Ejemplo n.º 1
0
 public MaterialHolder()
 {
     Material = new Material();
     Vertices = new List<VertexPositionNormalTexture>();
     Indices = new List<int>();
 }
Ejemplo n.º 2
0
        static void Draw(GameTime gameTime, Material material, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
        {
            material.GraphicsDevice.VertexDeclaration = material.VertexDeclaration;
            material.GraphicsDevice.Vertices[0].SetSource(material.VertexBuffer, 0, material.VertexStride);
            material.GraphicsDevice.Indices = material.IndexBuffer;

            material.GraphicsDevice.RenderState.DepthBufferEnable = true;
            material.GraphicsDevice.RenderState.AlphaTestEnable = false;
            material.GraphicsDevice.RenderState.AlphaBlendEnable = false;

            material.GraphicsDevice.RenderState.CullMode = CullMode.None;

            BasicEffect effect = material.Effect;

            effect.View = viewMatrix;
            effect.Projection = projectionMatrix;
            effect.World = worldMatrix;
            effect.TextureEnabled = ((effect.Texture = material.Texture2D) != null);
            effect.VertexColorEnabled = false;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                material.GraphicsDevice.DrawIndexedPrimitives(material.PrimitiveType, 0, 0, material.VertexCount, 0, material.PrimitiveCount);
                pass.End();
            }
            effect.End();
        }