Esempio n. 1
0
        private void LimitRotation(float timestep)
        {
            btQuaternion rot     = m_body.getWorldTransform().getRotation();
            bool         changed = false;

            if (m_RollreferenceFrame != Quaternion.Identity)
            {
                if (rot.getX() >= m_RollreferenceFrame.X)
                {
                    rot = new btQuaternion(rot.getX() - (m_RollreferenceFrame.X / 2), rot.getY(), rot.getZ(), rot.getW());
                }
                if (rot.getX() <= -m_RollreferenceFrame.X)
                {
                    rot = new btQuaternion(rot.getX() + (m_RollreferenceFrame.X / 2), rot.getY(), rot.getZ(), rot.getW());
                }

                if (rot.getY() >= m_RollreferenceFrame.Y)
                {
                    rot = new btQuaternion(rot.getX(), rot.getY() - (m_RollreferenceFrame.Y / 2), rot.getZ(), rot.getW());
                }
                if (rot.getY() <= -m_RollreferenceFrame.Y)
                {
                    rot = new btQuaternion(rot.getX(), rot.getY() + (m_RollreferenceFrame.Y / 2), rot.getZ(), rot.getW());
                }

                changed = true;
            }
            if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0)
            {
                rot     = new btQuaternion(0, 0, rot.getZ(), rot.getW());
                changed = true;
            }

            if (changed)
            {
                btTransform trans = m_body.getWorldTransform();
                trans.setRotation(rot);
                m_body.setWorldTransform(trans);
            }
        }