You are on page 1of 1

} } break; glutSetWindowTitle("sphere - removing hidden faces and phong mod el Flat shading"); rot=rotationYMTX(0.02*tickindisp); mat=tilting*rot; for (i=0;i<sphere.NumberofVertices;i++) { vec[i]=point2Vector(sphere.

pnt[i]); vec[i]=mat*vec[i]; } for (i=0;i<sphere.NumberofFaces;i++) { for (i=0;j<sphere.fc[i]NumberofVertices;j++) { vecbuff(j)=vec[sphere.fc[i].pnt[j]]; } NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff [0]); normalzi=NormalVector.v[2]; if (0.<normalzi) { for (j=0;j<sphere.fc[i]NumberofVertices;j++) { buff[j]=Vector2point2D(vecbuff[j]; } NormalVector=unitVector(NormalVector); fillcolor=PhongModel(LightVector,NormalVector,ViewVector,ColCyan); fillolygon(buff,sphere.fc[i].NumberofVertices,fillcolor); } } break; glutSetWindowTitle("sphere - removing hidden faces and phong mod el Gouraud shading"); rot=rotationYMTX(0.02*tickindisp); mat=tilting*rot; for (i=0;i<sphere.NumberofVertices;i++) { vec[i]=point2Vector(sphere.pnt[i]); vec[i]=mat*vec[i];sphere.pnt[i]); vec[i]=mat*vec[i]; nrmvec[i]=mat*shere.NormalVector[i]-ZeroVector; }

You might also like