private void ModeButton_Click(object sender, EventArgs e) { if (Globals.Avatar.GetMoveMode() == MAvatar.eMoveMode.Flying) { MMessageBus.ChangeModeRequest(this, Massive.MAvatar.eMoveMode.Walking); MMessageBus.GravityStateChanged(this, new BooleanEvent(true)); } else { MMessageBus.ChangeModeRequest(this, Massive.MAvatar.eMoveMode.Flying); MMessageBus.GravityStateChanged(this, new BooleanEvent(false)); } }
private void AssetsView_SelectionChanged(object sender, EventArgs e) { //DataGridViewSelectedRowCollection col = AssetsView.SelectedRows; DataGridViewSelectedCellCollection col = AssetsView.SelectedCells; if (col.Count > 0) { MSceneObject mo = (MSceneObject)col[0].OwningRow.DataBoundItem; MMessageBus.Navigate(this, mo.transform.Position); MMessageBus.Select(this, new SelectEvent(mo)); } }
private void Navigate_Click(object sender, EventArgs e) { double height = 0; if (MPlanetHandler.CurrentNear != null) { height = MPlanetHandler.CurrentNear.DistanceToAvatar; } Vector3d LatLon = GetLonLatInMeters(height); MMessageBus.Navigate(this, LatLon); }
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)); } } }
public static void Mc_DoubleClick(MObject mo) { string sTag = (string)mo.Tag; string[] parms = sTag.Split('|'); if (parms.Length > 0) { NavigationBarDecoder dec = new NavigationBarDecoder(); Vector3d v = dec.Decode(parms[1]); MMessageBus.Status(mo, "Teleporting to:" + parms[1] + " - " + parms[2]); MMessageBus.TeleportRequest(mo, v, Quaterniond.Identity); } }
void Add(MBuildingBlock bb) { LastBuild = bb; if (MStateMachine.ZoneLocked == true) { MMessageBus.Error(this, "Can't build here, zone is locked / other building nearby"); return; } Vector3d pos = Globals.Avatar.GetPosition(); if (bb.TemplateID.Equals(MBuildParts.FOUNDATION01)) { pos += Globals.Avatar.Forward() * 13 - Globals.Avatar.Up() * 1.0; } else { pos += Globals.Avatar.Forward() * 4 + Globals.Avatar.Up() * 3.0; } Quaterniond rot = Globals.LocalUpRotation(); if (SelectedItem != null) { rot = SelectedItem.transform.Rotation; //prevent smaller items getting lost in the foundation if (SelectedItem.TemplateID != MBuildParts.FOUNDATION01) { //pos = SelectedItem.transform.Position; } } if (Globals.Network.Connected == true) { Globals.Network.SpawnRequest(bb.TemplateID, "TEXTURE01", bb.TemplateID, bb.TemplateID, pos, rot); } else { MServerObject mso = new MServerObject(); mso.InstanceID = Helper.GUID(); mso.OwnerID = Globals.UserAccount.UserID; mso.TextureID = bb.TextureID; mso.TemplateID = bb.TemplateID; mso.Position = MassiveTools.ArrayFromVector(pos); mso.Rotation = MassiveTools.ArrayFromQuaterniond(rot); MMessageBus.CreateObjectRequest(this, mso); } }
/// <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)); } }
private void UploadTexture_Click(object sender, EventArgs e) { if (SelectedItem == null) { return; } ImageUploader iu = new ImageUploader(); //iu.Show(TopLevelControl); iu.sTargetID = SelectedItem.InstanceID; if (iu.ShowDialog() == DialogResult.OK) { //sLocus now contains the URL of the uploaded image MMessageBus.ChangeTextureRequest(this, SelectedItem.InstanceID, iu.sPublicFile); } }
private void TestButton_Click(object sender, EventArgs e) { if (Target == null) { return; } try { Process.Start((string)Target.Tag); } catch (Exception ee) { Console.WriteLine(ee.Message); MMessageBus.Error(this, ee.Message); } }
private void Bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (Vertices == null) { return; } //Globals.GUIThreadOwner.Invoke((MethodInvoker)delegate // { int MSize = TexturedVertex.Size; GL.GenVertexArrays(1, out VAO); GL.GenBuffers(1, out VBO); GL.GenBuffers(1, out EBO); GL.BindVertexArray(VAO); GL.BindBuffer(BufferTarget.ArrayBuffer, VBO); GL.BufferData(BufferTarget.ArrayBuffer, Vertices.Length * MSize, Vertices, BufferUsageHint.DynamicDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, EBO); GL.BufferData(BufferTarget.ElementArrayBuffer, Indices.Length * sizeof(int), Indices, BufferUsageHint.StaticDraw); // vertex positions GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, MSize, 0); // vertex normals GL.EnableVertexAttribArray(1); GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, MSize, sizeof(float) * 3); // vertex texture coords GL.EnableVertexAttribArray(2); GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, MSize, sizeof(float) * 6); // }); _backgroundWorker.Dispose(); _backgroundWorker = null; VerticesLength = Vertices.Length; IndicesLength = Indices.Length; //Indices = null; // Vertices = null; IsSetup = true; if (Settings.TerrainPhysics == true) { MMessageBus.LoadingStatus(this, "Preparing:" + TileX + "," + TileY); SetupPhysics(); //must run on main thread } }
public void Update() { if (MStateMachine.CurrentState == MStateMachine.eStates.Splash) { MMessageBus.GravityStateChanged(this, new BooleanEvent(false)); CheckSetupStarted(); } if (MStateMachine.CurrentState == MStateMachine.eStates.Setup) { CheckSetupComplete(); } Globals._scene.Update(); _lightHandler.Update(); _cameraHandler.Update(); }
public void HandleKey(KeyEventArgs e) { switch (e.KeyCode) { case Keys.ShiftKey: ShiftDown = true; break; case Keys.Add: MMessageBus.Rotate(this, new Quaterniond(0, 45 * Math.PI / 180.0, 0)); break; case Keys.Subtract: MMessageBus.Rotate(this, new Quaterniond(0, -45 * Math.PI / 180.0, 0)); break; } }
public static void Mc_DoubleClick(MObject mo) { if (string.IsNullOrEmpty((string)mo.Tag)) { return; } MMessageBus.Status(null, "Opening:" + mo.Tag); try { Process.Start((string)mo.Tag); } catch (Exception ee) { Console.WriteLine(ee.Message); MMessageBus.Error(mo, ee.Message); } }
public static void SetTimeOfDay(double _time) { time = _time; MAstroBody Sol = MPlanetHandler.Get("Sol"); Quaterniond q = Quaterniond.FromEulerAngles(0, (15 * time) * Math.PI / 180.0, 0); MSceneObject mo = (MSceneObject)MScene.AstroRoot.FindModuleByName("Sol"); mo.SetPosition(q * new Vector3d(Sol.DistanceToAvatar, 0, 0)); MMessageBus.Navigate(null, mo.transform.Position); double ottime = (time + timeOffset) % 24; float f24 = (float)Math.Sin((ottime * 15.0) * Math.PI / 180.0); //f24 = Math.Min((float)Math.Pow(f24, 0.2), 1); f24 = Math.Max(f24, 0.02f); MScene.light.Ambient = new Vector3(f24, f24, f24); }
private void Client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e) { progressBar1.Visible = false; if (e.Error != null) { Globals.Log(this, e.Error.Message); Status(e.Error.Message); Console.WriteLine(e.Error.Message); return; } string s = System.Text.Encoding.UTF8.GetString(e.Result, 0, e.Result.Length); //Console.WriteLine(s); Status("Upload Complete"); sPublicFile = s.Replace("{HOST}", Globals.Network.ServerIP); Globals.Network.ChangePropertyRequest(Target.InstanceID, Description); MMessageBus.ChangeTextureRequest(this, Target.InstanceID, sPublicFile); }
private void MapBox_MouseClick(object sender, MouseEventArgs e) { WorldLocationPoint = MapTo3D(e.X, e.Y); ClickPoint = e.Location; MMessageBus.Navigate(this, WorldLocationPoint); Console.WriteLine("Validate"); if (bmp == null) { return; } Bitmap bmp2 = new Bitmap(bmp); Pen RedPen = new Pen(Color.Red); RedPen.Width = 2; Graphics g = Graphics.FromImage(bmp2); float posx = (float)ClickPoint.X / (float)MapBox.Width * (float)bmp.Width; float posy = (float)ClickPoint.Y / (float)MapBox.Height * (float)bmp.Height; Rectangle rec = new Rectangle((int)posx - 7, (int)posy - 7, 15, 15); g.DrawRectangle(RedPen, rec); RedPen.Dispose(); g.Dispose(); MapBox.BackgroundImage = bmp2; Invalidate(new Rectangle(ClickPoint.X - 2, ClickPoint.Y - 2, 5, 5)); Vector3d Pos3d = MapTo3D(e.X, MapBox.Height - e.Y); Vector3d uv = CurrentBody.GetUVPointOnSphere(Pos3d); Vector3d lonlat = CurrentBody.GetLonLatOnShere(Pos3d); Vector3d tile = CurrentBody.GetTileFromPoint(Pos3d); WorldLocationPoint = CurrentBody.LonLatToUniPosition(lonlat.X, lonlat.Y, 0); MTerrainBoundary tb = CurrentBody.GetTileBoundaryLonLat((int)tile.X, (int)tile.Y, (int)tile.Z); WorldLocationPoint = Pos3d; WorldCoords.Text = " pos:" + Pos3d.ToString() + "\r\n" // + " uv:" + uv.ToString() + "\r\n" + " lonlat:" + lonlat.ToString() + "\r\n" + " Tile: " + tile.ToString() + "\r\n" // + " Bounds: " + tb.ToString() + "\r\n" // + " Round Trip: " + WorldLocationPoint.ToString() ; }
void SetupDatagrid(DataTable dt) { dataGridView1.DataSource = dt; if (dataGridView1.Columns.Count == 0) { MMessageBus.Error(this, "LobbyForm:Problem loading lobby"); return; } dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending); dataGridView1.Columns[1].Visible = false; DataGridViewRow dg = dataGridView1.Rows[0]; if (dg == null) { return; } ServerIPBox.Text = dg.Cells[1].Value.ToString(); }
public void GetLobbyList() { WebClient wc = new WebClient(); try { string sResponse = wc.DownloadString(Globals.LobbyDataURL); Console.WriteLine(sResponse); ParseJSON(sResponse); } catch (Exception ex) { Console.WriteLine(ex.Message); } DataTable dt = DataTableTools.ConvertToDatatable(Entries); TableEvent te = new TableEvent(dt); MMessageBus.LobbyLoaded(this, te); }
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 C_MouseUp(object sender, MouseEventArgs e) { isDown = false; //accx =0; //accy =0; double d = Vector2.Distance(new Vector2(e.Location.X, e.Location.Y), new Vector2(FirstDownPoint.X, FirstDownPoint.Y)); if ((e.Button == MouseButtons.Left) && (d < 3)) { //hide own avatar bool previous = true; //if (Globals.Avatar.Target != null) //{ //previous = Globals.Avatar.Target.Visible; //} CheckPick(e.Location, false); //if (Globals.Avatar.Target != null) //{ //Globals.Avatar.Target.Visible = previous; //} } if ((e.Button == MouseButtons.Right) && (d < 3)) { CheckPick(e.Location, false, true); } if (e.Button == MouseButtons.Right) { MMessageBus.Select(this, null); } //MMessageBus.Click(this, e.Location, e.Button == MouseButtons.Left ? 0 : 1); }
// double c; public override void Update() { if (Playing == false) { return; } //Console.WriteLine(Globals.Tasks); MMessageBus.NotifyEarlyUpdate(this); if (Background.Modules.Count > 0) { Background.Update(); Background2.Update(); } ModelRoot.Update(); UtilityRoot.Update(); // MMessageBus.NotifyUpdate(this); Overlay.Update(); MMessageBus.NotifyLateUpdate(this); }
void MoveSelection(double x, double y, double z) { if (SelectedItem == null) { return; } double mult = MKeyboardHandler.GetMinifier(); // complete any pending transitions MMoveSync ms = (MMoveSync)SelectedItem.FindModuleByType(MObject.EType.MoveSync); if (ms != null) { ms.Complete(); } Vector3d v = SelectedItem.transform.Position + SelectedItem.transform.Right() * x * mult + SelectedItem.transform.Forward() * y * mult + SelectedItem.transform.Up() * z * mult; MMessageBus.MoveRequest(this, SelectedItem.InstanceID, v, SelectedItem.transform.Rotation); }
/// <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()); } } }
void RotateSelection(double x, double y, double z) { if (SelectedItem == null) { return; } double mult = MKeyboardHandler.GetRotationMinifier(); x = MathHelper.DegreesToRadians(x * mult); y = MathHelper.DegreesToRadians(y * mult); z = MathHelper.DegreesToRadians(z * mult); // complete any pending transitions MMoveSync ms = (MMoveSync)SelectedItem.FindModuleByType(MObject.EType.MoveSync); if (ms != null) { ms.Complete(); } Quaterniond rot = SelectedItem.transform.Rotation * Quaterniond.FromEulerAngles(x, y, z); MMessageBus.MoveRequest(this, SelectedItem.InstanceID, SelectedItem.transform.Position, rot); }
public void Setup(MAstroBody body) { string sText = string.Format("Earth\\{0}\\biome\\{1}_{2}.png", ZoomLevel, TileX, TileY); sText = Path.Combine(Settings.TileDataPath, sText); if (!File.Exists(sText)) { return; } CurrentBody = body; if (_backgroundWorker != null) { _backgroundWorker.CancelAsync(); } ; Console.WriteLine("Memory:" + GC.GetTotalMemory(false)); MMessageBus.LoadingStatus(this, "Loading:" + TileX + "," + TileY); _backgroundWorker = new BackgroundWorker(); _backgroundWorker.DoWork += Bw_DoWork; _backgroundWorker.RunWorkerCompleted += Bw_RunWorkerCompleted; _backgroundWorker.WorkerSupportsCancellation = true; _backgroundWorker.RunWorkerAsync(body); }
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 TimeOfDay_Scroll(object sender, EventArgs e) { MClimate.SetTimeOfDay(TimeOfDay.Value); MMessageBus.AvatarMoved(this, Globals.UserAccount.UserID, Globals.Avatar.GetPosition(), Globals.Avatar.GetRotation()); }
private void GravityCheck_CheckedChanged(object sender, EventArgs e) { Settings.Gravity = GravityCheck.Checked; MMessageBus.GravityStateChanged(this, new BooleanEvent(Settings.Gravity)); }
public void InitializePlanets() { //GravityIndicator = Helper.CreateCube(MScene.AstroRoot, "GravitySphere", Vector3d.Zero); //GravityIndicator.transform.Scale = new Vector3d(0.05, 0.1, 0.1); //GravityIndicator.OwnerID = "MasterAstronomer"; //MScene.AstroRoot.Add(GravityIndicator); //GravityIndicator.SetMaterial((MMaterial)MScene.MaterialRoot.FindModuleByName(MMaterial.DEFAULT_MATERIAL)); CreateShaders(); for (int i = 0; i < Bodies.Count; i++) { MAstroBody m = Bodies[i]; //m.Radius = m.Radius * 0.5; if (m.IsTemplate == true) { continue; } m.ListIndex = i; Vector3d pos = m.Position + new Vector3d(-m.Radius.X, 0, 0) * (m.HasRings == true ? 3.0 : 1.1); MServerZone zone = new MServerZone("MASTER_ASTRONOMER", m.Name, "Astronomical", MassiveTools.ToVector3_Server(pos)); zone.Rotation = MassiveTools.ArrayFromQuaterniond(Quaterniond.Identity); zone.Description = m.Description + " \nRadius:" + m.Radius; MMessageBus.AddZone(this, zone); //Extensions.LookAt(m.Position + m.Radius * 2, m.Position), m.Name)); MSceneObject mo; //planet files contain uvs for mercator if (m.HasAtmosphere) { CurrentNear = m; mo = Helper.CreateModel(MScene.AstroRoot, m.Name, @"Models\planets\earth.3ds", Vector3d.Zero); //mo = Helper.CreateSphere(MScene.AstroRoot, 3, "Planet"); //mo.transform.Scale = m.Radius * 1.00055; mo.transform.Scale = m.Radius; } else { mo = Helper.CreateModel(MScene.AstroRoot, m.Name, @"Models\planets\planet_sphere2.3ds", Vector3d.Zero); mo.transform.Scale = m.Radius; } if (m.HasRings) { MModel ring = Helper.CreateModel(MScene.Priority2, m.Name + "_rings", @"Models\planets\planet_rings.3ds", Vector3d.Zero); ring.transform.Position = m.Position; ring.transform.Rotation = Quaterniond.FromEulerAngles(0, 0, 5 * Math.PI / 180); ring.transform.Scale = m.Radius; ring.InstanceID = m.Name; ring.TemplateID = m.Name; ring.DistanceThreshold = m.Radius.X * 12; ring.OwnerID = "MasterAstronomer"; MMaterial ringmat = new MMaterial(m.Name + "_mat"); ringmat.AddShader((MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER)); MTexture ringtex = Globals.TexturePool.GetTexture(@"Textures\Planets\saturn_rings.png"); ringmat.SetDiffuseTexture(ringtex); ring.SetMaterial(ringmat); MPhysicsObject ringpo = new MPhysicsObject(ring, "Physics", 0, MPhysicsObject.EShape.ConcaveMesh, false, m.Radius); ringpo.SetLinearFactor(0, 0, 0); ringpo.SetRestitution(0.5); } mo.transform.Position = m.Position; //mo.transform.Scale = m.Radius * 1.9999; mo.InstanceID = m.Name; mo.TemplateID = m.Name; mo.OwnerID = "MasterAstronomer"; mo.DistanceThreshold = m.Radius.X * 110002; //distance at which it becomes visible //MModel mod = (MModel)mo.FindModuleByType(EType.Model); //mod.DistanceThreshold = mo.DistanceThreshold; //MMesh met = (MMesh)mod.FindModuleByType(EType.Mesh); //if ( met != null ) { //met.DistanceThreshold = mo.DistanceThreshold; //} mo.Tag = m; m.Tag = mo; //now that we have a 3d model, apply some progressive textures (will auto-switch with smooth transition in shader) MMaterial mat = new MMaterial(m.Name + "_mat"); mat.AddShader((MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER)); MTexture tex = Globals.TexturePool.GetTexture(m.TextureName); mat.SetDiffuseTexture(tex); mo.SetMaterial(mat); MTexture tex2 = Globals.TexturePool.GetTexture("Textures\\terrain\\sand01b.jpg"); mat.SetMultiTexture(tex2); MTexture tex3 = Globals.TexturePool.GetTexture("Textures\\terrain\\water.jpg"); mat.SetNormalMap(tex3); double dia = 2.0 * Math.PI * m.Radius.X * 0.0000001; //double dia = 1; mat.Tex2CoordScale = new Vector2((float)dia, (float)dia); mo.SetMaterial(mat); MScene.MaterialRoot.Add(mat); if (m.HasAtmosphere) { if (Settings.DrawTerrains == true) { m.AddDynamicTerrain(); //adds tile based terrain (from e.g. tile service) } //MPhysicsObject po = new MPhysicsObject(mo, "Physics", 0, MPhysicsObject.EShape.ConcaveMesh, //false, m.Radius); MPhysicsObject po = new MPhysicsObject(mo, "Physics", 0, MPhysicsObject.EShape.Sphere, false, m.Radius); //po.SetLinearFactor(0, 0, 0); //po.SetRestitution(0.5); //MSphere moc = Helper.CreateSphere(MScene.AstroRoot, 3, m.Name+ "Clouds", Vector3d.Zero); MModel moc = Helper.CreateModel(MScene.AstroRoot, m.Name + "_clouds", @"Models\planets\clouds.3ds", Vector3d.Zero); moc.CastsShadow = false; moc.transform.Position = m.Position; moc.transform.Scale = m.Radius; moc.DistanceThreshold = m.Radius.X * 3; //moc.transform.Scale = m.Radius*2.1; moc.InstanceID = m.Name; moc.TemplateID = m.Name; moc.OwnerID = "MasterAstronomer"; moc.Tag = m; MMaterial cmat = new MMaterial("CloudMat"); cmat.AddShader((MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER)); cmat.Opacity = 1; cmat.IsSky = 1; // = new MTexture("CloudTex"); MTexture ctex = Globals.TexturePool.GetTexture(CloudTexURL); ctex.Additive = false; cmat.SetDiffuseTexture(ctex); moc.SetMaterial(cmat); MScene.MaterialRoot.Add(cmat); MModel sky = Helper.CreateModel(MScene.AstroRoot, m.Name + "_sky", @"Models\sky.3ds", Vector3d.Zero); sky.CastsShadow = false; sky.transform.Position = m.Position; sky.transform.Scale = m.Radius; //moc.transform.Scale = m.Radius*2.1; sky.InstanceID = m.Name; sky.TemplateID = m.Name; sky.OwnerID = "MasterAstronomer"; sky.Tag = m; sky.SetMaterial(cmat); sky.DistanceThreshold = m.Radius.X * 4; MObjectAnimation ani = new MObjectAnimation(); ani.AngleOffset = Quaterniond.FromEulerAngles(0, 0.002, 0); ani.Speed = 1; sky.Add(ani); sky.SetMaterial(MSkyMaterial); /*MMaterial csky = new MMaterial("Skymat"); * csky.AddShader((MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER)); * csky.Opacity = 0.5; * csky.IsSky = 1; * // = new MTexture("CloudTex"); * MTexture cSkyTex = Globals.TexturePool.GetTexture(OpaqueCloudTexURL); * cSkyTex.Additive = false; * csky.SetDiffuseTexture(cSkyTex); * sky.SetMaterial(csky); * MScene.MaterialRoot.Add(csky); */ /* MSphere water = Helper.CreateSphere(MScene.ModelRoot, 5, "Water"); * water.transform.Position = m.Position; * water.transform.Scale = m.Radius * 2.00; * MMaterial waterman = new MMaterial("Watermat"); * MShader shader = new MShader("watershader"); * shader.Load("ocean_vs.glsl", "ocean_fs.glsl"); * shader.Bind(); * shader.SetInt("diffuseTexture", 0); * shader.SetInt("shadowMap", 1); * waterman.AddShader(shader); * water.SetMaterial(waterman); */ //water.SetMaterial((MMaterial)MScene.MaterialRoot.FindModuleByName(MMaterial.DEFAULT_MATERIAL)); } else { MPhysicsObject po = new MPhysicsObject(mo, "Physics", 0, MPhysicsObject.EShape.Sphere, false, m.Radius * 0.999); po.SetLinearFactor(0, 0, 0); po.SetRestitution(0.5); } m.Setup(); //Console.WriteLine("Created:" + mo.Name + ":" + (mo.transform.Position) + " R:" + m.Radius); } }
private void GoLatLon_Click(object sender, EventArgs e) { Vector3d d = GetLonLatInMeters(); MMessageBus.TeleportRequest(this, d, Quaterniond.Identity); }