NewtonCollision* NewtonCreateBox( const NewtonWorld* newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat *offsetMatrix)
Creates a box / cuboid primitive body.
- const NewtonWorld *newtonWorld - is the pointer to the Newton world.
- dFloat dx - box side one x dimension.
- dFloat dy - box side one y dimension.
- dFloat dz - box side one z dimension.
- int shapeID
- const dFloat *offsetMatrix - pointer to an array of 16 floats containing the offset matrix of the box relative to the body. Note: If this parameter is NULL, then the primitive is centered at the origin of the body.
- pointer to the box
This function creates a "bounding box" collision mesh in the NewtonWorld specified by the first parameter. The second, third, and fourth parameters are the dimensions of the box. The last is a 4x4 matrix stored as an array of 16 floats, which specifies the position of the box in the 3D world.
An important thing to remember is that if you are creating a box for a scene node, you need to set the initial position of this box to the initial position of your node in the game; otherwise, the node will not be at the same place in your world as your collision detection. This will result in strange things happening.
- Collision primitives are reference counted objects. The application should call NewtonReleaseCollision in order to release references to the object. Neglecting to release references to collision primitives is a common cause of memory leaks. Collision primitives can be reused with more than one body. This will reduce the amount of memory used be the engine, as well as speed up some calculations.