Game Development Reference
In-Depth Information
if (!pi.pts) return FALSE;
memcpy(pi.pts, oi.pts, sizeof(POINT3D) * oi.numpoints);
pi.numpoints = oi.numpoints;
pi.pchs = new POLYGON[oi.numpolygons];
if (!pi.pchs) return FALSE;
memcpy(pi.pchs, oi.plys, sizeof(POLYGON) * oi.numpolygons);
pi.numpatches = oi.numpolygons;
return TRUE;
}
Having stored the original topology we now want to analyse the
topology of the mesh. To this end, the code used to examine the mesh is
given below. For each vertex in the mesh we scan all the polygons in the
mesh and if the current vertex, v , is used then we add a pointer to this
polygon to the local array plyscan and update a counter of added
polygons. Having traversed all the polygons in the mesh, we have an
array of plycount POLYGON pointers called plyscan . The next stage in
the process is to attempt to create an ordered list of vertices using just the
plycount polygons in the plyscan array. Regarding the current vertex as a
central point, we can store the vertices in the first polygon in the plyscan
array.
The vertex indices are stored in the POINTCON members p [0] and
p [1]. Now that the first polygon has been added plyscan[0] can be set to
NULL, to indicate that this polygon has been considered. The next step is
Figure 15.9 Identifying the appropriate vertices to create an anticlockwise ordering.
Search Nedrilad ::




Custom Search