Game Development Reference

In-Depth Information

edges
- the current edge array;

pts
- the point list for the mesh;

con
- the connectivity array for the mesh;

pointcount
- the number vertices in the pts, point list;

edgecount
- the number of edges in the edges, edge list;

v
1
- end-point index;

v
2
- end-point index;

return value - the index of the mid-point for this edge.

The AddEdge function first checks if the edge already exists. If it does,

then it simply returns the index of the mid-point of the existing edge. If it

does not exist, then a new edge is added to the edge array and the value

edgecount is updated. The mid-point of the edge is calculated using the

POINTCON array for the end-points. Vertices are passed using indices

into the pts array and the con array. The calculation uses the valence of

one end-point in the array to calculated a new vertex location pt1. Then

the function looks at the other end-point and calculates a new vertex

location pt2. If both end-points are extraordinary, then the average of the

two points is used. When using the POINTCON for the current vertex, it

is important to get the correct orientation, that is
p
[0] must be the opposite

edge vertex. This is done by iterating through the vertex indices in the

point array to find the opposite edge vertex index and then constructing a

new POINTCON structure using this information. When a vertex is a

border edge this simply means moving the end of the array to the

beginning and placing the beginning of the array on the end of the new

Figure 15.11 Identifying vertices as named in the AddEdge function.

Search Nedrilad ::

Custom Search