MyGame.HPBillboardSystem.Draw C# (CSharp) Method

Draw() public method

This method renders the current state.
public Draw ( Matrix View, Matrix Projection, Vector3 Up, Vector3 Right ) : void
View Matrix
Projection Matrix
Up Vector3
Right Vector3
return void
        public void Draw(Matrix View, Matrix Projection, Vector3 Up, Vector3 Right)
        {
            // Set the vertex and index buffer to the graphics card
            graphicsDevice.SetVertexBuffer(verts);
            graphicsDevice.Indices = ints;

            graphicsDevice.BlendState = BlendState.AlphaBlend;

            setEffectParameters(View, Projection, Up, Right);

            if (EnsureOcclusion)
            {
                drawOpaquePixels();
                drawTransparentPixels();
            }
            else
            {
                graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
                effect.Parameters["AlphaTest"].SetValue(false);
                drawBillboards();
            }

            // Reset render states
            graphicsDevice.BlendState = BlendState.Opaque;
            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            // Un-set the vertex and index buffer
            graphicsDevice.SetVertexBuffer(null);
            graphicsDevice.Indices = null;
        }

Usage Example

        /// <summary>
        /// This method renders the current state.
        /// </summary>
        /// <param name="gameTime">The elapsed game time.</param>
        public override void Draw(GameTime gameTime)
        {
            foreach (Monster monster in monsters)
            {
                monster.Draw(gameTime);
            }

            if (monsters.Count != 0)
            {
                hpBillBoardSystem.Draw(myGame.camera.View, myGame.camera.Projection,
                                       ((ChaseCamera)myGame.camera).Up, ((ChaseCamera)myGame.camera).Right);
            }
            base.Draw(gameTime);
        }