Beispiel #1
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>
            /// <param name="sendUpdate">whether to send update or not</param>
            public bool TurnToward(Vector3 target, bool sendUpdate)
            {
                if (Client.Settings.SEND_AGENT_UPDATES)
                {
                    Quaternion parentRot = Quaternion.Identity;

                    if (Client.Self.SittingOn > 0)
                    {
                        if (!Client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(Client.Self.SittingOn))
                        {
                            Logger.Log("Attempted TurnToward but parent prim is not in dictionary", Helpers.LogLevel.Warning, Client);
                            return false;
                        }
                        else parentRot = Client.Network.CurrentSim.ObjectsPrimitives[Client.Self.SittingOn].Rotation;
                    }

                    Quaternion between = Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(target - Client.Self.SimPosition));
                    Quaternion rot = between * (Quaternion.Identity / parentRot);

                    BodyRotation = rot;
                    HeadRotation = rot;
                    Camera.LookAt(Client.Self.SimPosition, target);

                    if (sendUpdate) SendUpdate();

                    return true;
                }
                else
                {
                    Logger.Log("Attempted TurnToward but agent updates are disabled", Helpers.LogLevel.Warning, Client);
                    return false;
                }
            }
Beispiel #2
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);
                }
            }