Game Development Reference
In-Depth Information
v->x=pt2.x; v->y=pt2.y; v->z=pt2.z;
v->x = (pt1.x + pt2.x)/2.0;
v->y = (pt1.y + pt2.y)/2.0;
v->z = (pt1.z + pt2.z)/2.0;
return edge->v;//Zero start for the indices
This leaves just the main function call to the function SubDivide . The
passed parameter indicates how many times to subdivide the mesh. The
first step in the subdivision is restoring the original mesh. Then we create
a connectivity array and iterate through the base polygons, adding the
new polygons to the subdivided polygons' array. The subdivided mesh
uses all new polygons, but it uses the original vertex list. The new
polygons are formed from the existing and new vertices using the
following stencil:
p [0],
v 1,
v 3
p [1],
v 2,
v 1
p [2],
v 3,
v 2
v 1,
v 2,
v 3
Figure 15.12 Indices of added polygons.
Search Nedrilad ::

Custom Search