btTriangleIndexVertexArray to btBvhTriangleMeshShape to ...

Please don't post Bullet support questions here, use the above forums instead.
philT
Posts: 5
Joined: Wed Jun 02, 2010 1:34 pm

btTriangleIndexVertexArray to btBvhTriangleMeshShape to ...

Post by philT »

Code: Select all

const int c_vertex = 8;
const int c_tri = 12;
float vertex[c_vertex * 3] = {
   -20, -50, 20,
   -20, -50, -20,
   20, -50, -20,
   20, -50, 20,
   -20, 50, 20,
   -20, 50, -20,
   20, 50, -20,
   20, 50, 20};
int idx[c_tri * 3] = {
   1, 5, 8,
   1, 8, 4,
   4, 8, 7,
   4, 7, 3,
   3, 7, 6,
   3, 6, 2,
   2, 6, 5,
   2, 5, 1,
   5, 6, 7,
   5, 7, 8,
   2, 1, 4,
   2, 4, 3};

   btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(
      c_tri, idx, 3 * sizeof(int),
      c_vertex, vertex, 3 * sizeof(float));

    btBvhTriangleMeshShape* triShape = new btBvhTriangleMeshShape(indexVertexArrays, true);

    btVector3 localScaling(20,20,20);
	localScaling[1]=1.f;
	triShape->setLocalScaling(localScaling);


    btCollisionObject *colObj = new btCollisionObject();
    colObj->setCollisionShape(triShape);
   btTransform tr;
   tr.setIdentity();

    m_dynamicsWorld->addCollisionObject(triShape);
//or -> 	localCreateRigidBody(0,tr,triShape);

the Program is crashing when doing that kind of code.

How can i make a static collision mesh from indexVertexArrays that could be seen with debugDraw?