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();
            }
        }
Exemple #2
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            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))
                    {
                        ViewModel.Draw();
                    }
                }
            }
        }
Exemple #3
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            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))
                    {
                        ViewModel.Draw();
                    }
                }
            }
        }
        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();
                    }
        }