(C++) Create a Newton Collision from an Irrlicht BoundingBox

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

(C++) Create a Newton Collision from an Irrlicht BoundingBox

Post by JonLT »

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());
}
remenber:

Code: Select all

#include <irrlicht.h>
#include <newton.h>
and the namespaces
Post Reply