APOCALYX is a...

free Game Engine based on OpenGL (MAIL) (SITE) (FORUM) (BLOG)

Tuesday, September 16, 2008

Particle-based physics (II)

Sometimes people asks how those cloth simulations that you can find among the APOCALYX demos are done, or more precisely how can a virtual cloth be affected by wind. Are they simple animations or are precise physics laws applied?

I programmed that effect several years ago and some simplified technique had to be applied, because there was no PhysiX engine running on the GPU at that time. The wind-blowing-on-cloth effect was part of my particle-based physics engine, that I called SimulAxion.
I first read about a particle-based physics engine in an old paper by Thomas Jakobsen, who designed the dead-body simulator of the first chapter of the Hitman series: “Hitman: Codename 47”. In that paper Thomas described a simple way to simulate rigid-bodies, soft-bodies and cloths, through the use of particles linked by sticks. In practice, the particles follow the usual laws of dynamics, but also they are constrained in their motion by rigid connections with nearby particles. The result is a very fast way to create a believable physics behavior with little computational effort.
In practice, the algorithm works on a grid of particles connected by almost rigid constraints, not the usual springs as you can see in other simulations. The distance constraint is solved by the particles themselves over several frames: they simply adjust several times their position to better fit the required stick lengths.
Finally, to create the blowing wind effect, the 3 vertexes of each triangle, that the cloth is made of, are displaced accordingly to the surface exposure to the wind direction: large displacements when the wind is perpendicular, no one when it is parallel.
It may be surprising, but this small set of rules (linked particles and wind direction) is sufficient to create in a realistic way those characteristics movements of flags and cloths.

No comments: