Пример #1
0
        public void Draw()
        {
            graphicsDevice.BlendState        = BlendState.Opaque;
            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            // Projection を更新します。
            projection.AspectRatio = graphicsDevice.Viewport.AspectRatio;
            projection.Update();

            // CameraView を更新します。
            CameraView.Update();

            // DirectionalLightModel.View を更新します。
            DirectionalLightModel0.View.Update();
            DirectionalLightModel1.View.Update();
            DirectionalLightModel2.View.Update();

            // GridBlockMesh を描画します。
            if (GridVisible)
            {
                DrawGridBlockMesh();
            }

            // Block を描画します。
            DrawBlock();
        }
Пример #2
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (Workspace.SelectedMaterial == null)
            {
                return;
            }

            var bounds = new Rect(0, 0, RenderSize.Width, RenderSize.Height);

            using (var draw3d = drawContext.BeginDraw3D())
                using (var localViewport = drawContext.BeginViewport(bounds))
                    using (var localClipping = drawContext.BeginNewClip(bounds))
                    {
                        var graphicsDevice = Screen.GraphicsDevice;
                        graphicsDevice.BlendState        = BlendState.Opaque;
                        graphicsDevice.DepthStencilState = DepthStencilState.Default;

                        // View を更新します。
                        view.Update();

                        // Projection を更新します。
                        projection.AspectRatio = graphicsDevice.Viewport.AspectRatio;
                        projection.Update();

                        var material = Workspace.SelectedMaterial;
                        var effect   = cubeMesh.Effect;
                        effect.View          = view.Matrix;
                        effect.Projection    = projection.Matrix;
                        effect.DiffuseColor  = material.DiffuseColor.ToVector3();
                        effect.EmissiveColor = material.EmissiveColor.ToVector3();
                        effect.SpecularColor = material.SpecularColor.ToVector3();
                        effect.SpecularPower = material.SpecularPower;

                        cubeMesh.Draw();
                    }
        }