Game Development Reference
In-Depth Information
Figure 47 - A visual representation of a transformation matrix.
The first part is generating the geometry for the axis lines, we need 3 lines, consisting of
twovertices each,thisistoallowustocoloreachlineindependently,aswesawbefore,we
will represent the axes X,Y,Z by the colors R,G,B respectively.
vertex_default vertices[6];
// x-axis
vertices[0] = vertex_default(math::vector3::Zero, color::RED);
vertices[1] = vertex_default(math::vector3::UnitX, color::RED);
// y-axis
vertices[2] = vertex_default(math::vector3::Zero, color::GREEN);
vertices[3] = vertex_default(math::vector3::UnitY, color::GREEN);
// z-axis
vertices[4] = vertex_default(math::vector3::Zero, color::BLUE);
vertices[5] = vertex_default(math::vector3::UnitZ, color::BLUE);
We will create a vertex buffer with these vertices and this will be used to render the axis
lines. If we wanted, we could stop here and only display the axes as three color-coded
lines, but we can use our newfound knowledge and cap each line with a pyramid, or a cone
(though, a pyramid has fewer faces).
Since our cone object is by default a unit cone, we only need to create one instance of it
thatwewillrenderthreetimes,oneperaxis.Wewillneedtotransformtheconethreetimes
toset it at the correct position onthe axis andwewill rotate it soit points outwards, like an
arrow, we will start by declaring the cone's transformation.
math::matrix coneTransform = math::matrix::Identity;
Forthex-axis,wewillwanttorolltheconesoitstippointsoutwardsfromthex-axis,given
that the cone initially points up in the y-axis, we need to roll it by π/2 and then translate it
Search WWH ::




Custom Search