I've recently started doing stuff with bullet and can't figure out something.
I have got a simple soft body (a square patch) and a mesh that I load myself with tiny_obj_loader. I throw the patch on the mesh and expect it to get stuck on top of it.
Here's what I get: https://www.youtube.com/watch?v=VSS-G48 ... e=youtu.be
I can see that there's some kind of collision, since the patch is being pulled up a bit in the center when it goes through the mesh.
When I use the box primitive instead of a mesh, everything works fine.
So, here's the question:
How do I create a mesh properly and what am I doing wrong?
Code: Select all
btTriangleMesh* triangleMeshTerrain = new btTriangleMesh(); // here I parse the .obj file and add triangles via 'triangleMeshTerrain->addTriangle(vertex1, vertex2, vertex3);' btCollisionShape* collisionShapeTerrain = new btBvhTriangleMeshShape(triangleMeshTerrain, true); btTransform meshTransform; meshTransform.setIdentity(); meshTransform.setOrigin(btVector3(0.0, 0.0, 0.0)); btDefaultMotionState* motionState = new btDefaultMotionState(meshTransform); btRigidBody::btRigidBodyConstructionInfo rigidBodyConstructionInfo(0.0f, motionState, collisionShapeTerrain, btVector3(0.0, 0.0, 0.0)); btRigidBody* rigidBodyTerrain = new btRigidBody(rigidBodyConstructionInfo); rigidBodyTerrain->setFriction(btScalar(0.9)); getDynamicsWorld()->addRigidBody(rigidBodyTerrain);