anyone has any example about a integration between "ITerrainSceneNode" and Newton collision manager?
This is the code im using for my static objects, but i didn't found any example in order to do the same with a heightmap terrain.
Code: Select all
void CreateNewtonMesh(NewtonWorld *world, IAnimatedMeshSceneNode *node)
{
NewtonCollision *treeCollision;
treeCollision = NewtonCreateTreeCollision(world, NULL);
NewtonTreeCollisionBeginBuild(treeCollision);
IMesh *mesh = node->getMesh();
for (unsigned int i = 0; i < mesh->getMeshBufferCount(); i++)
{
IMeshBuffer *mb = mesh->getMeshBuffer(i);
switch(mb->getVertexType())
{
case EVT_STANDARD:
addMeshToTreeCollisionStandard(mb, treeCollision, node->getScale());
break;
case EVT_2TCOORDS:
addMeshToTreeCollision2TCoords(mb, treeCollision, node->getScale());
break;
case EVT_TANGENTS:
addMeshToTreeCollisionTangents(mb, treeCollision, node->getScale());
break;
default:
printf("Newton error: Unknown vertex type in static mesh: %d\n",
mb->getVertexType());
break;
}
}
NewtonTreeCollisionEndBuild(treeCollision, 1);
NewtonBody* treeBody;
treeBody = NewtonCreateBody(world, treeCollision);
NewtonReleaseCollision(world, treeCollision);
NewtonBodySetUserData(treeBody, node);
}