예제 #1
0
        /// <summary>
        /// implementation updates the position/orientation with the
        /// current velocties.
        /// </summary>
        /// <param name="dt"></param>
        public void UpdatePosition(float dt)
        {
            if (immovable || !IsActive)
            {
                return;
            }

            #region REFERENCE: Vector3 angMomBefore = Vector3.Transform(transformRate.AngularVelocity, worldInertia);
            Vector3 angMomBefore;
            Vector3.Transform(ref transformRate.AngularVelocity, ref worldInertia, out angMomBefore);
            #endregion

            transform.ApplyTransformRate(transformRate, dt);

            #region REFERENCE: invOrientation = Matrix.Transpose(transform.Orientation);
            Matrix.Transpose(ref transform.Orientation, out invOrientation);
            #endregion

            // recalculate the world inertia
            #region REFERENCE: worldInvInertia = invOrientation * bodyInvInertia * transform.Orientation;
            Matrix.Multiply(ref invOrientation, ref bodyInvInertia, out worldInvInertia);
            Matrix.Multiply(ref worldInvInertia, ref transform.Orientation, out worldInvInertia);
            #endregion

            #region REFERENCE: worldInertia = invOrientation * bodyInertia * transform.Orientation;
            Matrix.Multiply(ref invOrientation, ref bodyInertia, out worldInertia);
            Matrix.Multiply(ref worldInertia, ref transform.Orientation, out worldInertia);
            #endregion

            // conservation of momentum
            #region REFERENCE: transformRate.AngularVelocity = Vector3.Transform(angMomBefore, worldInvInertia);
            Vector3.Transform(ref angMomBefore, ref worldInvInertia, out transformRate.AngularVelocity);
            #endregion

            if (this.CollisionSkin != null)
            {
                CollisionSkin.SetTransform(ref oldTransform, ref transform);
            }
        }