Code: Select all
//! create a NewtonCollision from an irrlicht bounding box
NewtonCollision* CreateCollisionFromBoundingBox(NewtonWorld *nWorld, aabbox3df boundingBox)
{
//calculate the dimensions of the bounding box
vector3df boundingBoxSize(boundingBox.MaxEdge.X - boundingBox.MinEdge.X,
boundingBox.MaxEdge.Y - boundingBox.MinEdge.Y,
boundingBox.MaxEdge.Z - boundingBox.MinEdge.Z);
//get the relative center of the bounding box and put it to a matrix4
matrix4 boundingBoxCenterMatrix;
boundingBoxCenterMatrix.setTranslation(boundingBox.getCenter());
/* make the newton collision box from the dimensions of the bounding box
and offset it to the center of the bounding box */
return NewtonCreateBox(nWorld,
boundingBoxSize.X,
boundingBoxSize.Y,
boundingBoxSize.Z,
boundingBoxCenterMatrix.pointer());
}
Code: Select all
#include <irrlicht.h>
#include <newton.h>