Beispiel #1
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;
            }
        }
Beispiel #2
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;
        }