예제 #1
0
        } //end MoveAngular

        internal void LimitRotation(float timestep)
        {
            SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body);
            Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);    // rotq = rotation of object

            SafeNativeMethods.Quaternion m_rot = new SafeNativeMethods.Quaternion();
            bool changed = false;

            m_rot.X = rotq.X;
            m_rot.Y = rotq.Y;
            m_rot.Z = rotq.Z;
            m_rot.W = rotq.W;
            if (m_RollreferenceFrame != Quaternion.Identity)
            {
                if (rotq.X >= m_RollreferenceFrame.X)
                {
                    m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2);
                }
                if (rotq.Y >= m_RollreferenceFrame.Y)
                {
                    m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2);
                }
                if (rotq.X <= -m_RollreferenceFrame.X)
                {
                    m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2);
                }
                if (rotq.Y <= -m_RollreferenceFrame.Y)
                {
                    m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2);
                }
                changed = true;
            }
            if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0)
            {
                m_rot.X = 0;
                m_rot.Y = 0;
                changed = true;
            }
            if (changed)
            {
                SafeNativeMethods.BodySetQuaternion(Body, ref m_rot);
            }
        }