protected override void OnSetTransform(bool updatePosition, bool updateRotation) { base.OnSetTransform(updatePosition, updateRotation); if (PushedToWorld) { if (!Static) { if (bodyID != IntPtr.Zero) { if (updatePosition) { Ode.dBodySetPosition(bodyID, Position.X, Position.Y, Position.Z); } if (updateRotation) { Ode.dQuaternion odeQuat; Convert.ToODE(Rotation, out odeQuat); Ode.dBodySetQuaternion(bodyID, ref odeQuat); } } } else { UpdateStaticBodyGeomsTransform(); } } }
void PushToWorld() { if (!Static) { bodyID = Ode.dBodyCreate(scene.worldID); UpdateSleepiness(); Ode.dBodySetPosition(bodyID, Position.X, Position.Y, Position.Z); Ode.dQuaternion odeQuat; Convert.ToODE(Rotation, out odeQuat); Ode.dBodySetQuaternion(bodyID, ref odeQuat); Ode.dBodySetLinearVel(bodyID, LinearVelocity.X, LinearVelocity.Y, LinearVelocity.Z); Ode.dBodySetAngularVel(bodyID, AngularVelocity.X, AngularVelocity.Y, AngularVelocity.Z); if (Sleeping) { Ode.dBodyDisable(bodyID); } else { Ode.dBodyEnable(bodyID); } if (!EnableGravity) { Ode.dBodySetGravityMode(bodyID, 0); } } bodyData = Ode.CreateBodyData(bodyID); CreateGeomDatas(); //no shapes if (geomDatas == null || geomDatas.Length == 0) { PopFromWorld(); return; } if (!Static) { CalculateBodyMass(); } RecreateAttachedJoints(); }