Rigid Body Physics in SXE
by, 04-19-2010 at 03:55 AM (16997 Views)
For physics simulation PhysX by NVIDIA has been integrated to Spin-X Engine and will be available in the next public release. The engine also features a streamlined physics asset pipeline and tools to further adjust physics assets in the Spin-X Editor.
Collision objects for static meshes are defined in your favourite 3D modelling application. Each static mesh can be composed of multiple collision object and each object is named so that it has "CVOL" string (short for "collision volume") in the object name, which the engine interprets as being used solely for collision primitive definition. In the two images below I have split the mushroom to "cap" and "stem" collision object in modo 401 and respectively named the objects to "Mushroom Cap [CVOL]" and "Mushroom Stem [CVOL]". The 3 other objects define the 3 different LODs used for rendering the mesh at different distances and doesn't contribute to collision object definition.
Once the mesh is properly defined, it can be imported to Spin-X Editor. Upon object import different tight bounding volumes and collision primitives for the mesh are automatically created, which can be viewed by selecting the viewed bounding volume from the "BVol" drop-down menu in static mesh editor as shown below. The red bounding volumes are different types of bounding volumes enclosing the entire object (including LODs), while the green volumes display the collision primitives that were created for the collision objects defined in modo.
The primitive type (e.g. sphere, capsule, etc.) selected for each collision object depends on the primitives supported by the physics engine, which by default is set to an enclosing primitive which has the smallest surface area for each collision object. This can be overridden in object properties for each collision object individually, e.g. in the image below I have used object-oriented box (i.e. preferred shape = oobox) instead of capsule for the stem collision object. Because the collision geometry doesn't have to match the visual geometry, you can optionally create desired primitive object in the modelling app and Spin-X Engine will automatically use closest matching pimitive for it.
To test rigid body collision in the engine I created a small physics scene in Spin-X Editor shown below:
And here's a short video clip showing the scene in action: