Пример #1
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();
        }