public void Initialize(RenderControl window, GxContext context) { mGlobalBuffer = new ConstantBuffer(context); mGlobalParamsBuffer = new ConstantBuffer(context); mGlobalParamsBufferStore = new GlobalParamsBuffer { mapAmbient = new Vector4(0.5f, 0.5f, 0.5f, 1.0f), mapDiffuse = new Vector4(0.25f, 0.5f, 1.0f, 1.0f), fogColor = new Vector4(0.25f, 0.5f, 1.0f, 1.0f), fogParams = new Vector4(500.0f, 900.0f, mMainCamera.FarClip, 0.0f), brushParameters = new Vector4(45.0f, 55.0f, 0.0f, 0.0f), mousePosition = new Vector4(float.MaxValue), eyePosition = Vector4.Zero, brushSettings = new Vector4(0, 1, 0, 0) }; mGlobalParamsBuffer.UpdateData(mGlobalParamsBufferStore); mGlobalBufferStore = new GlobalBuffer { eyePosition = Vector4.Zero, matProj = Matrix.Identity, matView = Matrix.Identity }; mGlobalBuffer.UpdateData(mGlobalBufferStore); Dispatcher = new GraphicsDispatcher(); MapChunkRender.Initialize(context); MapAreaLowRender.Initialize(context); WmoGroupRender.Initialize(context); M2BatchRenderer.Initialize(context); M2ModelRenderer.Initialize(context); StaticAnimationThread.Instance.Initialize(); WmoManager.Initialize(); M2Manager.Initialize(); GraphicsContext = context; SetActiveCamera(mMainCamera); TextureManager.Instance.Initialize(context); MapManager.Initialize(); mMainCamera.ViewChanged += ViewChanged; mMainCamera.ProjectionChanged += ProjectionChanged; ViewChanged(mMainCamera, mMainCamera.View); ProjectionChanged(mMainCamera, mMainCamera.Projection); CamControl = new CameraControl(window); CamControl.PositionChanged += MapManager.UpdatePosition; if (!LeftHandedCamera) { CamControl.InvertY = true; } }
public MpqTerrainManager(TileIdentifier tileId) { var wowRootDir = DBCTool.FindWowDir(); MpqManager = new MpqManager(wowRootDir); TileId = tileId; var entries = GetMapEntries(); MapInfo entry = null; foreach (var item in entries) { if (item.Id != tileId.MapId) { continue; } entry = item; break; } WDTParser.MpqManager = MpqManager; _wdt = WDTParser.Process(entry); _adtManager = new ADTManager(this); _wmoManager = new WMOManager(); _m2Manager = new M2Manager(); _meshManager = new NavMeshManager(); _selectedTriangleManager = new SelectedTriangleManager(_adtManager); }
public void OnFrame() { Dispatcher.ProcessFrame(); CamControl.Update(ActiveCamera, State != AppState.World); EditManager.Instance.UpdateChanges(); // do not move before mCamControl.Update to have the latest view/projection if (State == AppState.World) { UpdateCursorPosition(); UpdateBrushTime(TimeManager.Instance.GetTime()); CheckUpdateGlobalBuffer(); } GraphicsContext.Context.VertexShader.SetConstantBuffer(0, mGlobalBuffer.Native); GraphicsContext.Context.PixelShader.SetConstantBuffer(0, mGlobalBuffer.Native); MapManager.OnFrame(ActiveCamera); if (!HideWMO) { WmoManager.OnFrame(ActiveCamera); } if (!HideM2) { M2Manager.OnFrame(ActiveCamera); } WorldTextManager.OnFrame(ActiveCamera); BoundingBoxDrawManager.OnFrame(); }
public void Shutdown() { TextureManager.Instance.Shutdown(); MapManager.Shutdown(); WmoManager.Shutdown(); StaticAnimationThread.Instance.Shutdown(); M2Manager.Shutdown(); }
private WorldFrame() { HighlightModelsInBrush = true; MapManager = new MapManager(); WmoManager = new WmoManager(); M2Manager = new M2Manager(); mState = AppState.FileSystemInit; }
private WorldFrame() { MapManager = new MapManager(); WmoManager = new WmoManager(); M2Manager = new M2Manager(); WorldTextManager = new WorldTextManager(); BoundingBoxDrawManager = new BoundingBoxDrawManager(); mState = AppState.Idle; // set the settings on creation HighlightModelsInBrush = Properties.Settings.Default.HighlightModelsInBrush; //this.UpdateDrawBrushOnModels = Properties.Settings.Default.UpdateDrawBrushOnModels; // todo: notimplemented! }
private void ViewChanged(Camera camera, Matrix matView) { if (camera != ActiveCamera) { return; } mGlobalBufferStore.matView = matView; mGlobalChanged = true; M2Manager.ViewChanged(); UpdateCursorPosition(true); }
public void OnFrame() { Dispatcher.ProcessFrame(); CamControl.Update(ActiveCamera, State != AppState.World); Editing.EditManager.Instance.UpdateChanges(); // do not move before mCamControl.Update to have the latest view/projection UpdateCursorPosition(); UpdateBrushTime(Utils.TimeManager.Instance.GetTime()); UpdateBuffers(); GraphicsContext.Context.VertexShader.SetConstantBuffer(0, mGlobalBuffer.Native); GraphicsContext.Context.PixelShader.SetConstantBuffer(0, mGlobalParamsBuffer.Native); MapManager.OnFrame(); WmoManager.OnFrame(); M2Manager.OnFrame(); }
private void ProjectionChanged(Camera camera, Matrix matProj) { if (camera != ActiveCamera) { return; } mGlobalBufferStore.matProj = matProj; mGlobalChanged = true; var perspectiveCamera = camera as PerspectiveCamera; if (perspectiveCamera == null) { return; } mGlobalParamsBufferStore.fogParams.Z = perspectiveCamera.FarClip; mGlobalParamsChanged = true; M2Manager.ViewChanged(); }
private void ProjectionChanged(Camera camera, Matrix matProj) { if (camera != ActiveCamera) { return; } var vp = GraphicsContext.Viewport; mGlobalBufferStore.matProj = matProj; mGlobalBufferStore.viewport = new Vector4(vp.Width, vp.Height, vp.MinDepth, vp.MaxDepth); var perspectiveCamera = camera as PerspectiveCamera; if (perspectiveCamera != null) { mGlobalBufferStore.fogParams.Z = perspectiveCamera.FarClip; } mGlobalBufferChanged = true; M2Manager.ViewChanged(); }
private void OnRenderWindowMouseDown(object sender, MouseEventArgs mouseEventArgs) { var pos = mWindow.PointToClient(Cursor.Position); var intersection = new IntersectionParams(ActiveCamera.ViewInverse, ActiveCamera.ProjectionInverse, new Vector2(pos.X, pos.Y)); MapManager.Intersect(intersection); M2Manager.Intersect(intersection); WmoManager.Intersect(intersection); if (mouseEventArgs.Button == MouseButtons.Left) { IModelInstance selected = null; if (intersection.M2Hit) { selected = intersection.M2Instance; } else if (intersection.WmoHit) { selected = intersection.WmoInstance; } if (selected != mSelectedInstance) { if (mSelectedBoundingBox != null) { BoundingBoxDrawManager.RemoveDrawableBox(mSelectedBoundingBox); } mSelectedBoundingBox = null; if (mSelectedInstance != null) { mSelectedInstance.DestroyModelNameplate(); } if (ModelEditManager.Instance.IsCopying && selected != ModelEditManager.Instance.SelectedModel) { selected = ModelEditManager.Instance.SelectedModel; mSelectedBoundingBox = BoundingBoxDrawManager.AddDrawableBox(selected.InstanceCorners); } else if (selected != null && selected.IsSpecial == false) { selected.CreateModelNameplate(); mSelectedBoundingBox = BoundingBoxDrawManager.AddDrawableBox(selected.InstanceCorners); ModelEditManager.Instance.SelectedModel = selected; } else if (selected == null) { ModelEditManager.Instance.SelectedModel = null; } if (EditManager.Instance.CurrentMode != EditMode.Chunk) { mSelectedInstance = selected; ModelSpawnManager.Instance.ClickedInstance = selected as M2RenderInstance; } } } if (OnWorldClicked != null) { OnWorldClicked(intersection, mouseEventArgs); } }
public void Initialize(RenderControl window, GxContext context) { GraphicsContext = context; mWindow = window; context.Resize += (w, h) => OnResize((int)w, (int)h); mGlobalBuffer = new ConstantBuffer(context); mGlobalBuffer = new ConstantBuffer(context); mGlobalBufferStore = new GlobalParamsBuffer { matView = Matrix.Identity, matProj = Matrix.Identity, viewport = Vector4.Zero, ambientLight = new Color4(0.5f, 0.5f, 0.5f, 1.0f), diffuseLight = new Color4(0.25f, 0.5f, 1.0f, 1.0f), fogColor = new Color4(0.25f, 0.5f, 1.0f, 1.0f), fogParams = new Vector4(500.0f, 900.0f, mMainCamera.FarClip, 0.0f), mousePosition = new Vector4(float.MaxValue), eyePosition = Vector4.Zero, brushParams = new Vector4(45.0f, 55.0f, 0.0f, 0.0f) }; mGlobalBuffer.UpdateData(mGlobalBufferStore); Dispatcher = new GraphicsDispatcher(); Dispatcher.AssignToThread(); MapChunkRender.Initialize(context); MapAreaLowRender.Initialize(context); WmoGroupRender.Initialize(context); M2BatchRenderer.Initialize(context); M2SingleRenderer.Initialize(context); M2PortraitRenderer.Initialize(context); WorldText.Initialize(context); BoundingBoxDrawManager.Initialize(); ChunkEditManager.Instance.Initialize(); StaticAnimationThread.Instance.Initialize(); WmoManager.Initialize(); M2Manager.Initialize(); WorldTextManager.Initialize(); SetActiveCamera(mMainCamera); TextureManager.Instance.Initialize(context); MapManager.Initialize(); mMainCamera.ViewChanged += ViewChanged; mMainCamera.ProjectionChanged += ProjectionChanged; OnResize(mWindow.Width, mWindow.Height); ViewChanged(mMainCamera, mMainCamera.View); ProjectionChanged(mMainCamera, mMainCamera.Projection); CamControl = new CameraControl(window); CamControl.PositionChanged += MapManager.UpdatePosition; if (!LeftHandedCamera) { CamControl.InvertY = false; } window.MouseDown += OnRenderWindowMouseDown; }