Пример #1
0
 protected void Orthonormalize()
 {
     // Make sure the axis are orthagonal and normalized
     xAxis  = LLVector3.Norm(xAxis);
     yAxis -= xAxis * (xAxis * yAxis);
     yAxis  = LLVector3.Norm(yAxis);
     zAxis  = LLVector3.Cross(xAxis, yAxis);
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="at">Looking direction, must be a normalized vector</param>
        /// <param name="upDirection">Up direction, must be a normalized vector</param>
        public void LookDirection(LLVector3 at, LLVector3 upDirection)
        {
            // The two parameters cannot be parallel
            LLVector3 left = LLVector3.Cross(upDirection, at);

            if (left == LLVector3.Zero)
            {
                // Prevent left from being zero
                at.X += 0.01f;
                at    = LLVector3.Norm(at);
                left  = LLVector3.Cross(upDirection, at);
            }
            left = LLVector3.Norm(left);

            xAxis = at;
            yAxis = left;
            zAxis = LLVector3.Cross(at, left);
        }