Game Development Reference
In-Depth Information
Figure 15.10 Identifying boundary vertices.
to find a polygon in the plyscan array that has the edge ( v , p [1]), where v
is the current vertex index ('ptindex' in the sample code) and p [1] is the
index shown in the code as 'vindex'. If this edge is found, then we can add
the remaining vertex in the triangle as the next member of our connectivity
array and update the search edge. If it is not found, then we can assume
that this is a boundary vertex. We store the current count so that we can
reorder the array later. A border vertex must have two edges that do not
form a continuous link; Figure 15.10 indicates how this must be so. If we
have found the gap, then setting our search to any other polygon in the
scanned array should result in a continuous link. Then we place the
vertices we found before restarting at the end of the newly found vertices.
In this way, the edges defined by ( v , p [0]) and ( v , p [ N - 1]), where N is the
valence, must be boundary edges.
//=============================================================
//CreateConnectivityArray
//Used by SubDivide.
//=============================================================
BOOL CT3DObject::CreateConnectivityArray(POINTCON *con){
POLYGON *plyscan[MAX_VALENCE],*ply;
int i, ptindex, plyindex, plycount, count, vindex;
unsigned short p[MAX_VALENCE];
POINTCON *ptcon = con;
BOOL found,rev;
for(ptindex=0; ptindex<oi.numpoints; ptindex++){
//Scan through all polygons to find ones that
//have a point index with value ptindex and
//store them in the plyscan array.