Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
        public void LookAt(LLVector3 origin, LLVector3 target, LLVector3 upDirection)
        {
            this.origin = origin;
            LLVector3 at = new LLVector3(target - origin);

            at = LLVector3.Norm(at);

            LookDirection(at, upDirection);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
            /// <summary>
            /// Rotates the avatar body and camera toward a target position.
            /// This will also anchor the camera position on the avatar
            /// </summary>
            /// <param name="target">Region coordinates to turn toward</param>
            public bool TurnToward(LLVector3 target)
            {
                if (Client.Settings.SEND_AGENT_UPDATES)
                {
                    LLVector3    myPos   = Client.Self.SimPosition;
                    LLVector3    forward = new LLVector3(1, 0, 0);
                    LLVector3    offset  = LLVector3.Norm(target - myPos);
                    LLQuaternion newRot  = LLVector3.RotBetween(forward, offset);

                    BodyRotation = newRot;
                    HeadRotation = newRot;
                    Camera.LookAt(myPos, target);

                    SendUpdate();

                    return(true);
                }
                else
                {
                    Logger.Log("Attempted TurnToward but agent updates are disabled", Helpers.LogLevel.Warning, Client);
                    return(false);
                }
            }