コード例 #1
0
ファイル: DeferredShader.cs プロジェクト: Lin20/isosurface
        public void Draw(ISurfaceAlgorithm a, Camera c)
        {
            /* Set buffers */
            Device.SetRenderTargets(color_target, normal_target, depth_target);

            Clear();
            DrawScene(c, a);
            Device.SetRenderTarget(null);

            DrawFinal(c);
        }
コード例 #2
0
ファイル: DeferredShader.cs プロジェクト: Lin20/isosurface
        private void DrawScene(Camera c, ISurfaceAlgorithm a)
        {
            Device.RasterizerState = r_state;
            RenderToShader.Parameters["World"].SetValue(Matrix.CreateTranslation(new Vector3(-Game1.Resolution / 2, -Game1.Resolution / 2, -Game1.Resolution / 2)));
            RenderToShader.Parameters["View"].SetValue(c.View);
            RenderToShader.Parameters["Projection"].SetValue(c.Projection);

            RenderToShader.CurrentTechnique.Passes[0].Apply();
            a.Draw(null);
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: chongbingbao/isosurface
        protected override void Initialize()
        {
            DualMarchingSquaresNeilson.MarchingSquaresTableGenerator.PrintCaseTable();
            float n = SimplexNoise.Noise(0, 0);
            RState = new RasterizerState();
            RState.CullMode = CullMode.CullClockwiseFace;
            GraphicsDevice.RasterizerState = RState;
            graphics.PreferredBackBufferWidth = 1600;
            graphics.PreferredBackBufferHeight = 900;
            graphics.PreferMultiSampling = true;
            graphics.ApplyChanges();

            IsMouseVisible = true;

            effect = new BasicEffect(GraphicsDevice);

            QualityIndex = 1;
            NextAlgorithm();

            effect.VertexColorEnabled = true;

            Camera = new Camera(GraphicsDevice, new Vector3(-Resolution, Resolution, -Resolution) , 1f);
            if (SelectedAlgorithm.Is3D)
            {
                Camera.Update(true);
                effect.View = Camera.View;
            }
            last_state = Keyboard.GetState();

            DrawMode = Isosurface.DrawModes.Mesh | DrawModes.Outline;
            WireframeMode = WireframeModes.Fill;

            base.Initialize();
        }
コード例 #4
0
ファイル: DeferredShader.cs プロジェクト: Lin20/isosurface
        private void DrawFinal(Camera c)
        {
            FinalShader.Parameters["color_map"].SetValue(color_target);
            FinalShader.Parameters["normal_map"].SetValue(normal_target);
            FinalShader.Parameters["depth_map"].SetValue(depth_target);
            FinalShader.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(c.View * c.Projection));

            FinalShader.CurrentTechnique.Passes[0].Apply();
            quad.Render(Device);
        }
コード例 #5
0
ファイル: ISurfaceAlgorithm.cs プロジェクト: Lin20/isosurface
        public virtual void DrawWireframe(Camera c, Effect e, Matrix world)
        {
            if (WireframeCount == 0)
                return;
            e.Parameters["World"].SetValue(world);
            e.Parameters["View"].SetValue(c.View);
            e.Parameters["Projection"].SetValue(c.Projection);
            e.CurrentTechnique.Passes[0].Apply();

            Device.Indices = WireframeIndexBuffer;
            Device.SetVertexBuffer(WireframeBuffer);

            Device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, WireframeVertexCount, 0, WireframeCount / 2);

            Device.SetVertexBuffer(null);
            Device.Indices = null;
        }