public static void CalculateGravityAtAvatar() { //Console.WriteLine("Update"); Vector3d g = GetGravityVector(Globals.Avatar.GetPosition()); if (Globals.Avatar.Target == null) { g = GetGravityVector(MassiveTools.VectorFromArray(Globals.UserAccount.CurrentPosition)); } MPhysics.Instance.SetGravity(g); Globals.LocalUpVector = -g.Normalized(); if (double.IsNaN(Globals.LocalUpVector.X)) { if (Globals.Avatar.Target != null) { Globals.LocalUpVector = Globals.Avatar.Target.transform.Up(); } } if (double.IsNaN(g.X)) { g = new Vector3d(0, -0.8, 0); } Globals.LocalGravity = g; }
private void MMessageBus_ChangeAvatarRequestHandler(object sender, ChangeAvatarEvent e) { MBuildingBlock bb = MBuildParts.GetBlock(e.TemplateID); if (bb == null) { Console.WriteLine("MSpawnHandler: Missing Template:" + e.TemplateID); return; } MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(e.UserID); if (mo != null) { MMessageBus.DeleteRequest(this, mo); } MServerObject m = new MServerObject(); m.InstanceID = e.UserID; m.TemplateID = e.TemplateID; m.OwnerID = e.UserID; m.TextureID = bb.MaterialID; m.Name = Globals.UserAccount.UserName; MScene.Camera.CameraOffset = MassiveTools.VectorFromArray(bb.BoneOffset); m.Position = Globals.UserAccount.CurrentPosition; m.Rotation = MassiveTools.ArrayFromQuaterniond(Globals.Avatar.GetRotation()); Spawn(m); }
void CheckSetupComplete() { if (Globals.Tasks <= 0) { MStateMachine.ChangeState(MStateMachine.eStates.Viewing); MPlanetHandler.GetUpAt(MassiveTools.VectorFromArray((Globals.UserAccount.CurrentPosition))); CreateAvatar(); } }
void CheckSetupComplete() { if (Globals.Tasks <= 0) { MStateMachine.ChangeState(MStateMachine.eStates.Viewing); MPlanetHandler.GetUpAt(MassiveTools.VectorFromArray((Globals.UserAccount.CurrentPosition))); MMessageBus.GravityStateChanged(this, new BooleanEvent(true)); CreateAvatar(); } }
private void setGPSToolStripMenuItem_Click(object sender, EventArgs e) { Button b = (Button)contextMenuStrip1.SourceControl; if (b != null) { MBookmark bm = (MBookmark)b.Tag; if (bm != null) { MMessageBus.Navigate(this, MassiveTools.VectorFromArray(bm.Position)); } } }
/// <summary> /// Prepares an object for inclusion in the scene graph /// If the template does not exist, it is created first /// </summary> /// <param name="m"></param> public void Spawn(MServerObject m) { MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(m.InstanceID); if (mo != null) { return; //if the object already exists, never mind } //check if the object template exists. All user objects must exist as a template first MSceneObject mt = (MSceneObject)MScene.TemplateRoot.FindModuleByName(m.TemplateID); if (mt == null) { LoadTemplate(m.TemplateID); } //if ((m.Name == Globals.UserAccount.UserID) && ( m.OwnerID == Globals.UserAccount.UserID)){ mo = Helper.Spawn(m, MassiveTools.VectorFromArray(m.Position), MassiveTools.QuaternionFromArray(m.Rotation)); if (mo == null) { Console.WriteLine("MSpawnHandler: Template not found:" + m.TemplateID); } else { mo.InstanceID = m.InstanceID; mo.SetRotation(MassiveTools.QuaternionFromArray(m.Rotation)); //If the object spawning is our avatar if (mo.InstanceID == Globals.UserAccount.UserID) { Globals.Avatar.SetSceneObject(mo); MBuildingBlock bb = MBuildParts.GetBlock(mo.TemplateID); MScene.Camera.CameraOffset = MassiveTools.VectorFromArray(bb.BoneOffset); MMessageBus.AvatarChanged(this, Globals.UserAccount.UserID, mo.TemplateID); } SetMaterial(mo, m.TextureID); MMessageBus.Created(this, mo); } if (mo.OwnerID == Globals.UserAccount.UserID) { MMessageBus.Select(this, new SelectEvent(mo)); } }
//2 user logs in, gets a userID, ends up here private void MMessageBus_LoggedIn(object sender, ChangeDetailsEvent e) { ParseCmdLine(); Globals.Network.GetWorld(); //TODO: Use Server-side home position Vector3d Home = MassiveTools.VectorFromArray(Globals.UserAccount.HomePosition); //Globals.UserAccount.HomePosition = MassiveTools.ArrayFromVector(Home); Globals.Network.SpawnRequest(Globals.UserAccount.AvatarID, MTexture.DEFAULT_TEXTURE, Globals.UserAccount.UserID, "TAG", Home, Quaterniond.Identity, Globals.UserAccount.UserID, 0, 10); Globals.Network.ChangeAvatarRequest(Globals.UserAccount.UserID, Globals.UserAccount.AvatarID); //12717655889.4, 146353256822.3, -7581841339.4(18.4096672612293, -33.9328163657347, 0) Globals.Network.TeleportRequest(Globals.UserAccount.UserID, Home, Quaterniond.Identity); }
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); } }
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)); } } }
private void MMessageBus_LoggedIn(object sender, ChangeDetailsEvent e) { NavigationTarget = MassiveTools.VectorFromArray(Globals.UserAccount.HomePosition); }
public static MSceneObject LoadTemplate(string TemplateID) { MBuildingBlock bb = MBuildParts.GetBlock(TemplateID); if (bb == null) { Console.WriteLine("WARNING: MSpawnHandler.LoadTemplate " + TemplateID + " not found in blocks"); return(null); } MSceneObject o = null; if (bb.Type == MBuildParts.MAnimatedModel) { o = Helper.CreateAnimatedModel(MScene.TemplateRoot, TemplateID, bb.Model, Vector3d.Zero); MAnimatedModel man = (MAnimatedModel)o; man.BoneOffset = MassiveTools.VectorFromArray(bb.BoneOffset); } if (bb.Type == MBuildParts.MModel) { o = Helper.CreateModel(MScene.TemplateRoot, TemplateID, bb.Model, Vector3d.Zero); } MMaterial mat = (MMaterial)MScene.MaterialRoot.FindModuleByName(bb.MaterialID); if (mat == null) { Console.WriteLine("MSpawnHandler.LoadTemplate " + bb.MaterialID + " was null"); } o.SetMaterial(mat); Vector3d size = MassiveTools.VectorFromArray(bb.Size); MPhysicsObject.EShape shape = GetShape(bb.PhysicsShape); if (shape != MPhysicsObject.EShape.NULL) { MPhysicsObject mpo = new MPhysicsObject(o, TemplateID + "_physics", bb.Weight, shape, true, size); mpo.SetSleep(5); mpo.SetFriction(0.5); if (shape != MPhysicsObject.EShape.Sphere) { mpo.SetAngularFactor(0.0, 0.0, 0.0); mpo.SetDamping(0.5, 0.5); mpo.SetRestitution(0.5); } else { mpo.SetDamping(0.1, 0.1); mpo.SetRestitution(0.8); } } o.TemplateID = TemplateID; o.InstanceID = TemplateID; o.IsTransparent = bb.IsTransparent; o.transform.RotationOffset = Quaterniond.FromEulerAngles(MassiveTools.VectorFromArray(bb.RotationOffset)); o.Setup(); AddSubmodules(bb, o); return(o); }