//localTrans.setOrigin(btVector3(0,0,1));
//#else
CollisionShape chassisShape = new BoxShape(new Vector3f(1.f,0.5f,2.f));
collisionShapes.add(chassisShape);
CompoundShape compound = new CompoundShape();
collisionShapes.add(compound);
Transform localTrans = new Transform();
localTrans.setIdentity();
// localTrans effectively shifts the center of mass with respect to the chassis
localTrans.origin.set(0,1,0);
//#endif
compound.addChildShape(localTrans,chassisShape);
{
CollisionShape suppShape = new BoxShape(new Vector3f(0.5f,0.1f,0.5f));
collisionShapes.add(chassisShape);
Transform suppLocalTrans = new Transform();
suppLocalTrans.setIdentity();
// localTrans effectively shifts the center of mass with respect to the chassis
suppLocalTrans.origin.set(0f,1.0f,2.5f);
compound.addChildShape(suppLocalTrans, suppShape);
}
tr.origin.set(0,0.f,0);
carChassis = localCreateRigidBody(800,tr,compound);//chassisShape);
//m_carChassis->setDamping(0.2,0.2);
{
CollisionShape liftShape = new BoxShape(new Vector3f(0.5f,2.0f,0.05f));
collisionShapes.add(liftShape);
Transform liftTrans = new Transform();
liftStartPos.set(0.0f, 2.5f, 3.05f);
liftTrans.setIdentity();
liftTrans.origin.set(liftStartPos);
liftBody = localCreateRigidBody(10,liftTrans, liftShape);
Transform localA = new Transform(), localB = new Transform();
localA.setIdentity();
localB.setIdentity();
MatrixUtil.setEulerZYX(localA.basis, 0, PI_2, 0);
localA.origin.set(0.0f, 1.0f, 3.05f);
MatrixUtil.setEulerZYX(localB.basis, 0, PI_2, 0);
localB.origin.set(0.0f, -1.5f, -0.05f);
liftHinge = new HingeConstraint(carChassis,liftBody, localA, localB);
liftHinge.setLimit(-LIFT_EPS, LIFT_EPS);
dynamicsWorld.addConstraint(liftHinge, true);
CollisionShape forkShapeA = new BoxShape(new Vector3f(1.0f,0.1f,0.1f));
collisionShapes.add(forkShapeA);
CompoundShape forkCompound = new CompoundShape();
collisionShapes.add(forkCompound);
Transform forkLocalTrans = new Transform();
forkLocalTrans.setIdentity();
forkCompound.addChildShape(forkLocalTrans, forkShapeA);
CollisionShape forkShapeB = new BoxShape(new Vector3f(0.1f,0.02f,0.6f));
collisionShapes.add(forkShapeB);
forkLocalTrans.setIdentity();
forkLocalTrans.origin.set(-0.9f, -0.08f, 0.7f);
forkCompound.addChildShape(forkLocalTrans, forkShapeB);
CollisionShape forkShapeC = new BoxShape(new Vector3f(0.1f,0.02f,0.6f));
collisionShapes.add(forkShapeC);
forkLocalTrans.setIdentity();
forkLocalTrans.origin.set(0.9f, -0.08f, 0.7f);
forkCompound.addChildShape(forkLocalTrans, forkShapeC);
Transform forkTrans = new Transform();
forkStartPos.set(0.0f, 0.6f, 3.2f);
forkTrans.setIdentity();
forkTrans.origin.set(forkStartPos);
forkBody = localCreateRigidBody(5, forkTrans, forkCompound);
localA.setIdentity();
localB.setIdentity();
MatrixUtil.setEulerZYX(localA.basis, 0, 0, PI_2);
localA.origin.set(0.0f, -1.9f, 0.05f);
MatrixUtil.setEulerZYX(localB.basis, 0, 0, PI_2);
localB.origin.set(0.0f, 0.0f, -0.1f);
forkSlider = new SliderConstraint(liftBody, forkBody, localA, localB, true);
forkSlider.setLowerLinLimit(0.1f);
forkSlider.setUpperLinLimit(0.1f);
forkSlider.setLowerAngLimit(-LIFT_EPS);
forkSlider.setUpperAngLimit(LIFT_EPS);
dynamicsWorld.addConstraint(forkSlider, true);
CompoundShape loadCompound = new CompoundShape();
collisionShapes.add(loadCompound);
CollisionShape loadShapeA = new BoxShape(new Vector3f(2.0f,0.5f,0.5f));
collisionShapes.add(loadShapeA);
Transform loadTrans = new Transform();
loadTrans.setIdentity();
loadCompound.addChildShape(loadTrans, loadShapeA);
CollisionShape loadShapeB = new BoxShape(new Vector3f(0.1f,1.0f,1.0f));
collisionShapes.add(loadShapeB);
loadTrans.setIdentity();
loadTrans.origin.set(2.1f, 0.0f, 0.0f);
loadCompound.addChildShape(loadTrans, loadShapeB);
CollisionShape loadShapeC = new BoxShape(new Vector3f(0.1f,1.0f,1.0f));
collisionShapes.add(loadShapeC);
loadTrans.setIdentity();
loadTrans.origin.set(-2.1f, 0.0f, 0.0f);
loadCompound.addChildShape(loadTrans, loadShapeC);
loadTrans.setIdentity();
loadStartPos.set(0.0f, -3.5f, 7.0f);
loadTrans.origin.set(loadStartPos);
loadBody = localCreateRigidBody(4, loadTrans, loadCompound);
}