Ejemplo n.º 1
0
        public bool Initialize(Engine engine)
        {
            this.engine = engine;
            if (!TryOpenMpq(out mpq))
            {
                OnFailedInitialize?.Invoke();
                waitForInitialized.SetResult(false);
                waitForInitialized = new();
                return(false);
            }
            coroutineManager    = new();
            NotificationsCenter = new NotificationsCenter(this);
            TimeManager         = new TimeManager(this);
            ScreenSpaceSelector = new ScreenSpaceSelector(this);
            DbcManager          = new DbcManager(this, databaseClientFileOpener);
            CurrentMap          = DbcManager.MapStore.FirstOrDefault(m => m.Id == 1) ?? Map.Empty;
            TextureManager      = new WoWTextureManager(this);
            MeshManager         = new WoWMeshManager(this);
            MdxManager          = new MdxManager(this);
            WmoManager          = new WmoManager(this);
            ChunkManager        = new ChunkManager(this);
            CameraManager       = new CameraManager(this);
            LightingManager     = new LightingManager(this);
            AreaTriggerManager  = new AreaTriggerManager(this);
            RaycastSystem       = new RaycastSystem(engine);
            ModuleManager       = new ModuleManager(this, gameView); // must be last

            OnInitialized?.Invoke();
            IsInitialized = true;
            waitForInitialized.SetResult(true);
            return(true);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 public void Shutdown()
 {
     TextureManager.Instance.Shutdown();
     MapManager.Shutdown();
     WmoManager.Shutdown();
     StaticAnimationThread.Instance.Shutdown();
     M2Manager.Shutdown();
 }
Ejemplo n.º 5
0
 private WorldFrame()
 {
     HighlightModelsInBrush = true;
     MapManager             = new MapManager();
     WmoManager             = new WmoManager();
     M2Manager = new M2Manager();
     mState    = AppState.FileSystemInit;
 }
Ejemplo n.º 6
0
        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!
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        public bool Initialize()
        {
            var gameFiles = ResolveOrCreate <IGameFiles>();

            if (!gameFiles.Initialize())
            {
                return(false);
            }
            coroutineManager = new();

            dbcManager = ResolveOrCreate <DbcManager>();
            SetMap(1);

            foreach (var store in dbcManager.Stores())
            {
                registry.RegisterInstance(store.Item1, store.Item2);
            }

            notificationsCenter = ResolveOrCreate <NotificationsCenter>();
            timeManager         = ResolveOrCreate <TimeManager>();
            screenSpaceSelector = ResolveOrCreate <ScreenSpaceSelector>();
            loadingManager      = ResolveOrCreate <LoadingManager>();
            textureManager      = ResolveOrCreate <WoWTextureManager>();
            meshManager         = ResolveOrCreate <WoWMeshManager>();
            mdxManager          = ResolveOrCreate <MdxManager>();
            wmoManager          = ResolveOrCreate <WmoManager>();
            worldManager        = ResolveOrCreate <WorldManager>();
            chunkManager        = ResolveOrCreate <ChunkManager>();
            cameraManager       = ResolveOrCreate <CameraManager>();
            lightingManager     = ResolveOrCreate <LightingManager>();
            areaTriggerManager  = ResolveOrCreate <AreaTriggerManager>();
            raycastSystem       = ResolveOrCreate <RaycastSystem>();
            moduleManager       = ResolveOrCreate <ModuleManager>();

            IsInitialized = true;
            return(true);
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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;
        }