Isosurface.ISurfaceAlgorithm.Draw C# (CSharp) Method

Draw() public method

public Draw ( Effect effect, bool enable_lighting = false, DrawModes mode = DrawModes.Mesh|DrawModes.Outline ) : void
effect Microsoft.Xna.Framework.Graphics.Effect
enable_lighting bool
mode DrawModes
return void
        public virtual void Draw(Effect effect, bool enable_lighting = false, DrawModes mode = DrawModes.Mesh | DrawModes.Outline)
        {
            //effect.LightingEnabled = false;
            if (OutlineLocation > 0 && (mode & DrawModes.Outline) != 0)
            {
                effect.CurrentTechnique.Passes[0].Apply();
                Device.SetVertexBuffer(OutlineBuffer);
                Device.DrawPrimitives(PrimitiveType.LineList, 0, OutlineLocation / 2);
            }

            if ((IsIndexed && IndexCount == 0) || (!IsIndexed && VertexCount == 0) || ((mode & DrawModes.Mesh) == 0))
            {
                Device.SetVertexBuffer(null);
                return;
            }

            if (enable_lighting)
            {
                /*effect.LightingEnabled = true;
                effect.PreferPerPixelLighting = true;
                effect.SpecularPower = 64;
                effect.SpecularColor = Color.Black.ToVector3();
                effect.CurrentTechnique.Passes[0].Apply();
                effect.AmbientLightColor = Color.Gray.ToVector3();*/
            }

            if (effect != null)
                effect.CurrentTechnique.Passes[0].Apply();
            Device.SetVertexBuffer(VertexBuffer);
            if (IsIndexed)
            {
                Device.Indices = IndexBuffer;
                if (Is3D)
                    Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VertexCount, 0, Math.Min(1048575, IndexCount / 3));
                else
                    Device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, VertexCount, 0, IndexCount / 2);
                Device.Indices = null;
            }
            else
            {
                if (Is3D)
                    Device.DrawPrimitives(PrimitiveType.TriangleList, 0, VertexCount / 3);
                else
                    Device.DrawPrimitives(PrimitiveType.LineList, 0, VertexCount / 2);
            }
            Device.SetVertexBuffer(null);
        }

Usage Example

コード例 #1
0
        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);
        }
All Usage Examples Of Isosurface.ISurfaceAlgorithm::Draw