Game Development Reference
In-Depth Information
At this stage we have all the information we need to apply modified
butterfly subdivision. The purpose of subdivision is to add polygons to the
mesh, so we include a utility function for this purpose. This function is
passed a reference to the new polygon and sets the vertex indices and
texture coordinates. Texture coordinates are calculated as simply the mid-
point of an edge. If the end-points of the edge have texture coordinates
tc 1 and tc 2 then the mid-point for this edge will have texture
u =( tc 1 * u + tc 2 * u )/2
v =( tc 1 * v + tc 2 * v )/2
These coordinates are calculated by the caller to the CreatePolygon
BOOL CT3DObject::CreatePolygon(POLYGON &sdply, int srfID,
int v1, int v2, int v3, TEXVEC &tv1, TEXVEC &tv2, TEXVEC &tv3){
sdply.numverts = 3;
sdply.p[0] = v1;
sdply.p[1] = v2;
sdply.p[2] = v3;
sdply.srf = srfID;
if (oi.srfs[srfID].tex){[0].u = tv1.u;[0].v = tv1.v;[1].u = tv2.u;[1].v = tv2.v;[2].u = tv3.u;[2].v = tv3.v;
memset(, 0, sizeof(TEXVEC)*3);
return TRUE;
The actual function call to subdivide a mesh iterates through all the
polygons in the mesh and replaces a single polygon with four polygons.
The first step in creating the new polygons is to add the three edges in the
triangle to an edge array. This is achieved using the AdgeEdge function
call, which has seven parameters.
int CT3DObject:: AddEdge (EDGE * edges , POINT3D * pts , POINTCON * con ,
int & pointcount , int & edgecount , int v1 , int v2 )
Search Nedrilad ::

Custom Search