Esempio n. 1
0
 //this waits for the server to respond before actually moving the object.
 //another strategy might be to move the object, then correct
 private void Network_PositionChangeHandler(object sender, Massive.Events.MoveEvent e)
 {
     //throw new NotImplementedException();
     if (!e.InstanceID.Equals(Globals.UserAccount.UserID))
     {
         MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(e.InstanceID);
         if (mo != null)
         {
             //movesync smoothly moves an object into position
             MMoveSync ms = (MMoveSync)mo.FindModuleByType(MObject.EType.MoveSync);
             if (ms == null)
             {
                 ms = new MMoveSync(mo, e.Position, e.Rotation);
                 mo.Add(ms);
             }
             else
             {
                 ms.SetTarget(e.Position, e.Rotation);
             }
         }
     }
     else
     {
         MMessageBus.AvatarMoved(this, e.InstanceID, e.Position, e.Rotation);
     }
     //Console.WriteLine(e.Position);
 }
Esempio n. 2
0
        void Go()
        {
            string sText = SiteBox.Text;

            if (string.IsNullOrEmpty(sText))
            {
                return;
            }
            sText        = sText.Trim();
            SiteBox.Text = sText;
            Vector3d dest = Decoder.Decode(sText);

            if (Globals.Network.Connected == true)
            {
                MMessageBus.TeleportRequest(this, dest, Globals.LocalUpRotation());
            }
            else
            {
                MScene.Camera.transform.Position    = dest;
                Globals.UserAccount.CurrentPosition = MassiveTools.ArrayFromVector(dest);
                Globals.Avatar.SetPosition(dest);
                MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID, dest, Quaterniond.Identity);
            }
            MMessageBus.Navigate(this, dest);
        }
Esempio n. 3
0
 private void GotoMapPointButton_Click(object sender, EventArgs e)
 {
     if (Globals.Network.Connected == true)
     {
         MMessageBus.TeleportRequest(this, WorldLocationPoint, Quaterniond.Identity);
     }
     else
     {
         Globals.Avatar.SetPosition(WorldLocationPoint);
         MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID, WorldLocationPoint, Quaterniond.Identity);
     }
 }
Esempio n. 4
0
        private void HomeButton_Click(object sender, EventArgs e)
        {
            MServerZone zone = MZoneService.Find("Earth");
            //Vector3d pos = MassiveTools.Vector3dFromVector3_Server(zone.Position);

            //cape town
            Vector3d pos = MassiveTools.VectorFromArray(Globals.UserAccount.HomePosition);

            if (Globals.Network.Connected == true)
            {
                MMessageBus.TeleportRequest(Globals.UserAccount.UserID, pos, Quaterniond.Identity);
            }
            else
            {
                MScene.Camera.transform.Position    = pos;
                Globals.UserAccount.CurrentPosition = MassiveTools.ArrayFromVector(pos);
                Globals.Avatar.SetPosition(pos);
                MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID, pos, Quaterniond.Identity);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// If we have moved greated than 1m from our last position, inform the network
        /// TODO: move to avatar handler
        /// </summary>
        /// <param name="AP"></param>
        void CheckNetworkUpdating(Vector3d AP)
        {
            double dist = Vector3d.Distance(PreviousPosition, MScene.Camera.transform.Position);
            double td   = Math.Abs(Vector3d.Distance(PreviousTarget, MScene.Camera.Focus.transform.Position));

            if (((dist > 0.25) || (td > 1)) &&
                (Throttle > MaxNetworkThrottle))
            {
                Throttle         = 0;
                PreviousPosition = MScene.Camera.transform.Position;
                PreviousTarget   = MScene.Camera.Focus.transform.Position;
                if (Globals.Network.Connected == true)
                {
                    MMessageBus.MoveAvatarRequest(this, Globals.UserAccount.UserID, AP, Globals.Avatar.GetRotation());
                }
                else
                {
                    //TODO: follow this event down the rabbit hole and optimize out where possible
                    MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID, AP, Globals.Avatar.GetRotation());
                    //Console.WriteLine("Avatar " + Globals.Avatar.GetRotation());
                }
            }
        }
Esempio n. 6
0
        private void But_Click(object sender, EventArgs e)
        {
            Button    b  = (Button)sender;
            MBookmark bm = (MBookmark)b.Tag;

            if (bm != null)
            {
                if (Globals.Network.Connected == true)
                {
                    MMessageBus.TeleportRequest(this,
                                                MassiveTools.VectorFromArray(bm.Position),
                                                MassiveTools.QuaternionFromArray(bm.Rotation));
                }
                else
                {
                    MScene.Camera.transform.Position    = MassiveTools.VectorFromArray(bm.Position);
                    Globals.UserAccount.CurrentPosition = bm.Position;
                    Globals.Avatar.SetPosition(MScene.Camera.transform.Position);
                    MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID,
                                            MScene.Camera.transform.Position,
                                            MassiveTools.QuaternionFromArray(bm.Rotation));
                }
            }
        }
Esempio n. 7
0
 private void TimeOfDay_Scroll(object sender, EventArgs e)
 {
     MClimate.SetTimeOfDay(TimeOfDay.Value);
     MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID, Globals.Avatar.GetPosition(), Globals.Avatar.GetRotation());
 }