I found some code for it on the forums. I'm sorry, I do not remember who wrote it - if it is yours, feel free to yell and scream.
Here it is, just to make it easy!
Header
Code: Select all
void showCollision();
void NewtonDebugCollision (const NewtonBody* body, int vertexCount, const float* faceVertec, int id);
void NewtonDebugBody(const NewtonBody* body);
CPP
Code: Select all
void showCollision() {
matrix4 mat;
SMaterial material;
material.Textures[1] = 0;
material.Lighting = false;
video_driver -> setTransform(ETS_WORLD, mat);
video_driver -> setMaterial(material);
NewtonWorldForEachBodyDo(nWorld, NewtonDebugBody);
}
void NewtonDebugBody(const NewtonBody* body){
if(!video_driver) return;
NewtonBodyForEachPolygonDo(body, NewtonDebugCollision);
}
void NewtonDebugCollision(const NewtonBody* body, int vertexCount, const float* FaceArray, int faceId){
vector3df p0(FaceArray[0], FaceArray[1], FaceArray[2]);
const SColor c0(0, 0, 255, 0);
for(int i = 2; i < vertexCount; i ++){
vector3df p1(FaceArray[(i-1) * 3 + 0], FaceArray[(i-1) * 3 + 1], FaceArray[(i-1) * 3 + 2]);
vector3df p2(FaceArray[i * 3 + 0], FaceArray[i * 3 + 1], FaceArray[i * 3 + 2]);
triangle3df t;
t.set(p1, p2, p0);
video_driver ->draw3DTriangle(t, c0);
}
}
Just run showCollision() following your world update or something. Kind of like this.
Code: Select all
while (true) {
NewtonUpdate(world, t);
showCollision();
}
I am not sure if that is right, but it works for me.
-
Incidentally, I have sorted out my meshes. My brother (who is the graphical artist in the family), showed me where I went wrong in my pivot points and alignment.