#ifndef M_PI #define M_PI 3.141592654 #endif void normalize(float* a){ float l = sqrt(a[1]*a[1] + a[2]*a[2] + a[0]*a[0]); if (l<0.00000001) l = 1; for (int i=0;i<3;i++) a[i] = a[i]/l*currentScale; } void cross(float *a, float *b, float *c, float *d){ d[0] = (b[1]-a[1]) * (c[2]-a[2]) - (b[2]-a[2]) * (c[1]-a[1]); d[1] = (b[2]-a[2]) * (c[0]-a[0]) - (b[0]-a[0]) * (c[2]-a[2]); d[2] = (b[0]-a[0]) * (c[1]-a[1]) - (b[1]-a[1]) * (c[0]-a[0]); normalize(d); } void averageNormals(float* a, float* b, float* c, float* d, float* e){ e[0] = (a[0]+b[0]+c[0]+d[0])/4.0f; e[1] = (a[1]+b[1]+c[1]+d[1])/4.0f; e[2] = (a[2]+b[2]+c[2]+d[2])/4.0f; normalize(e); } #define layers 28 #define n 20 void drawMyCreation() { //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glPolygonMode(GL_FRONT, GL_FILL); glClearColor(1,1,1,1); GLfloat mat_color1[] = {0.3,0.3,0.5,1}; GLfloat mat_color2[] = {0.5, 0.5, 0.7,1}; GLfloat mat_color3[] = {1, 1, 1 ,1}; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color1); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color2); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_color3); glMaterialf(GL_FRONT, GL_SHININESS, 100); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); xCurrent %= 360; yCurrent %= 360; glRotated(yCurrent , 1, 0, 0); glRotated(xCurrent , 0, 0, 1); glRotated(180, 0, 1, 0); glTranslated(0, -130, 0); // your composite obejct here //layers = 26; float x[layers] = {0,9.72,16.84,18.42,18.42,18.42,18.42,18.27,17.8,16.03,12.81,11.03,10.06,9.04,8.46,7.84,7.84,7.84,7.84,7.84,7.84,11.22,11.61,11.15,11,7.77,4.66,0}; float y[layers] = {259.1,259.08,257.05,253.49,250.39,234.33,165.5,156.2,148.23,123.23,107.11,100.35,95.68,89.72,83.93,70.71,64.96,42.21,24.83,10,9.94,9.72,7.3,5.74,3.55,1.07,0.23,0}; // int n = 20; float vertices[n*layers*2*3]; int count = 0; for (int i=0;i