Drawing Billboards

With our vertex and index buffers set up, we are ready to write the code that draws our billboards. First, we will need a function to set all of our effect parameters to our soon-to-be-written effect:

void setEffectParameters(Matrix View, Matrix Projection, Vector3 Up, Vector3 Right)
{
effect.Parameters["ParticleTexture"].SetValue(texture);
effect.Parameters["View"].SetValue(View);
effect.Parameters["Projection"].SetValue(Projection);
effect.Parameters["Size"].SetValue(billboardSize / 2f);
effect.Parameters["Up"].SetValue(Up);
effect.Parameters["Side"].SetValue(Right);
effect.CurrentTechnique.Passes[0].Apply();
}

The Up and Right vectors are especially important, as these are the axes along which we will move the vertices from ...

Get 3D Graphics with XNA Game Studio 4.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.