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)); } }
/// <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 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); }
void CheckPick(Point p, bool DoubleClick = false, bool RightClick = false) { GL.Enable(EnableCap.DepthTest); GL.ClearColor(Color.Black); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); MScene.ScreenPick.RenderPick(MScene.ModelRoot); //_glcontrol.SwapBuffers(); Vector3d p3d = new Vector3d(p.X, _glcontrol.Height - p.Y, 0); int index = _Scene.GetPick(p3d); //Log("Pick id:" + index + " @" + p.ToString()); if (index != -1) { //Console.WriteLine("Clicked:" + index); MObject mobj = MScene.ModelRoot.FindModuleByIndex(index, null); if (mobj == null) { return; } if (!mobj.Renderable) { return; } MSceneObject mo = (MSceneObject)mobj; if (mo != null) { if ((mo.Type == MObject.EType.Mesh) && (mo.Parent.Renderable)) { mo = (MSceneObject)mo.Parent; } else { return; } //Console.WriteLine("Pick id:" + index + " @" + p.ToString() + " Owner:" + mo.OwnerID); if (mo.OwnerID == null) { MMessageBus.Status(this, "ID: + " + mo.Index + " Object " + mo.Name + " with ID:" + mo.InstanceID + " has no owner"); } else if (!mo.OwnerID.Equals(Globals.UserAccount.UserID)) { MMessageBus.Status(this, "ID:" + mo.Index + " Object " + mo.Name + "," + mo.InstanceID); } // else { mo.OnClick(DoubleClick, RightClick); MMessageBus.Select(this, new SelectEvent(mo)); MMaterial m = (MMaterial)mo.FindModuleByType(EType.Material); MMessageBus.Status(this, "Selected:" + mo.TemplateID + "," + mo.InstanceID); } } MScene.SelectedObject = mo; } else { MScene.SelectedObject = null; } }