Files Classes Functions Hierarchy
00001 #include <iostream> 00002 using namespace std; 00003 00004 #include <GL/gl.h> 00005 00006 #include <graphmisc.h> 00007 #include <vrmlshape.h> 00008 00009 00010 #ifndef NDEBUG 00011 //#define DEBUG_VRMLSHAPE 00012 #endif 00013 00014 00015 00016 void vrmllines::writeP() const 00017 { 00018 assert((point.size()%6)==0); 00019 00020 myLightingTurnOff temp; 00021 00022 uintc imax = point.size(); 00023 glBegin(GL_LINES); 00024 for (uint i=0; i<imax; i+=6) 00025 { 00026 glVertex3f(point[i],point[i+1],point[i+2]); 00027 glVertex3f(point[i+3],point[i+4],point[i+5]); 00028 } 00029 glEnd(); 00030 } 00031 00032 00033 void vrmllines::writePC() const 00034 { 00035 assert(point.size()==color.size()); 00036 assert((point.size()%6)==0); 00037 00038 myLightingTurnOff temp; 00039 00040 uintc imax = point.size(); 00041 glBegin(GL_LINES); 00042 for (uint i=0; i<imax; i+=6) 00043 { 00044 glColor3f(color[i],color[i+1],color[i+2]); 00045 glVertex3f(point[i],point[i+1],point[i+2]); 00046 glColor3f(color[i+3],color[i+4],color[i+5]); 00047 glVertex3f(point[i+3],point[i+4],point[i+5]); 00048 } 00049 glEnd(); 00050 } 00051 00052 00053 ostream & vrmlshape::print( ostream & os ) const 00054 { 00055 os << "diffuseColor: "; 00056 os << diffuseColor[0] << " "; 00057 os << diffuseColor[1] << " "; 00058 os << diffuseColor[2] << " "; 00059 os << endl; 00060 00061 os << "point:" << endl; 00062 00063 for (uint i=0; i<point.size(); ++i) 00064 { 00065 os << point[i] << " "; 00066 if ((i+1)%3==0) 00067 os << endl; 00068 } 00069 os << endl; 00070 00071 os << "normal:" << endl; 00072 00073 for (uint i=0; i<normal.size(); ++i) 00074 { 00075 os << normal[i] << " "; 00076 if ((i+1)%3==0) 00077 os << endl; 00078 } 00079 os << endl; 00080 00081 os << "color:" << endl; 00082 00083 for (uint i=0; i<color.size(); ++i) 00084 { 00085 os << color[i] << " "; 00086 if ((i+1)%3==0) 00087 os << endl; 00088 } 00089 os << endl; 00090 00091 return os; 00092 } 00093 00094 00095 void vrmlshape::diffuseColorWrite() const 00096 { 00097 assert(diffuseColor[0]>=0.0); 00098 00099 glColor3f 00100 ( 00101 diffuseColor[0], 00102 diffuseColor[1], 00103 diffuseColor[2] 00104 ); 00105 } 00106 00107 00108 void vrmlshape::writeP() const 00109 { 00110 uintc sz = point.size(); 00111 00112 if (sz==0) 00113 return; 00114 00115 //<TODO> look at this code, does writeP() word? 00116 glBegin(GL_LINES); 00117 // glBegin(GL_TRIANGLES); 00118 00119 diffuseColorWrite(); 00120 00121 assert((point.size()%3)==0); 00122 00123 for (uint i=0; i<sz; i+=9 ) 00124 { 00125 glVertex3f(point[i+0],point[i+1],point[i+2]); 00126 glVertex3f(point[i+3],point[i+4],point[i+5]); 00127 glVertex3f(point[i+3],point[i+4],point[i+5]); 00128 glVertex3f(point[i+6],point[i+7],point[i+8]); 00129 glVertex3f(point[i+6],point[i+7],point[i+8]); 00130 glVertex3f(point[i+0],point[i+1],point[i+2]); 00131 } 00132 00133 glEnd(); 00134 } 00135 00136 void vrmlshape::writePN() const 00137 { 00138 uintc sz = point.size(); 00139 00140 if (sz==0) 00141 return; 00142 00143 assert(sz==normal.size()); 00144 00145 00146 #ifdef DEBUG_VRMLSHAPE 00147 axes(0.25); 00148 #endif 00149 00150 00151 glBegin(GL_TRIANGLES); 00152 00153 diffuseColorWrite(); 00154 00155 for (uint i=0; i<sz; i+=3 ) 00156 { 00157 glNormal3f(normal[i],normal[i+1],normal[i+2]); 00158 glVertex3f(point[i],point[i+1],point[i+2]); 00159 } 00160 00161 glEnd(); 00162 } 00163 00164 void vrmlshape::writePNC() const 00165 { 00166 uintc sz = point.size(); 00167 00168 if (sz==0) 00169 return; 00170 00171 assert(sz==normal.size()); 00172 assert(sz==color.size()); 00173 00174 glBegin(GL_TRIANGLES); 00175 00176 for (uint i=0; i<sz; i+=3 ) 00177 { 00178 glNormal3f(normal[i],normal[i+1],normal[i+2]); 00179 glColor3f(color[i],color[i+1],color[i+2]); 00180 glVertex3f(point[i],point[i+1],point[i+2]); 00181 } 00182 00183 glEnd(); 00184 } 00185 00186 void vrmlshape::writePwind() const 00187 { 00188 uintc sz = point.size(); 00189 00190 if (sz==0) 00191 return; 00192 00193 glBegin(GL_TRIANGLES); 00194 00195 uint k; 00196 00197 for (uint i=0; i<sz; i+=3 ) 00198 { 00199 k = i/3; 00200 k %= 3; 00201 switch (k) 00202 { 00203 case 0: glColor3f(1.0,0.0,0.0); break; 00204 case 1: glColor3f(0.0,1.0,0.0); break; 00205 default: glColor3f(0.0,0.0,1.0); break; 00206 } 00207 00208 glVertex3f(point[i],point[i+1],point[i+2]); 00209 } 00210 00211 glEnd(); 00212 } 00213 00214 00215 00216 00217
1.5.8