O'Reilly logo

3D Graphics with XNA Game Studio 4.0 by Sean James

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required