I'm currently working on something like tank simulator, and i want all parts of tank (like turret, gun etc.) to be physical. At first i used hingeconstraints to connect parts, but parts penetrate each other, and when i'm rotating tank hull, turret didn't rotate

I've tried setParam values(erp, cfm) but it didn't help.
So i want to try compound shape.
Actually i'm making hull & turret as rigid body with compound collision shapes, next i'm adding convex shapes like in this code:
Code: Select all
hull.module->collShape = new btConvexHullShape(hull.cnv_mesh->positions.data(), hull.cnv_mesh->positions.size()/3, 3*sizeof(float));
hull.module->collShape->setLocalScaling(btVector3(1,1,1)*SCALE);
hull.module->compound = new btCompoundShape();
btTransform localTrans;
localTrans.setIdentity();
localTrans.setOrigin(btVector3(0,0,0));
hull.module->compound->addChildShape(localTrans,hull.module->collShape);
tr.setOrigin(btVector3(0,0,0));
hull.module->rgBody = bulletWorld.createRigidBody(hull.node["mass"].as<float>(),tr,hull.module->compound);
Code: Select all
turret.module->collShape = new btConvexHullShape(it.cnv_mesh->positions.data(), turret.cnv_mesh->positions.size()/3, 3*sizeof(float));
it.module->rgBody = bulletWorld.createRigidBody(it.node["mass"].as<float>(),tr,it.module->collShape);
localTrans.setOrigin(pivotA);
hull.module->compound->addChildShape(localTrans, compound);

My question is:
how to move childs of compound shape with respects to their parents, or how to move bodies connected via hingeConstraint respects to their parents and how to disable moving along axis when i'm using higeConstraint.
Karol