Difference between revisions of "NewtonCreateBox"

From Newton Wiki
Jump to: navigation, search
 
m (1 revision imported)
 
(No difference)

Latest revision as of 08:02, 10 June 2019

NewtonCreateBox

Syntax:

NewtonCollision* NewtonCreateBox( const NewtonWorld* newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat *offsetMatrix)

Usage

Creates a box / cuboid primitive body.

Parameters

  • 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.

Return

  • pointer to the box

Description

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.

Remarks

  • 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.

See also

NewtonReleaseCollisionNewtonCreateConvexHullModifier Newton SDK API reference#Category:convex_collision_primitives_creation_functions