Game Development Reference
In-Depth Information
//Sub divides the mesh pointed to by the OBJECTINFO data structure
//The results of the subdivision are stored in the OBJECTINFO
//data structure.
BOOL CT3DObject::SubDivide(int subDivIndex)
if (subDivIndex<1) return FALSE;
//The PATCHINFO structure stores the original mesh
if (pi.numpoints==0) CreatePatchInfo();
//Start by copying original mesh
//We are using Butterfly subdivsion so the existing vertices
//must be part of the cage information
delete [] oi.pts;
delete [] oi.plys;
oi.pts = new POINT3D[pi.numpoints];
oi.plys = new POLYGON[pi.numpatches];
memcpy(oi.pts, pi.pts, sizeof(POINT3D) * pi.numpoints);
memcpy(oi.plys, pi.pchs, sizeof(POLYGON) * pi.numpatches);
oi.numpoints = pi.numpoints;
oi.numpolygons = pi.numpatches;
int numpolygons, numedges, numpoints, edgecount, pointcount;
int i,k,v1,v2,v3;
EDGE *edges;
POLYGON *ply, *sdply, *plys;
POINT3D *pts;
for ( i=0; i<subDivIndex; i++){
numpolygons = oi.numpolygons * 4; //Accurate
numedges = (numpolygons * 3); // Worst case
numpoints = oi.numpoints + numedges;
plys = new POLYGON[numpolygons];
pts = new POINT3D[numpoints];
con = new POINTCON[oi.numpoints];
edges = new EDGE[numedges];
Search Nedrilad ::

Custom Search