Collision shapes - Outerra/anteworld GitHub Wiki
Collision shapes
Collision shapes are used for collision detection in Outerra engine. Collision shapes have to be standalone meshes attached to the central bone hierarchy. Only the FBX Importer (Ctrl+F7) supports importing collision shapes.
Collision geometry is created from meshes that are specifically named. The shape type is determined by the node name prefix. The prefix is filtered out from the resulting node name.
Supported types:
- COL_CONVEX (convex hull)
- COL_SPHERE
- COL_BOX
- COL_CYLINDER
- COL_CAPSULE
- COL_CONE
- COL_WHEEL
Note that, with the exception of the convex hull, the mesh itself is not used directly to determine parameters of the shape. Parameters like the radius and height for parametric collision shapes are derived from the mesh’s AABB instead. It’s important to have the pivot in right position; some objects need the pivot in object’s center, others in object’s base (see below).
The meshes are imported into the package as well and can be used for debugging purposes, so it’s a good idea to have the meshes roughly corresponding to actual collision shapes (cylinder should be cylinder etc.).
Resulting collision shape is a union of the primitive shapes present in the model. If the shapes are attached to animated bones, the collision body will be automatically updated with the bones.
Convex hull - COL_CONVEX
There is no check if the mesh is really convex! Convex hull is created from mesh vertices. For performance reasons the triangle count should be kept low. Shading should be set to smooth and UV map disabled to avoid unnecessary vertex splitting.
Note it’s preferable to use the parametric shapes instead of the convex mesh when possible, as they are faster.
Sphere shape - COL_SPHERE
Pivot point has to be in sphere center. Radius is computed from AABB’s half vector and its X component.
Box shape - COL_BOX
Pivot point has to be in the box center. Shape is defined from AABB’s half vector.
Cylinder shape - COL_CYLINDER
Pivot point has to be in the center of the cylinder. Radius is computed from AABB’s half vector along the X axis, and the central axis is aligned with Z axis.
Capsule shape - COL_CAPSULE
Pivot point has to be in the capsule center. Shape is defined by the AABB’s half vector. Radius and central axis are detected automatically.
Cone shape - COL_CONE
Pivot point has to be in the center of the cone base. Radius is computed from AABB’s half vector along the X axis, and the height along the Z axis.
Cylinder shape for wheel - COL_WHEEL
The basic geometric shape is the same as COL_CYLINDER, with the difference that the wheel collision geometry is not colliding with the terrain. It has to be the child of the wheel bone!
Terrain occluder
The terrain occluders are the special types of the collision shapes, which define the interior of eg. tunnels. The terrain inside of the terrain occluder is not rendered and the collisions are disabled. It also defines a volume of the interior. That means it will not provide any collision responses while it still could be used for test if point is inside of given object. The terrain occluder name must contain special prefix similar to ordinary collision shape, but in the case of the terrain occluder you replace "COL" with "OCC" (eg. OCC_BOX,OCC_CYLINDER ...).
Recommendations:
Keep the count of the terrain occluders as low as you can. Generally the entrance to the underground needs more accuracy, but for the models which are meant to be entirely hidden under the ground the AABB should be sufficient. In the case of the entrance models we advise you to make a little margin which will be hidden in the model geometry.
Characters
Character collision shapes are generated automatically from bone hierarchy and character height (in future we can add additional coefficients to control shape generation).
Default hidden meshes
You can define the hidden meshes in the objdef file. Just add "hidden_meshes" section which holds the array of the names of the hidden meshes.
Note:
When you hide the collision mesh it also disables the collision of given mesh.
Example:
"hidden_meshes": ["mesh1", "mesh2", "mesh3", ...]