00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <QtOpenGL>
00029 #define BYTE unsigned char
00030
00031 namespace Enki
00032 {
00033
00034
00035
00036
00037
00038 static BYTE face_indicies[48][9] = {
00039
00040 {2,24,1 ,0,1,2 ,0,1,2 }, {2,25,24 ,0,3,1 ,0,3,1 }, {3,25,2 ,4,3,0 ,4,3,0 },
00041 {3,26,25 ,4,5,3 ,4,5,3 }, {4,26,3 ,6,5,4 ,6,5,4 }, {4,27,26 ,6,7,5 ,6,7,5 },
00042 {5,27,4 ,8,7,6 ,8,7,6 }, {5,28,27 ,8,9,7 ,8,9,7 }, {6,28,5 ,10,9,8 ,10,9,8 },
00043 {6,29,28 ,10,11,9 ,10,11,9 }, {7,29,6 ,12,11,10 ,12,11,10 },
00044 {7,30,29 ,12,13,11 ,12,13,11 }, {8,30,7 ,14,13,12 ,14,13,12 },
00045 {8,31,30 ,14,15,13 ,14,15,13 }, {9,31,8 ,16,15,14 ,16,15,14 },
00046 {9,32,31 ,16,17,15 ,16,17,15 }, {10,32,9 ,18,17,16 ,18,17,16 },
00047 {10,33,32 ,18,19,17 ,18,19,17 }, {11,33,10 ,20,19,18 ,20,19,18 },
00048 {11,34,33 ,20,21,19 ,20,21,19 }, {12,34,11 ,22,21,20 ,22,21,20 },
00049 {12,35,34 ,22,23,21 ,22,23,21 }, {13,35,12 ,24,23,22 ,24,23,22 },
00050 {13,36,35 ,24,25,23 ,24,25,23 }, {14,36,13 ,26,25,24 ,26,25,24 },
00051 {14,37,36 ,26,27,25 ,26,27,25 }, {15,37,14 ,28,27,26 ,28,27,26 },
00052 {15,38,37 ,28,29,27 ,28,29,27 }, {16,38,15 ,30,29,28 ,30,29,28 },
00053 {16,39,38 ,30,31,29 ,30,31,29 }, {17,39,16 ,32,31,30 ,32,31,30 },
00054 {17,40,39 ,32,33,31 ,32,33,31 }, {18,40,17 ,34,33,32 ,34,33,32 },
00055 {18,41,40 ,34,35,33 ,34,35,33 }, {19,41,18 ,36,35,34 ,36,35,34 },
00056 {19,42,41 ,36,37,35 ,36,37,35 }, {20,42,19 ,38,37,36 ,38,37,36 },
00057 {20,43,42 ,38,39,37 ,38,39,37 }, {21,43,20 ,40,39,38 ,40,41,42 },
00058 {21,44,43 ,40,41,39 ,40,43,41 }, {22,44,21 ,42,41,40 ,44,43,40 },
00059 {22,45,44 ,42,43,41 ,44,45,43 }, {23,45,22 ,44,43,42 ,46,45,44 },
00060 {23,46,45 ,44,45,43 ,46,47,45 }, {0,46,23 ,46,45,44 ,48,47,46 },
00061 {0,47,46 ,46,47,45 ,48,49,47 }, {1,47,0 ,2,47,46 ,2,49,48 },
00062 {1,24,47 ,2,1,47 ,2,1,49 }
00063 };
00064 static GLfloat vertices [48][3] = {
00065 {-0.0225f,-0.0389711f,0.00525f},{-0.0116469f,-0.0434667f,0.00525f},{0.0f,-0.045f,0.00525f},
00066 {0.0116469f,-0.0434667f,0.00525f},{0.0225f,-0.0389711f,0.00525f},{0.0318198f,-0.0318198f,0.00525f},
00067 {0.0389711f,-0.0225f,0.00525f},{0.0434667f,-0.0116469f,0.00525f},{0.045f,0.0f,0.00525f},
00068 {0.0434667f,0.0116469f,0.00525f},{0.0389711f,0.0225f,0.00525f},{0.0318198f,0.0318198f,0.00525f},
00069 {0.0225f,0.0389711f,0.00525f},{0.0116469f,0.0434667f,0.00525f},{0.0f,0.045f,0.00525f},
00070 {-0.0116469f,0.0434667f,0.00525f},{-0.0225f,0.0389711f,0.00525f},{-0.0318198f,0.0318198f,0.00525f},
00071 {-0.0389711f,0.0225f,0.00525f},{-0.0434667f,0.0116469f,0.00525f},{-0.045f,0.0f,0.00525f},
00072 {-0.0434667f,-0.0116469f,0.00525f},{-0.0389711f,-0.0225f,0.00525f},{-0.0318198f,-0.0318198f,0.00525f},
00073 {-0.0116469f,-0.0434667f,0.045875f},{0.0f,-0.045f,0.045875f},{0.0116469f,-0.0434667f,0.045875f},
00074 {0.0225f,-0.0389711f,0.045875f},{0.0318198f,-0.0318198f,0.045875f},{0.0389711f,-0.0225f,0.045875f},
00075 {0.0434667f,-0.0116469f,0.045875f},{0.045f,0.0f,0.045875f},{0.0434667f,0.0116469f,0.045875f},
00076 {0.0389711f,0.0225f,0.045875f},{0.0318198f,0.0318198f,0.045875f},{0.0225f,0.0389711f,0.045875f},
00077 {0.0116469f,0.0434667f,0.045875f},{0.0f,0.045f,0.045875f},{-0.0116469f,0.0434667f,0.045875f},
00078 {-0.0225f,0.0389711f,0.045875f},{-0.0318198f,0.0318198f,0.045875f},{-0.0389711f,0.0225f,0.045875f},
00079 {-0.0434667f,0.0116469f,0.045875f},{-0.045f,0.0f,0.045875f},{-0.0434667f,-0.0116469f,0.045875f},
00080 {-0.0389711f,-0.0225f,0.045875f},{-0.0318198f,-0.0318198f,0.045875f},{-0.0225f,-0.0389711f,0.045875f}
00081 };
00082 static GLfloat normals [48][3] = {
00083 {-0.0438419f,-0.999038f,0.0f},{-0.216222f,-0.976344f,0.0f},{-0.300918f,-0.95365f,0.0f},
00084 {0.0438419f,-0.999038f,0.0f},{0.216222f,-0.976344f,0.0f},{0.300918f,-0.95365f,0.0f},
00085 {0.461551f,-0.887114f,0.0f},{0.537487f,-0.843272f,0.0f},{0.675426f,-0.737428f,0.0f},
00086 {0.737428f,-0.675426f,0.0f},{0.843272f,-0.537487f,0.0f},{0.887114f,-0.461551f,0.0f},
00087 {0.95365f,-0.300918f,0.0f},{0.976344f,-0.216222f,0.0f},{0.999038f,-0.0438419f,0.0f},
00088 {0.999038f,0.0438419f,0.0f},{0.976344f,0.216222f,0.0f},{0.95365f,0.300918f,0.0f},
00089 {0.887114f,0.461551f,0.0f},{0.843272f,0.537487f,0.0f},{0.737428f,0.675426f,0.0f},
00090 {0.675426f,0.737428f,0.0f},{0.537487f,0.843272f,0.0f},{0.461551f,0.887114f,0.0f},
00091 {0.300918f,0.95365f,0.0f},{0.216222f,0.976344f,0.0f},{0.0438419f,0.999038f,0.0f},
00092 {-0.0438419f,0.999038f,0.0f},{-0.216222f,0.976344f,0.0f},{-0.300918f,0.95365f,0.0f},
00093 {-0.461551f,0.887114f,0.0f},{-0.537487f,0.843272f,0.0f},{-0.675426f,0.737428f,0.0f},
00094 {-0.737428f,0.675426f,0.0f},{-0.843272f,0.537487f,0.0f},{-0.887114f,0.461551f,0.0f},
00095 {-0.95365f,0.300918f,0.0f},{-0.976344f,0.216222f,0.0f},{-0.999038f,0.0438419f,0.0f},
00096 {-0.999038f,-0.0438419f,0.0f},{-0.976344f,-0.216222f,0.0f},{-0.95365f,-0.300918f,0.0f},
00097 {-0.887114f,-0.461551f,0.0f},{-0.843272f,-0.537487f,0.0f},{-0.737428f,-0.675426f,0.0f},
00098 {-0.675426f,-0.737428f,0.0f},{-0.537487f,-0.843272f,0.0f},{-0.461551f,-0.887114f,0.0f}
00099 };
00100 static GLfloat textures [50][2] = {
00101 {0.251939f,0.326379f},{0.210595f,0.428389f},{0.210595f,0.326379f},
00102 {0.251939f,0.428389f},{0.293282f,0.326379f},{0.293282f,0.428389f},
00103 {0.334626f,0.326379f},{0.334626f,0.428389f},{0.375969f,0.326379f},
00104 {0.375969f,0.428389f},{0.417313f,0.326379f},{0.417313f,0.428389f},
00105 {0.458656f,0.326379f},{0.458656f,0.428389f},{0.5f,0.326379f},
00106 {0.5f,0.428389f},{0.541343f,0.326379f},{0.541343f,0.428389f},
00107 {0.582687f,0.326379f},{0.582687f,0.428389f},{0.62403f,0.326379f},
00108 {0.62403f,0.428389f},{0.665374f,0.326379f},{0.665374f,0.428389f},
00109 {0.706717f,0.326379f},{0.706717f,0.428389f},{0.748061f,0.326379f},
00110 {0.748061f,0.428389f},{0.789404f,0.326379f},{0.789404f,0.428389f},
00111 {0.830748f,0.326379f},{0.830748f,0.428389f},{0.872092f,0.326379f},
00112 {0.872092f,0.428389f},{0.913435f,0.326379f},{0.913435f,0.428389f},
00113 {0.954778f,0.326379f},{0.954778f,0.428389f},{0.996122f,0.326379f},
00114 {0.996122f,0.428389f},{0.0452214f,0.326379f},{0.00387793f,0.427763f},
00115 {0.00387793f,0.326379f},{0.0452214f,0.428389f},{0.086565f,0.326379f},
00116 {0.086565f,0.428389f},{0.127908f,0.326379f},{0.127908f,0.428389f},
00117 {0.169252f,0.326379f},{0.169252f,0.428389f}
00118 };
00119
00120 GLint GenFeederRing()
00121 {
00122 GLint lid=glGenLists(1);
00123 glNewList(lid, GL_COMPILE);
00124
00125 glBegin (GL_TRIANGLES);
00126 for(size_t i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
00127 {
00128 for(size_t j=0;j<3;j++)
00129 {
00130 int vi=face_indicies[i][j];
00131 int ni=face_indicies[i][j+3];
00132 int ti=face_indicies[i][j+6];
00133
00134
00135
00136
00137
00138 glNormal3f (normals[ni][1],-normals[ni][0],normals[ni][2]);
00139 glTexCoord2f(textures[ti][0],textures[ti][1]);
00140 glVertex3f (100.f*vertices[vi][1],-100.f*vertices[vi][0],100.f*vertices[vi][2]);
00141 }
00142 }
00143 glEnd ();
00144
00145 glEndList();
00146 return lid;
00147 };
00148 }