Fixing Stiffness with Hinge constraint

shashwatsher
Posts: 5
Joined: Thu Mar 19, 2015 6:08 pm

Fixing Stiffness with Hinge constraint

Post by shashwatsher »

Hi guys

I am building a car game with help of bullet physics and need help regarding a specific functionality.
I have attached a Canon to my car to shoot bullets. Actually my car body and the canon are two separate rigidbody objects attached using btHingeConstraint ( there is a reason why i have done that instead of using compoundshape). The canon is at right position and the shooting is also working perfectly.
The problem happens when my car collides with a building. At this moment my canon dislodges from the car. Is there a way I can make canon stiffly bound tho the car using hingeconstarint only? I read bout CFM and ERP but they prove to be of no use. Here is a sample code -
btVector3 cyl_coord = btVector3(0.5, 1, 1);
btCollisionShape* suppShape = new btCylinderShapeZ(cyl_coord);
suppLocalTrans.setIdentity();
suppLocalTrans.setOrigin(m_cameraPosition);
m_canon = localCreateRigidBody(1,suppLocalTrans, suppShape); // Canon added to car

btTransform localC, localD;
localC.setIdentity();
localD.setIdentity();
localC.getBasis().setEulerZYX(0, M_PI_2, 0);
localC.setOrigin(btVector3(0.0, 0.2, 1.05));
localD.getBasis().setEulerZYX(0, M_PI_2, 0);
localD.setOrigin(btVector3(0.0, -1.5, -1.05));
m_liftHinge = new btHingeConstraint(*m_carChassis,*m_canon, localC, localD);// Creating the constraint
m_liftHinge->setLimit(0.0f, 0.0f);
m_liftHinge->setParam( BT_CONSTRAINT_STOP_CFM, 0, -1);
m_dynamicsWorld->addConstraint(m_liftHinge, true);

Can any one help with this.
You do not have the required permissions to view the files attached to this post.
shashwatsher
Posts: 5
Joined: Thu Mar 19, 2015 6:08 pm

Re: Fixing Stiffness with Hinge constraint

Post by shashwatsher »

Not Even A single reply on the issue???? C'mon guys any suggestion here would be really helpful...