예제 #1
0
 protected override void OnSetAngularVelocity()
 {
     if (PushedToWorld && bodyID != IntPtr.Zero)
     {
         Ode.dBodySetAngularVel(bodyID, AngularVelocity.X, AngularVelocity.Y, AngularVelocity.Z);
         //freelySpinning = false;
     }
 }
예제 #2
0
        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();
        }