bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position) { if (dragData.Object == null) { return(false); } Mogre.Ray mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y); EntityEditor entity = dragData.Object as EntityEditor; bool hitFound = false; if (!hitFound) { if (entity.Position.x == 999999 && entity.Position.y == 999999 && entity.Position.z == 999999) { entity.Position = mouseRay.Origin + mouseRay.Direction * 40.0f; } else { entity.Position = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(entity, mouseRay); } } return(true); }
void MogitorsRoot.IDragDropHandler.OnDragWheel(DragData dragData, Mogre.Viewport vp, float delta) { if (dragData.Object == null) { return; } Mogre.Vector3 vPos = Mogre.Vector3.ZERO; PropertyInfo prop = dragData.Object.GetType().GetProperty("Position"); if (prop != null) { vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null); } float distance = (vPos - vp.Camera.DerivedPosition).Length + (delta / 120.0f); if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999) { return; } else { vPos = vp.Camera.DerivedPosition + ((vPos - vp.Camera.DerivedPosition).NormalisedCopy * distance); } prop.SetValue(dragData.ObjectType, vPos, null); }
void MogitorsRoot.IDragDropHandler.OnDragDrop(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position) { if (dragData.Object != null) { Mogre.NameValuePairList parameters = new Mogre.NameValuePairList(); dragData.Object.GetObjectProperties(parameters); dragData.Object.Destroy(false); dragData.Object = null; dragData.Parameters["Position"] = parameters["Position"]; MogitorsRoot.Instance.CreateEditorObject(null, dragData.ObjectType, dragData.Parameters, true, true); } dragData.Parameters.Clear(); dragData.ObjectType = ""; dragData.Object = null; }
bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position) { if (dragData.ObjectType == "") { return(false); } if (dragData.Object == null) { return(true); } Mogre.Ray mouseRay; mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y); Mogre.Vector3 vPos = Mogre.Vector3.ZERO; PropertyInfo prop = dragData.Object.GetType().GetProperty("Position"); if (prop != null) { vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null); } if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999) { vPos = mouseRay.Origin + (mouseRay.Direction * 40.0f); } else { vPos = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(dragData.Object, mouseRay); } if (prop != null) { prop.SetValue(dragData.Object, vPos, null); } return(true); }
void MogitorsRoot.IDragDropHandler.OnDragWheel(DragData dragData, Mogre.Viewport vp, float delta) { if (dragData.Object == null) { return; } EntityEditor entity = dragData.Object as EntityEditor; Mogre.Vector3 vPos = entity.Position; float distance = (vPos - vp.Camera.DerivedPosition).Length + (delta / 120.0f); if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999) { return; } else { vPos = vp.Camera.DerivedPosition + ((vPos - vp.Camera.DerivedPosition).NormalisedCopy * distance); } entity.Position = vPos; }
public Core() { m_config = 0; //!config m_stateManager = 0; m_root = null; m_renderWnd = null; m_viewport = null; m_log = null; m_timer = null; m_inputMgr = null; m_keyboard = null; m_mouse = null; m_update = 1.0f / 120; m_elapsed = 0.0f; /* for (int i = 0; i < 256; ++i) m_keyStates[i] = false; */ }
/// <summary> /// Sets camera and sets the viewport to camera. /// </summary> protected override void CreateViewports() { Mogre.Viewport viewport = mWindow.AddViewport(mCamera); viewport.BackgroundColour = new Mogre.ColourValue(0.1f, 0.1f, 0.1f); mCamera.AspectRatio = (float)viewport.ActualWidth / viewport.ActualHeight; }
private void SetupViewport() { m_viewport = m_renderWnd.AddViewport( null ); m_viewport.BackgroundColour = new Mogre.ColourValue(0.5f, 0.5f, 0.5f, 1.0f); }
private void CreateImages(ObservableCollection <IconTextItem> retlist, bool skipCached) { retlist.Clear(); Mogre.TexturePtr texture = Mogre.TextureManager.Singleton.CreateManual("EntityTex", Mogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, Mogre.TextureType.TEX_TYPE_2D, 256, 256, 0, Mogre.PixelFormat.PF_A8R8G8B8, (int)Mogre.TextureUsage.TU_RENDERTARGET); Mogre.RenderTexture rttTex = texture.GetBuffer().GetRenderTarget(); Mogre.SceneManager sceneMgr = Mogre.Root.Singleton.CreateSceneManager("OctreeSceneManager", "EntityTexMgr"); Mogre.Light dir1 = sceneMgr.CreateLight("DisplayLight"); dir1.SetDirection(-1, -1, -1); dir1.SetDiffuseColour(1, 1, 1); dir1.Type = Mogre.Light.LightTypes.LT_DIRECTIONAL; Mogre.Camera RTTCam = sceneMgr.CreateCamera("EntityCam"); RTTCam.NearClipDistance = 0.01F; RTTCam.FarClipDistance = 0; RTTCam.AspectRatio = 1; RTTCam.FOVy = new Mogre.Radian(new Mogre.Degree(90)); RTTCam.Position = new Mogre.Vector3(0, 0, 1); RTTCam.LookAt(0, 0, 0); Mogre.Viewport v = rttTex.AddViewport(RTTCam); v.SetClearEveryFrame(true); v.BackgroundColour = new Mogre.ColourValue(0, 0, 0, 0); Mogre.StringVector list = Mogre.ResourceGroupManager.Singleton.FindResourceNames("ProjectResources", "*.mesh", false); IDictionary <string, string> entities = new Dictionary <string, string>(list.Count); foreach (string addstr in list) { if (entities.Values.Contains(addstr) == false) { entities.Add(addstr, addstr); } } foreach (KeyValuePair <string, string> ite in entities) { string addstr = ite.Key; string addstrFile = MogitorsSystem.Instance.CombinePath(MogitorsRoot.Instance.ProjectOptions.ProjectDir, addstr + ".png"); if (!skipCached || !System.IO.File.Exists(addstrFile)) { Mogre.Entity entity = sceneMgr.CreateEntity("scbDisplay", addstr); sceneMgr.RootSceneNode.AttachObject(entity); Mogre.Vector3 vSize = entity.BoundingBox.HalfSize; Mogre.Vector3 vCenter = entity.BoundingBox.Center; vSize += new Mogre.Vector3(vSize.z, vSize.z, vSize.z); float maxsize = Math.Max(Math.Max(vSize.x, vSize.y), vSize.z); vSize = new Mogre.Vector3(0, 0, maxsize * 1.1f) + vCenter; RTTCam.SetPosition(vSize.x, vSize.y, vSize.z); RTTCam.LookAt(vCenter.x, vCenter.y, vCenter.z); rttTex.Update(); rttTex.WriteContentsToFile(addstrFile); entity.ParentSceneNode.DetachObject(entity); sceneMgr.DestroyEntity(entity); } retlist.Add(new IconTextItem(addstr.Remove(addstr.Length - 5, 5), addstrFile)); } rttTex.RemoveAllViewports(); Mogre.Root.Singleton.DestroySceneManager(sceneMgr); Mogre.Root.Singleton.DetachRenderTarget(rttTex.Name); Mogre.TextureManager.Singleton.Unload(texture.Name); Mogre.TextureManager.Singleton.Remove(texture.Name); list = null; }