Game Development Reference

In-Depth Information

a boundary edge and so a mid-point must be added using the border edge

equation given above, regardless of the vertex valences.

typedef struct stEDGE{

unsigned short a,b; //Indices of existing vertices

unsigned short v;

//Index of the middle vertex

}EDGE;

typedef struct stPOINTCON{

unsigned char valence;

unsigned short p[MAX_VALENCE];

unsigned char border;

}POINTCON;

The first step in any subdivision is to store the original mesh topology.

This is stored in a new PATCHINFO structure.

typedef struct stPATCHINFO{

POINT3D *pts;

POLYGON *pchs;

int numpoints;

int numpatches;

}PATCHINFO;

This ensures that we can restore the original topology at any time.

//=============================================================

//CreatePatchInfo

//Copies the original vertex and polygon information into a

//new data structure PATCHINFO. This is the same as a OBJECTINFO

//without any surface information. The purpose of the function

//is to allow the transformation engine to restore the original

//vertex and polygon structure after having rendered the subdivided

//mesh

//=============================================================

BOOL CT3DObject::CreatePatchInfo()

{

if (pi.pts) delete [] pi.pts;

if (pi.pchs) delete [] pi.pchs;

pi.pts = new POINT3D[oi.numpoints];

Search Nedrilad ::

Custom Search