Code: Select all
bool callbackFunc(btManifoldPoint &cp, const btCollisionObjectWrapper *obj1, int id1, int index1, const btCollisionObjectWrapper *obj2, int id2, int index2)
{
const btCollisionObject *o1 = obj1->getCollisionObject();
const btCollisionObject *o2 = obj2->getCollisionObject();
int index = -1;
if(o1 == femur8->getBody())
{
std::cout << "o1 == femur " << id1 << " " << index1 << std::endl;
index=index1;
}
if(o2 == femur8->getBody())
{
std::cout << "o2 == femur" << id2 << " " << index2 << std::endl;
index=index2;
}
if(index == -1) return false;
btGImpactMeshShape *shape = static_cast<btGImpactMeshShape*>(femur8->getBody()->getCollisionShape());
btTriangleShapeEx triangle;
shape->getBulletTriangle(index, triangle);
btVector3 vert;
for(int i=0; i<3; ++i)
{
triangle.getVertex(i,vert);
std::cout << vert.getX() << " " << vert.getY() << " " << vert.getZ() << std::endl;
}
return false;
}
What am I doing wrong? Is the index passed to the callback function indeed the index of the triangle in the mesh or something else? Is there a way of doing what I am trying to do?
Thank you in advance for any help regarding this.