Game Development Reference
In-Depth Information
list. An example may help. If the vertex indices for each end of an edge
are (10, 23) and the connectivity array for the vertex with index 10 is (2,
34, 56, 23, 12, 14), then we need to adjust the connectivity array so that
it reads (23, 12, 14, 2, 34, 56). Now the vertex with index 23, the opposite
edge vertex, is first in the connectivity array. The same work must be done
to the connectivity array for the vertex with index 23. This time the first
member of the connectivity array must be the vertex with index 10. Figure
15.11 shows how the vertices relate to the code naming.
//=============================================================
//AddEdge
//Takes an array of count edges and tests to see if vertex indices
//v1 and v2 have already been assigned an edge if so function returns
//the index of the edge. If not it creates a new edge, updates the
//count value, assigns the connectivity of end vertices, sets
//the valences and returns the index of this edge
//The connectivity array must have been pre calculated
//=============================================================
int CT3DObject::AddEdge(EDGE *edges, POINT3D *pts, POINTCON *con,
int &pointcount, int &edgecount, int v1, int v2)
{
EDGE *edge = edges;
for (int i=0; i<edgecount; i++){
if (edge->a == v1 && edge->b == v2) return edge->v;
if (edge->a == v2 && edge->b == v1) return edge->v;
edge++;
}
//If we get here then the edge has not been found
edge = &edges[edgecount];
edge->a = v1;
edge->b = v2;
edge->v = pointcount;
edgecount++;
pointcount++;
POINT3D *v = &pts[edge->v], pt1, pt2;
double w=0.0125,weight,valence;
int index,j;
POINTCON pc1, pc2;
Search Nedrilad ::




Custom Search