Game Development Reference
In-Depth Information
We precompute each of the vertex indices because we will use them later, it is always im-
portanttoavoidperformingthesamecalculationmultipletimes,inparticularwithinaloop.
Finallysincewehavealreadycalculated thevertexindicesforeachofthefacevertices,we
just need to map them into the proper position within the index buffer.
indices[i* 6 + 0] = vertexIndex0;
indices[i* 6 + 1] = vertexIndex1;
indices[i* 6 + 2] = vertexIndex2;
indices[i* 6 + 3] = vertexIndex0;
indices[i* 6 + 4] = vertexIndex2;
indices[i* 6 + 5] = vertexIndex3;
3.12.3 Pyramid / Cone
A cone is made up by creating a circle with a vertex in the middle then extruding that
middle vertex by some distance, if we lower the resolution enough on a cone we end up
with a cone with four sides, or a pyramid.
Figure 45 - A pyramid and a cone can be generated with the same algorithm.
The first piece of information we will need to create a cone is the angle.
The smaller the angle, the smoother the cone; as the angle becomes larger the cone will
lose resolution, so that if we need to produce a pyramid we would choose π/2 as the angle.
An angle of π will produce a flat triangle.
Search WWH ::




Custom Search