Game Development Reference
In-Depth Information
if (!edges||!plys || !pts || !con) goto subdivabort;
//Create an array of vertex connectivity
edgecount = 0;
pointcount = oi.numpoints;
ply = oi.plys;
sdply = plys;
TEXVEC tv[3];
//Copy base points
memcpy(pts, oi.pts, sizeof(POINT3D)*oi.numpoints);
v1 = AddEdge(edges, pts, con, pointcount, edgecount,
ply->p[0], ply->p[1]);
v2 = AddEdge(edges, pts, con, pointcount, edgecount,
ply->p[1], ply->p[2]);
v3 = AddEdge(edges, pts, con, pointcount, edgecount,
ply->p[2], ply->p[0]);
//Create the polygons and interpolate the texture coordinates
if (oi.srfs[ply->srf].tex){
tv[0].u = (float)(ply->tc[0].u + ply->tc[1].u)/2.0f;
tv[0].v = (float)(ply->tc[0].v + ply->tc[1].v)/2.0f;
tv[1].u = (float)(ply->tc[1].u + ply->tc[2].u)/2.0f;
tv[1].v = (float)(ply->tc[1].v + ply->tc[2].v)/2.0f;
tv[2].u = (float)(ply->tc[0].u + ply->tc[2].u)/2.0f;
tv[2].v = (float)(ply->tc[0].v + ply->tc[2].v)/2.0f;
if (!CreatePolygon(sdply++, ply->srf,
ply->p[0], v1, v3, ply->tc[0], tv[0], tv[2])) goto
if (!CreatePolygon(sdply++, ply->srf,
ply->p[1], v2, v1, ply->tc[1], tv[1], tv[0])) goto
if (!CreatePolygon(sdply++, ply->srf,
ply->p[2], v3, v2, ply->tc[2], tv[2], tv[1])) goto
if (!CreatePolygon(sdply++, ply->srf,
v1, v2, v3, tv[0], tv[1], tv[2])) goto subdivabort;
Search Nedrilad ::

Custom Search