Code: Select all
LPDIRECT3DVERTEXBUFFER9 pVertices;
Mesh->GetVertexBuffer( &pVertices );
DWORD dwVertexSize = Mesh->GetNumBytesPerVertex();
BYTE* pVertexData;
pVertices->Lock(0, 0, (void**)&pVertexData, 0);
LPDIRECT3DINDEXBUFFER9 pIndices;
Mesh->GetIndexBuffer(&pIndices);
BYTE* pIndexData;
pIndices->Lock(0, 0, (void**)&pIndexData, 0);
btTriangleIndexVertexArray *trimesh = new btTriangleIndexVertexArray(Mesh->GetNumFaces(), (int*)pIndexData, 3 * sizeof(int), Mesh->GetNumVertices(), (btScalar*)pVertexData, dwVertexSize);
pIndices->Unlock();
pIndices->Release();
pVertices->Unlock();
pVertices->Release();
Code: Select all
Vector3 min, max;
model->GetAABB(&min, &max);
btVector3 bMin(-1000, -1000, -1000), bMax(1000, 1000, 1000);
btBvhTriangleMeshShape *trimeshShape = new btBvhTriangleMeshShape(trimesh, true, bMin, bMax);
extern btDynamicsWorld *m_dynamicsWorld;
float mass = 1;
btCollisionShape *collision = trimeshShape;
btVector3 inertia;
collision->calculateLocalInertia(mass, inertia);
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(loc.x, loc.y, loc.z));
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, collision, inertia);
btRigidBody *body = new btRigidBody(rbInfo);
m_dynamicsWorld->addRigidBody(body);
Debugger points at this line:
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
Inside BulletCollision\CollisionShapes\btStridingMeshInterface.cpp
Anyone have idea what's wrong?
Let me know if I forgot to post any details.
Thanks in advance.