looking for working code to create btGImpactMeshShape

Post Reply
jdoriang
Posts: 5
Joined: Fri Jun 16, 2017 2:20 pm

looking for working code to create btGImpactMeshShape

Post by jdoriang » Fri Jun 16, 2017 10:44 pm

Hi

I am unable to get working collisions using btGImpactShape. Maybe I doing the construction incorrectly. debugDrawer does not draw any shapes and there are no collisions (when there should be!).

Here is my code :

Code: Select all

btTriangleMesh *mTriMesh = new btTriangleMesh(true, false);

	for (int i = 0; i < m_Entries[0].vertices.size()/3; i++) {
		btVector3 v1(m_Entries[0].vertices[i].x, m_Entries[0].vertices[i].y, m_Entries[0].vertices[i].z);
		btVector3 v2(m_Entries[0].vertices[i+1].x, m_Entries[0].vertices[i+1].y, m_Entries[0].vertices[i+1].z);
		btVector3 v3(m_Entries[0].vertices[i+2].x, m_Entries[0].vertices[i+2].y, m_Entries[0].vertices[i+2].z);
		mTriMesh->addTriangle(v1, v2, v3, true);
	}

	btGImpactMeshShape *groundCollisionShape = new btGImpactMeshShape(mTriMesh);
	groundCollisionShape->setMargin(0.05);
	int i = groundCollisionShape->getMeshPartCount();

	/* shape test 2 END */
	//btCollisionShape* boxCollisionShape = new btBoxShape(btVector3(1.0f, 1.0f, 1.0f)); // TEST
	btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass,              // mass, in kg. 0 -> Static object, will never move.
		motionstate,
		groundCollisionShape,
		localInertia);     // local inertia
	rigidBody = new btRigidBody(rigidBodyCI);
	rigidBody->activate(true);
	dynamicsWorld->addRigidBody(rigidBody);
	//dynamicsWorld->getDispatchInfo().m_enableSatConvex = true;
	rigidBody->setUserPointer((void*)this);
	rigidBody->setGravity(btVector3(0.0f, 0.0f, 0.0f));
Please help. I am working towards a University deadline and collisions do not work...

Thanks

Rupert

Post Reply