public HeightfieldTile(Mosaic parent, int tileSizeSamples, float metersPerSample, int tileLocationX, int tileLocationZ, Vector3 worldLocMM)
     : base(parent, tileSizeSamples, metersPerSample, tileLocationX, tileLocationZ, worldLocMM)
 {
     globalMinHeightMeters = parent.MosaicDesc.GlobalMinHeightMeters;
     globalMaxHeightMeters = parent.MosaicDesc.GlobalMaxHeightMeters;
     globalHeightRangeMeters = globalMaxHeightMeters - globalMinHeightMeters;
 }
        protected MosaicTile(Mosaic parent, int tileSizeSamples, float metersPerSample, int tileX, int tileZ, Vector3 worldLoc)
        {
            this.parent = parent;
            this.tileSizeSamples = tileSizeSamples;
            this.metersPerSample = metersPerSample;
            this.tileX = tileX;
            this.tileZ = tileZ;
            this.worldLoc = worldLoc;

            MosaicDescription desc = parent.MosaicDesc;
            available = desc.TileAvailable(tileX, tileZ);
        }
예제 #3
0
        /// <summary>
        ///   Lock on the bubble dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange        = 40 * Client.OneMeter;
            const float MinFadeRange        = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            // Don't show if they are too far away
            if (ray.LengthSquared > MaxFadeRangeSquared)
            {
                widgetNode.Visible = false;
                return;
            }

            BubbleTextNode bubbleNode = (BubbleTextNode)widgetNode;

            if (bubbleNode.IsExpired(now))
            {
                widgetNode.Visible = false;
                return;
            }

            Vector3 widgetOffset = new Vector3(0, 0.3f * Client.OneMeter, 0);
            Point   pixelOffset  = new Point(0, -50);

            // if (!SetWidgetPosition(widgetNode, widgetOffset, pixelOffset))
            if (!SetWidgetPosition(widgetNode, Vector3.Zero, pixelOffset))
            {
                return;
            }

            if (ray.LengthSquared < MinFadeRangeSquared)
            {
                widgetNode.Widget.Alpha = 1.0f;
            }
            else
            {
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            }
            if (this.Visible)
            {
                widgetNode.Visible = true;
            }
        }
예제 #4
0
        public void AddNode(int oid, ObjectNode objNode)
        {
            // Create a namebar scene node and entity to handle names
            Axiom.MathLib.Vector3 offset    = new Axiom.MathLib.Vector3(0, 2 * Client.OneMeter, 0);
            SceneNode             sceneNode = objNode.SceneNode.CreateChildSceneNode("namebar." + oid, offset);
            TexturedBillboardSet  widget    = new TexturedBillboardSet("billboard." + oid);

            widget.MaterialName    = "font-material";
            widget.BillboardType   = BillboardType.Point;
            widget.CommonDirection = Axiom.MathLib.Vector3.NegativeUnitZ;
            sceneNode.AttachObject(widget);

            // Set the target mesh for methods like Font.DrawText
            meshRenderer.BeginRender(widget);
            Rect dummyRect = new Rect();

            dummyRect.left   = 0;
            dummyRect.top    = 0;
            dummyRect.Height = 150;
            dummyRect.Width  = 600;
            font.DrawText("This is a test", dummyRect, 0);
            meshRenderer.EndRender();
        }
        public void AddNode(int oid, ObjectNode objNode)
        {
            // Create a namebar scene node and entity to handle names
            Axiom.MathLib.Vector3 offset = new Axiom.MathLib.Vector3(0, 2 * Client.OneMeter, 0);
            SceneNode sceneNode = objNode.SceneNode.CreateChildSceneNode("namebar." + oid, offset);
            TexturedBillboardSet widget = new TexturedBillboardSet("billboard." + oid);
            widget.MaterialName = "font-material";
            widget.BillboardType = BillboardType.Point;
            widget.CommonDirection = Axiom.MathLib.Vector3.NegativeUnitZ;
            sceneNode.AttachObject(widget);

            // Set the target mesh for methods like Font.DrawText
            meshRenderer.BeginRender(widget);
            Rect dummyRect = new Rect();
            dummyRect.left = 0;
            dummyRect.top = 0;
            dummyRect.Height = 150;
            dummyRect.Width = 600;
            font.DrawText("This is a test", dummyRect, 0);
            meshRenderer.EndRender();
        }
예제 #6
0
        /// <summary>
        /// Update the position of the sound source according to changes to the SceneNode and the Position property
        /// </summary>
        public virtual void UpdatePosition()
        {
            // if the position is changed
            if((parentNode != null) && ( (lastnodeposition.x != parentNode.WorldPosition.x || lastnodeposition.y != parentNode.WorldPosition.y || lastnodeposition.z != parentNode.WorldPosition.z) || (this.Position != lastposition)))
            {
                SetPosition(parentNode.WorldPosition + this.Position);
                lastnodeposition = parentNode.WorldPosition;
                lastposition = this.Position;
            }

            // if the orientation is changed
            if((parentNode != null) && ( (parentNode.WorldOrientation.w != lastorientation.w || parentNode.WorldOrientation.x != lastorientation.x || parentNode.WorldOrientation.y != lastorientation.y || parentNode.WorldOrientation.z != lastorientation.z) || (conedirection != lastdirection)))
            {
                SetConeDirection(Quaternion.Multiply(parentNode.WorldOrientation, conedirection));
                lastorientation = parentNode.WorldOrientation;
                lastdirection = conedirection;
            }
        }
        public static SceneNode CreateSceneNode(SceneManager sceneManager, 
												long oid, Vector3 location, Quaternion orientation)
        {
            SceneNode sceneNode = null;
            Monitor.Enter(sceneManager);
            try {
                sceneNode = sceneManager.RootSceneNode.CreateChildSceneNode("object." + oid, location, orientation);
                log.Info("Created sceneNode");
            } finally {
                Monitor.Exit(sceneManager);
            }
            return sceneNode;
        }
 protected void SetLoc(long timestamp, Vector3 loc)
 {
     if (timestamp <= lastLocTimestamp)
         return;
     // timestamp is newer.
     lastLocTimestamp = timestamp;
     // Use the property to set position (which side effects the
     // sounds, namebar, and bubble chat)
     // This will be applied on the next tick
     Vector3 newLoc = worldManager.ResolveLocation(this, loc);
     log.DebugFormat("loc for node {0} = newLoc {1} oldLoc {2}", this.Oid, newLoc, this.Position);
     Vector3 displacement = newLoc - this.Position;
     this.Position = newLoc;
     if (collider != null)
         collider.AddDisplacement(displacement);
 }
 /// <summary>
 ///   Sets up the data needed for interpolated movement of an object.
 ///   In this case, it is the direction, location, and timestamp when 
 ///   that location was the current location.
 /// </summary>
 /// <param name="timestamp">time that the message was created (in client time)</param>
 /// <param name="dir">direction of motion of the object</param>
 /// <param name="loc">initial location of the object (at the time the message was created)</param>
 public virtual void SetDirLoc(long timestamp, Vector3 dir, Vector3 pos)
 {
     SetLoc(timestamp, pos);
 }
예제 #10
0
 // Used for attaching internal attachments
 public Node AttachScriptObject(string slotName, MovableObject sceneObj, Quaternion orientation, Vector3 offset)
 {
     long objectId = worldManager.GetLocalOid();
     scriptAttachments[sceneObj] = objectId;
     return AttachObject(slotName, objectId, sceneObj, orientation, offset);
 }
예제 #11
0
 public Node AttachObject(AttachmentPoint attachPoint, long objectId,  MovableObject sceneObj, Quaternion orientation, Vector3 offset)
 {
     Node attachNode;
     Quaternion derivedOrientation = attachPoint.Orientation * orientation;
     Vector3 derivedOffset = (attachPoint.Orientation * offset) + attachPoint.Position;
     if (attachPoint.ParentBone != null) {
         attachNode = this.Entity.AttachObjectToBone(attachPoint.ParentBone, sceneObj, derivedOrientation, derivedOffset);
     } else {
         string attachNodeName = string.Format("attachment.{0}.{1}", attachPoint.Name, objectId);
         SceneNode attachedSceneNode = sceneNode.Creator.CreateSceneNode(attachNodeName);
         attachedSceneNode.Orientation = derivedOrientation;
         attachedSceneNode.Position = derivedOffset;
         sceneNode.AddChild(attachedSceneNode);
         attachedSceneNode.AttachObject(sceneObj);
         attachNode = attachedSceneNode;
     }
     attachments[objectId] = attachNode;
     attachedObjects[objectId] = sceneObj;
     return attachNode;
 }
예제 #12
0
 public Node AttachObject(string slotName, long objectId, MovableObject sceneObj, Quaternion orientation, Vector3 offset)
 {
     log.InfoFormat("Attaching to {0} on {1}", slotName, this.Name);
     AttachmentPoint socket = null;
     if (attachmentPoints.ContainsKey(slotName))
         socket = attachmentPoints[slotName];
     else
         socket = new AttachmentPoint(slotName, null, Quaternion.Identity, Vector3.Zero);
     return AttachObject(socket, objectId, sceneObj, orientation, offset);
 }
예제 #13
0
        public void HandleUpdate(AgentUpdatePacket pack)
        {
            if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0)
            {
                if (this._physActor.Flying == false)
                {
                    this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_FLY"];
                    this.anim_seq = 1;
                    this.SendAnimPack();
                }
                this._physActor.Flying = true;

            }
            else
            {
                if (this._physActor.Flying == true)
                {
                    this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
                    this.anim_seq = 1;
                    this.SendAnimPack();
                }
                this._physActor.Flying = false;
            }
            if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
            {
                Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
                if (((movementflag & 1) == 0) || (q != this.bodyRot))
                {

                    if (((movementflag & 1) == 0) && (!this._physActor.Flying))
                    {
                        this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_WALK"];
                        this.anim_seq = 1;
                        this.SendAnimPack();
                    }

                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity = new NewForce();
                    Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
                    Axiom.MathLib.Vector3 direc = q * v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc = direc * ((0.03f) * 128f);
                    if (this._physActor.Flying)
                        direc *= 2;

                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 1;
                    this.bodyRot = q;
                }
            }
            else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying))
            {
                if (((movementflag & 2) == 0) && this._physActor.Flying)
                {
                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity = new NewForce();
                    Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
                    Axiom.MathLib.Vector3 direc = v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc = direc * ((0.03f) * 128f * 2);
                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 2;
                }
            }
            else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying))
            {
                if (((movementflag & 4) == 0) && this._physActor.Flying)
                {
                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity = new NewForce();
                    Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
                    //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
                    Axiom.MathLib.Vector3 direc = v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc = direc * ((0.03f) * 128f * 2);
                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 4;
                }
            }
            else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
            {
                Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
                if (((movementflag & 8) == 0) || (q != this.bodyRot))
                {
                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity = new NewForce();
                    Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
                    Axiom.MathLib.Vector3 direc = q * v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc = direc * ((0.03f) * 128f);
                    if (this._physActor.Flying)
                        direc *= 2;

                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 8;
                    this.bodyRot = q;
                }
            }
            else
            {
                if (movementflag == 16)
                {
                    movementflag = 0;
                }
                if ((movementflag) != 0)
                {
                    NewForce newVelocity = new NewForce();
                    newVelocity.X = 0;
                    newVelocity.Y = 0;
                    newVelocity.Z = 0;
                    this.forcesList.Add(newVelocity);
                    movementflag = 0;
                    // We're standing still, so make it show!
                    if (this._physActor.Flying == false)
                    {
                        this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
                        this.anim_seq = 1;
                        this.SendAnimPack();
                    }
                    this.movementflag = 16;

                }
            }
        }
예제 #14
0
        public void HandleUpdate(AgentUpdatePacket pack)
        {
            if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0)
            {
                if (this._physActor.Flying == false)
                {
                    this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_FLY"];
                    this.anim_seq     = 1;
                    this.SendAnimPack();
                }
                this._physActor.Flying = true;
            }
            else
            {
                if (this._physActor.Flying == true)
                {
                    this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
                    this.anim_seq     = 1;
                    this.SendAnimPack();
                }
                this._physActor.Flying = false;
            }
            if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
            {
                Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
                if (((movementflag & 1) == 0) || (q != this.bodyRot))
                {
                    if (((movementflag & 1) == 0) && (!this._physActor.Flying))
                    {
                        this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_WALK"];
                        this.anim_seq     = 1;
                        this.SendAnimPack();
                    }


                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity        = new NewForce();
                    Axiom.MathLib.Vector3 v3    = new Axiom.MathLib.Vector3(1, 0, 0);
                    Axiom.MathLib.Vector3 direc = q * v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc = direc * ((0.03f) * 128f);
                    if (this._physActor.Flying)
                    {
                        direc *= 2;
                    }

                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 1;
                    this.bodyRot = q;
                }
            }
            else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying))
            {
                if (((movementflag & 2) == 0) && this._physActor.Flying)
                {
                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity        = new NewForce();
                    Axiom.MathLib.Vector3 v3    = new Axiom.MathLib.Vector3(0, 0, 1);
                    Axiom.MathLib.Vector3 direc = v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc         = direc * ((0.03f) * 128f * 2);
                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 2;
                }
            }
            else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying))
            {
                if (((movementflag & 4) == 0) && this._physActor.Flying)
                {
                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity     = new NewForce();
                    Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
                    //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
                    Axiom.MathLib.Vector3 direc = v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc         = direc * ((0.03f) * 128f * 2);
                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 4;
                }
            }
            else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
            {
                Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
                if (((movementflag & 8) == 0) || (q != this.bodyRot))
                {
                    //we should add a new force to the list
                    // but for now we will deal with velocities
                    NewForce newVelocity        = new NewForce();
                    Axiom.MathLib.Vector3 v3    = new Axiom.MathLib.Vector3(-1, 0, 0);
                    Axiom.MathLib.Vector3 direc = q * v3;
                    direc.Normalize();

                    //work out velocity for sim physics system
                    direc = direc * ((0.03f) * 128f);
                    if (this._physActor.Flying)
                    {
                        direc *= 2;
                    }

                    newVelocity.X = direc.x;
                    newVelocity.Y = direc.y;
                    newVelocity.Z = direc.z;
                    this.forcesList.Add(newVelocity);
                    movementflag = 8;
                    this.bodyRot = q;
                }
            }
            else
            {
                if (movementflag == 16)
                {
                    movementflag = 0;
                }
                if ((movementflag) != 0)
                {
                    NewForce newVelocity = new NewForce();
                    newVelocity.X = 0;
                    newVelocity.Y = 0;
                    newVelocity.Z = 0;
                    this.forcesList.Add(newVelocity);
                    movementflag = 0;
                    // We're standing still, so make it show!
                    if (this._physActor.Flying == false)
                    {
                        this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
                        this.anim_seq     = 1;
                        this.SendAnimPack();
                    }
                    this.movementflag = 16;
                }
            }
        }
 public Vector3Value(Vector3 val):
     base((object)val)
 {
 }
예제 #16
0
        /// <summary>
        ///   Lock on the name dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange        = 40 * Client.OneMeter;
            const float MinFadeRange        = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            ColorEx[] SelectedColors = new ColorEx[4];
            SelectedColors[0] = new ColorEx(1, 0, 1.0f, 1.0f);
            SelectedColors[1] = new ColorEx(1, 0, 0.9f, 0.9f);
            SelectedColors[2] = new ColorEx(1, 0, 0.8f, 0.8f);
            SelectedColors[3] = new ColorEx(1, 0, 0.7f, 0.7f);

            ColorEx StandardColor = new ColorEx(1, 0, 0.9f, 0.9f);

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            if (!IsTargeted(widgetNode.Oid))
            {
                // Don't show if they are too far away or if they are the player,
                // unless they are selected
                if (widgetNode.Oid == client.PlayerId || ray.LengthSquared > MaxFadeRangeSquared)
                {
                    widgetNode.Visible = false;
                    return;
                }
            }

            // Put the name widget about one foot above the mob's head
            if (!SetWidgetPosition(widgetNode, Vector3.Zero))
            {
                // if (!SetWidgetPosition(widgetNode, new Vector3(0, 0.3f * Client.OneMeter, 0)))
                return;
            }

            if (ray.LengthSquared < MinFadeRangeSquared || IsTargeted(widgetNode.Oid))
            {
                widgetNode.Widget.Alpha = 1.0f;
            }
            else
            {
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            }
#if OLD_CODE
            ZOrderedStaticText textWidget = (ZOrderedStaticText)widgetNode.Widget;
            if (IsTargeted(widgetNode.Oid))
            {
                const int Period = 500;
                // Blink the name with a 500ms period.
                float tmp = now % Period;
                tmp /= Period;
                int i = (int)Math.Min(3, 4 * Math.Sin(Math.PI * tmp));
                textWidget.SetTextColor(SelectedColors[i]);
            }
            else
            {
                textWidget.SetTextColor(StandardColor);
            }
#endif
            if (this.Visible)
            {
                widgetNode.Visible = true;
            }
        }