// sphere with class // mesh modeling // Gouraud shading // T. Kosaka CS TNCT 8Aug2002 #include #include #include #include "CGCore3D.h" #ifndef M_PI #define M_PI 3.141592653589793 #endif void userdraw(void); void display(void) { glClear( GL_COLOR_BUFFER_BIT); userdraw(); glutSwapBuffers(); } ////////////////////////////////////////////////////////////////// static void makeSphere(C_Smoothpolyhedron &sphere,float r,int NumLatEdge,int NumLngEdge,C_Color color,opticalAttribute_t attr) { // r : radius of the sphere // NumLatEdge : number of segments along the longitude at Latitude 0 // NumLngEdge : number of segments along the equator int NumberVertices; //多面体を構成する頂点の数 C_Vertex *Vertex; //多面体を構成する頂点の座標 C_Vector *NormalVector; //各擬似頂点位置の法線ベクトル int NumberFaces; //多面体を構成する面の数 C_Face *Face; //多面体を構成する面の定義 float latitude; float longitude; int i,j,k; C_Vector unitz(0,0,1); C_Vector unityn(0,1,0); C_Vector unitys(0,-1,0); C_Matrix mat1,mat2; NumberVertices=1+(NumLatEdge-1)*NumLngEdge+1; Vertex = new C_Vertex[NumberVertices]; NormalVector = new C_Vector[NumberVertices]; NormalVector[0]=unityn; Vertex[0]=r*NormalVector[0]; for(i=1;i