if (this.rigidBody == null || trimesh == null)
return;
Transform transform = new Transform();
MotionState motionstate = rigidBody.getMotionState();
motionstate.getWorldTransform(transform);
Matrix4f chairMatrix = new Matrix4f();
transform.getMatrix(chairMatrix);
// LOGGER.debug("current origin"+transform.origin.toString());
//this is overwritten when settign the chair matrix
//transform.origin.set(this.centreOfMass.x, this.centreOfMass.y,
// this.centreOfMass.z);
LOGGER.debug("delta x" + deltaCentreOfmass.x);
LOGGER.debug("delta y" + deltaCentreOfmass.y);
LOGGER.debug("delta z" + deltaCentreOfmass.z);
float newX = ((chairMatrix.m00) * deltaCentreOfmass.x)
+ ((chairMatrix.m01) * deltaCentreOfmass.y)
+ ((chairMatrix.m02) * deltaCentreOfmass.z);
float newY = (((chairMatrix.m10) * deltaCentreOfmass.x)
+ ((chairMatrix.m11) * deltaCentreOfmass.y) + ((chairMatrix.m12) * deltaCentreOfmass.z));
float newZ = ((chairMatrix.m20) * deltaCentreOfmass.x)
+ ((chairMatrix.m21) * deltaCentreOfmass.y)
+ ((chairMatrix.m22) * deltaCentreOfmass.z);
//these are the origin
chairMatrix.m03 -= deltaCentreOfmass.x;//10;//deltaCentreOfmass.x;
chairMatrix.m13 -= deltaCentreOfmass.y;//deltaCentreOfmass.y;
chairMatrix.m23 += deltaCentreOfmass.z;//deltaCentreOfmass.z;
//chairMatrix.m03 = this.centreOfMass.x;
//chairMatrix.m13 = this.centreOfMass.y;
//chairMatrix.m23 = this.centreOfMass.z;
LOGGER.debug("delta x t " + newX);
LOGGER.debug("delta y t " + newY);
LOGGER.debug("delta z t " + newZ);
transform.set(chairMatrix);
motionstate.setWorldTransform(transform);
rigidBody.setMotionState(motionstate);
Vector3f center = new Vector3f();
rigidBody.getCenterOfMassPosition(center);
LOGGER.debug("getCenterOfMassPosition set " + center);
// System.out.println("weight" + this.getArea());
Vector3f AngularVelocity = new Vector3f(0, 0, 0);
rigidBody.getAngularVelocity(AngularVelocity);
Vector3f LinearVelocity = new Vector3f(0, 0, 0);
rigidBody.getLinearVelocity(LinearVelocity);
GLOBAL.jBullet.update();
motionstate.getWorldTransform(transform);
// LOGGER.debug("new origin"+transform.origin.toString());
//this.translate(-newX, newY, newZ);
// rigidBody.setAngularVelocity(AngularVelocity);