Hey Guys,
Thanks very much for the help.
I've tried using an triangle array but wasn't quite shure which shape i should choose (or how to pass to btBvhTriangleMeshShape, couldn't figure out format for vertexBase.it's a btScalar?! o.O ).
So i fell back to my start off try.
Which kind of works but i think its not good for my use...i can import any mesh from Ogre but as soon as it's a concave for example a box with on face opened , so a sphere could go in,
it just kind of interpolates between vertices so instead of a hollow cube i get something like an inverse pyramid where the sphere goes in.
So i gues only some "outer shape" is calculated and kind of interpolated, so it's not the actual shape of the mesh.
Well this is my code so far:
Code: Select all
int *createFromEntity(Ogre::Entity *ent, Ogre::Vector3 pos, Ogre::Quaternion ori, Ogre::Vector3 size)
{
size_t vertex_count,index_count;
Ogre::Vector3* vertices;
unsigned long* indices;
int triIndex;
Ogre::MeshPtr meshptr;
meshptr = ent->getMesh();
if(meshptr.isNull())
{
printf("ERROR : MeshPointer is NULL\n");
return 0;
}
getMeshInformation(meshptr.getPointer() , vertex_count,vertices, index_count, indices, pos, ori, size);
printf("Vertices in mesh: %d \n",vertex_count);
printf("Triangles in mesh: %d \n",index_count);
btTriangleMesh* data = new btTriangleMesh();
//btConvexHullShape *cShape = new btConvexHullShape();
triIndex = 0;
for(unsigned int i = 0;i < vertex_count; i+=3)
{
triIndex++;
btVector3 A = btVector3((float)vertices[i].x,(float)vertices[i].y,(float)vertices[i].z);
btVector3 B = btVector3((float)vertices[i+1].x,(float)vertices[i+1].y,-(float)vertices[i+1].z);
btVector3 C = btVector3((float)vertices[i+2].x,(float)vertices[i+2].y,-(float)vertices[i+2].z);
data->addTriangle(A,B,C,false); // false, don’t remove duplicate vertices
data->addIndex(triIndex);
printf("----------Triangle #%d-----------------\n",triIndex);
printf("Point added at X %.0f | Y %.0f | Z%.0f \n",(float)A[0],(float)A[1],(float)A[2]);
printf("Point added at X %.0f | Y %.0f | Z%.0f \n",(float)B[0],(float)B[1],(float)B[2]);
printf("Point added at X %.0f | Y %.0f | Z%.0f \n",(float)C[0],(float)C[1],(float)C[2]);
printf("----------------------------------------\n");
}
// true for using quantization; true for building the BVH
btLabyrinthShape=new btBvhTriangleMeshShape(data,true,true);
btTriangleInfoMap *TriangleInfoMap = new btTriangleInfoMap();
btGenerateInternalEdgeInfo(btLabyrinthShape, TriangleInfoMap);
delete[] vertices;
delete[] indices;
return 0;
}
So any idea what shape i should use?
I want to import from a Labyrinth mesh where the sphere should be able to roll inside and collide with the walls.
Or maybe the import of my vertices is wrong , couldn't find how Bulletshape requires the Vertice Order...like x,y,z per triangle?!
Thanks in advance!
