Game Development Reference
In-Depth Information
double mx,my,mz; //Rotated normal
double wx,wy,wz; //Rotated points
int weight;
//0 vertex transformed by mesh
//n vertex transformed by n controls
}POINT3D;
//=============================================================
//AssignControlPoints
//bobj is the target single mesh object
//This function looks for a link between the vertex locations in this
//object and those in the target mesh bobj. It creates an array of
//m_numpoints POINT3D pointers which can be used to deform the target
//mesh.
//=============================================================
BOOL CToon3DObject::AssignControlPoints(CToon3DObject *bobj)
{
//Delete any existing m_vptr array
if (m_vptr) delete [] m_vptr;
//Creates m_numpoints POINT3D pointers
m_vptr=new POINT3D*[m_numpoints];
if (!m_vptr) return FALSE; //Probably means a memory error
POINT3D *pt; //pt is used to step through this controls points
POINT3D *bpt;// bpt is used to step through the target points
int count=0; //Incremented as point assignment occurs
pt = m_pts; //m_pts is the point array for this control
//Step through control points
for (int i=0;i<m_numpoints;i++){
bpt = bobj->m_pts;
for (int j=0;j<bobj->m_numpoints;j++){
if (pt->x==bpt->x && pt->y==bpt->y &&
pt->z==bpt->z){
//Control and target points match
bpt->weight++;
ptindex[i]=bpt;
count++;
break;
}
//Step on to next target point
bpt++;
Search Nedrilad ::




Custom Search