NEWTON_API NewtonCollision* NewtonCreateCompoundCollision (const NewtonWorld* newtonWorld, int count, NewtonCollision* const collisionPrimitiveArray, int shapeID);
Creates a single collision object from multiple collision objects to represent a more complex shape. For example, several elongated box shapes can be put together to form a scaffold-like structure. Or, 3 spheres can make a snowman shape. Convex hulls may also be used in compound collisions to generate a huge variety of concave shapes.
- const NewtonWorld *newtonWorld - is the pointer to the Newton world.
- int shapeID - ID to associate with the collision shape.
- Pointer to the compound object
Creates a Compound mesh primitive for collision from a set of various objects. This is very useful, when you need to build complex non-static concave shapes, for instance a complex detailed car shape or a spaceship.
You can look at compound collision object the same way you look at other rigid bodies.
To make a rigid body you do:
- create collision
- create body, passing the collision
- release collision
For objects with compound collision, same process
- create all sub collision primitives and place then into an array
- create compound collision, passing the array of collision primitives
- create rigid body, passing the compound collision
- release the compound collision
- release all sub-collision primitives
As you can see, it is the same creation wrapped in the sub collision primitive create-release extatement. You can not add collision tres, terrains, or user collision since this can only be static.
Compound collison can only be built using the closed (convex) shape collision primitives such as boxes, capsules, cylinders, convex hulls, etc. That means, you can not create a compound collision that uses collision trees, terrains, or user collision as parts since these primitives can only be static. You can also not use other compound collisions as parts. But you can include their pieces. You can use NewtonCollisionGetInfo to find out of which type a collision primitive is.
- Since Newton 2.0, compound collisions may be reused/shared by multiple rigid bodies just like any other collision object - Newton will create a duplicate of the compound collision for each new body.
- since Newton 3, count and collisionPrimitiveArray parameters were removed and compount collision is now built similar to collision trees via NewtonCompoundCollisionBeginAddRemove, NewtonCompoundCollisionAddSubCollision, NewtonCompoundCollisionEndAddRemove, NewtonCompoundCollisionRemoveSubCollision functions.