Game Development Reference
In-Depth Information
v->y = 0.5625 * pts[v1].y +
0.5625 * pts[v2].y -
0.0625 * pts[pc1.p[pc1.valence-1]].y -
0.0625 * pts[pc2.p[0]].y;
v->z = 0.5625 * pts[v1].z +
0.5625 * pts[v2].z -
0.0625 * pts[pc1.p[pc1.valence-1]].z -
0.0625 * pts[pc2.p[0]].z;
return edge->v;
}
//Calculate the location of the new vertex based on
//modified Butterfly
switch(pc1.valence){
case 3:
//v1=3/4,ca[0]=5/12, ca[1],ca[2]=-1/12
pt1.x = pts[v1].x * 0.75 +
pts[pc1.p[0]].x * 0.4167 -
pts[pc1.p[1]].x * 0.0833 -
pts[pc1.p[2]].x * 0.0833;
pt1.y = pts[v1].y * 0.75 +
pts[pc1.p[0]].y * 0.4167 -
pts[pc1.p[1]].y * 0.0833 -
pts[pc1.p[2]].y * 0.0833;
pt1.z = pts[v1].z * 0.75 +
pts[pc1.p[0]].z * 0.4167 -
pts[pc1.p[1]].z * 0.0833 -
pts[pc1.p[2]].z * 0.0833;
break;
case 4:
//v1=3/4,ca[0]=3/8, ca[1]=0, ca[2],=-1/8,ca[3]=0
pt1.x = pts[v1].x * 0.75 +
pts[pc1.p[0]].x * 0.375 -
pts[pc1.p[2]].x * 0.125;
pt1.y = pts[v1].y * 0.75 +
pts[pc1.p[0]].y * 0.375 -
pts[pc1.p[2]].y * 0.125;
pt1.z = pts[v1].z * 0.75 +
pts[pc1.p[0]].z * 0.375 -
pts[pc1.p[2]].z * 0.125;
break;