Пример #1
0
        public void OnFrame(Camera camera)
        {
            if (WorldFrame.Instance.HighlightModelsInBrush)
            {
                var brushPosition   = Editing.EditManager.Instance.MousePosition;
                var highlightRadius = Editing.EditManager.Instance.OuterRadius;
                UpdateBrushHighlighting(brushPosition, highlightRadius);
            }

            lock (mAddLock)
            {
                M2BatchRenderer.BeginDraw();
                // First draw all the instance batches
                foreach (var renderer in mRenderer.Values)
                {
                    renderer.RenderBatch();
                }

                M2SingleRenderer.BeginDraw();
                // Now draw those objects that need per instance animation
                foreach (var instance in mNonBatchedInstances.Values)
                {
                    instance.Renderer.RenderSingleInstance(instance);
                }

                // Then draw those that have alpha blending and need ordering
                foreach (var instance in mSortedInstances.Values)
                {
                    instance.Renderer.RenderSingleInstance(instance);
                }
            }

            IsViewDirty = false;
        }
Пример #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;
        }