Game Development Reference
In-Depth Information
square , we will divide this vector by 2, this will ensure that the width and height of the
quad will be one.
To guarantee that the basis is orthonormal, we will recalculate the up vector (the y axis)
by computing the cross product of the right and the normal . The resulting vectors will be
perpendicular to the right and the normal and can now be used to position the vertices by
adding and/or subtracting them to the origin.
Figure 42 - Generation of a quad using basis vectors.
Now we will have generated the geometry for a unit quad, the next step will be to render
it. Before we render it we will need to know what the behavior we expect for this quad, if
the quad is a world-space object, we can use a world space transformation that will orient
it and place it at the desired location, however, there are more ways in which we can trans-
form quads that are useful, particularly in the context of user interface development.
The default case will be to transform the quad with a user provided transformation matrix.
The quad's world transformation matrix is passed through the quad::Draw function and
then sent to the vertex buffer.
3.12.1.1Screen Aligned Quad
Often we need to display information within the game universe, but we need to make sure
it is always visible to the player, this is usually the case for user interface elements that
highlight game objects, such as loot or parts of the universe that are interactive.
The quad generation is no different from a standard quad, in fact, we can reuse the same
code and add a flag to the quad object that will make the quad screen aligned. We will per-
Search WWH ::




Custom Search