[SOLVED] Irrlicht to Newton mesh - Segmentation fault
Posted: Sun Jan 25, 2009 4:13 am
I'm having trouble converting my Irrlicht mesh into a newton collision. When I run the following code, Newton causes a segmentation fault. I've been getting help at the Newton Dynamics forums, but after pointing out multiple things I was doing wrong with Newton (and me fixing them), they are now saying that I must be collecting the triangles incorrectly.
Can anyone here help?
Can anyone here help?
Code: Select all
collision = NewtonCreateTreeCollision(physworld, NULL);
NewtonTreeCollisionBeginBuild(collision);
// loop through, adding triangles.
mesh->grab();
singleframe = mesh;
totalbuffers = singleframe->getMeshBufferCount();
for (int i = 0; i < totalbuffers; i++)
{
meshbuffer = singleframe->getMeshBuffer(i);
meshbuffer->grab();
//mb_vertices = (irr::video::S3DVertex2TCoords*)meshbuffer->getVertices();
//mb_indices = meshbuffer->getVertices();
mb_vertices_total = meshbuffer->getVertexCount();
for (int a = 0; a < mb_vertices_total-2; a++)
{
for (int b = 0; b < 3; b++)
{
p[b] = meshbuffer->getPosition(a+b);
newvertex[b][0] = p[b].X;
newvertex[b][1] = p[b].Y;
newvertex[b][2] = p[b].Z;
}
NewtonTreeCollisionAddFace(
collision,
3,
&newvertex[0][0],
sizeof(float)*3,
1);
nonlua_debug("Adding triangle " << a << " of " << mb_vertices_total-2,LVL_INFO);
}
meshbuffer->drop();
}
singleframe = 0;
mesh->drop();
NewtonTreeCollisionEndBuild(collision, 0);