Game Development Reference
In-Depth Information
case 6:
//We can leave this to be calculated in the next switch
//statement. It only applies to valence 6 for both vertices
break;
case 5:
default:
//v1=3/4,ca[n]=(1/4+cos(2pi*n/valence)+1/2(cos(4pi*n/
valence))/valence
valence = pc1.valence;
pt1.x = pts[v1].x * 0.75;
pt1.y = pts[v1].y * 0.75;
pt1.z = pts[v1].z * 0.75;
for ( i=0; i<pc1.valence; i++){
weight = (0.25 + cos((PI2 * (double)i)/valence) +
0.5 * cos((PI2 * 2 * (double)i)/valence))/valence;
pt1.x += pts[pc1.p[i]].x * weight;
pt1.y += pts[pc1.p[i]].y * weight;
pt1.z += pts[pc1.p[i]].z * weight;
}
break;
}
switch(pc2.valence){
case 3:
//v2=3/4,cb[0]=5/12, cb[1],cb[2]=-1/12
pt2.x = pts[v2].x * 0.75 +
pts[pc2.p[0]].x * 0.4167 -
pts[pc2.p[1]].x * 0.0833 -
pts[pc2.p[2]].x * 0.0833;
pt2.y = pts[v2].y * 0.75 +
pts[pc2.p[0]].y * 0.4167 -
pts[pc2.p[1]].y * 0.0833 -
pts[pc2.p[2]].y * 0.0833;
pt2.z = pts[v2].z * 0.75 +
pts[pc2.p[0]].z * 0.4167 -
pts[pc2.p[1]].z * 0.0833 -
pts[pc2.p[2]].z * 0.0833;
if (pc1.valence==6){
v->x = pt2.x; v->y = pt2.y; v->z = pt2.z;