Files Classes Functions Hierarchy
00001 #include <commandline.h> 00002 #include <desys.h> 00003 #include <desystestspring2.h> 00004 #include <gobj.h> 00005 #include <graphmisc.h> 00006 #include <helixtest.h> 00007 #include <helix.h> 00008 #include <nintegration.h> 00009 #include <singleton.h> 00010 #include <springlineardraw.h> 00011 #include <typedefs.h> 00012 #include <zpr.h> 00013 00014 namespace helixtestscope 00015 { 00016 00017 typedef nintegrationRK< desystestspring2, double > integrator; 00018 typedef desys< integrator, double > sys; 00019 typedef Singleton< sys > sysptr; 00020 00021 gobjContainer helixtestxGraphics; 00022 00023 framerate<> fr(.1,.05); 00024 00025 void helixtest::display01() 00026 { 00027 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00028 00029 gobj::global->draw(); 00030 00031 //cout << "displaying framerate." << endl; 00032 // glColor3f(0.0,0.0,1.0); 00033 fr.display(); 00034 00035 glerrordisplay(); 00036 00037 glutSwapBuffers(); 00038 } 00039 00040 void helixtest::keyboard01(unsigned char key, int x, int y) 00041 { 00042 switch (key) 00043 { 00044 case 27: 00045 exit(0); 00046 break; 00047 } 00048 } 00049 00050 void helixtest::test01(int argc, char** argv) 00051 { 00052 glutInit(&argc,argv); 00053 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00054 glutInitWindowSize(600,600); 00055 glutCreateWindow(""); 00056 glutDisplayFunc(helixtest::display01); 00057 glutKeyboardFunc(helixtest::keyboard01); 00058 00059 OpenGLinitialisation(); 00060 00061 glEnable(GL_DEPTH_TEST); 00062 glEnable(GL_CULL_FACE); 00063 glEnable(GL_NORMALIZE); 00064 00065 helixtestxGraphics.set(); 00066 00067 commandline cmd(argc,argv); 00068 00069 gobjpush(new gobjglPushAttrib(GL_CURRENT_BIT)); 00070 gobjpush(new gobjglDisable(GL_LIGHTING)); 00071 gobjpush(new gobjglColor3f(1.0,0.0,0.0)); 00072 gobjpush(new helix(1.5,100,2.0,0.5)); 00073 gobjpush(new gobjglPopAttrib()); 00074 00075 zpr zz; 00076 00077 camera::lookatxz(cmd,1.0); 00078 00079 glutMainLoop(); 00080 } 00081 00082 void helixtest::test02(int argc, char** argv) 00083 { 00084 glutInit(&argc,argv); 00085 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00086 int wx=600; 00087 int wy=600; 00088 glutInitWindowSize(wx,wy); 00089 glutCreateWindow(""); 00090 glutDisplayFunc(helixtest::display01); 00091 glutKeyboardFunc(helixtest::keyboard01); 00092 00093 OpenGLinitialisation(); 00094 00095 glEnable(GL_DEPTH_TEST); 00096 glEnable(GL_CULL_FACE); 00097 glEnable(GL_NORMALIZE); 00098 00099 helixtestxGraphics.set(); 00100 00101 springlineardraw & sd = * new springlineardraw(2,0.5,1.5,100); 00102 sd.springcolor = point3<double>(0.96,.01,0.2); 00103 sd.lengths[0]=2.0; 00104 sd.lengths[1]=1.5; 00105 sd.lengths[2]=0.8; 00106 00107 sd.quadric.slices=40; 00108 sd.quadric.loops=10; 00109 00110 gobjpush((gobj*)&sd); 00111 00112 commandline cmd(argc,argv); 00113 cmd.mapvar(sd.lengths[0],"l0"); 00114 cmd.mapvar(sd.lengths[1],"l1"); 00115 cmd.mapvar(sd.lengths[2],"l2"); 00116 00117 cmd.mapvar(sd.xoffsets[0],"x0"); 00118 cmd.mapvar(sd.xoffsets[1],"x1"); 00119 00120 zpr zz; 00121 00122 camera::lookatxz(cmd,2.0,4.0); 00123 00124 glutMainLoop(); 00125 } 00126 00127 void helixtest::keyboard03(unsigned char key, int x, int y) 00128 { 00129 switch (key) 00130 { 00131 case 27: 00132 exit(0); 00133 break; 00134 00135 case '-': 00136 if (sysptr::ptr!=0) 00137 { 00138 sysptr::ptr->hstep /= 2.0; 00139 } 00140 break; 00141 00142 case '+': 00143 if (sysptr::ptr!=0) 00144 { 00145 sysptr::ptr->hstep *= 2.0; 00146 } 00147 break; 00148 } 00149 } 00150 00151 void helixtest::idle03() 00152 { 00153 fr.update(); 00154 00155 sys* pde = sysptr::ptr; 00156 if (pde==0) 00157 return; 00158 00159 pde->eval(); 00160 00161 uintc sample=30; 00162 static uint counter; 00163 ++counter; 00164 if ((counter % sample)==0) 00165 { 00166 springlineardraw * sp = Singleton<springlineardraw>::ptr; 00167 assert(sp!=0); 00168 00169 if (sp!=0) 00170 { 00171 sp->xoffsets[0] = pde->yiGet(0,0); 00172 sp->xoffsets[1] = pde->yiGet(1,0); 00173 } 00174 00175 glutPostRedisplay(); 00176 } 00177 00178 // if (Singleton<helixtestspring2plotter>::ptr!=0) 00179 // Singleton<helixtestspring2plotter>::ptr->add(); 00180 00181 } 00182 00183 void helixtest::test03(int argc, char** argv) 00184 { 00185 glutInit(&argc,argv); 00186 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00187 int const wx=500; 00188 int const wy=500; 00189 glutInitWindowSize(wx,wy); 00190 glutCreateWindow(""); 00191 glutDisplayFunc(helixtest::display01); 00192 glutKeyboardFunc(helixtest::keyboard03); 00193 glutIdleFunc(helixtest::idle03); 00194 00195 OpenGLinitialisation(); 00196 00197 glEnable(GL_DEPTH_TEST); 00198 glEnable(GL_CULL_FACE); 00199 glEnable(GL_NORMALIZE); 00200 00201 helixtestxGraphics.set(); 00202 00203 springlineardraw & sd = 00204 * new springlineardraw(2,0.5,1.5,100); 00205 00206 Singleton<springlineardraw>::ptr = &sd; 00207 sd.springcolor = point3<double>(0.96,.01,0.2); 00208 sd.lengths[0]=4.0; 00209 sd.lengths[1]=6.5; 00210 sd.lengths[2]=3.5; 00211 00212 sd.quadric.slices=40; 00213 sd.quadric.loops=10; 00214 00215 gobjpush((gobj*)&sd); 00216 00217 commandline cmd(argc,argv); 00218 cmd.mapvar(sd.lengths[0],"l0"); 00219 cmd.mapvar(sd.lengths[1],"l1"); 00220 cmd.mapvar(sd.lengths[2],"l2"); 00221 00222 cmd.mapvar(sd.xoffsets[0],"x0"); 00223 cmd.mapvar(sd.xoffsets[1],"x1"); 00224 00225 sys de(2,2); 00226 sysptr::ptr = &de; 00227 00228 double w0=0.0; 00229 double w1=0.0; 00230 double Dw0=1.0; 00231 double Dw1=1.0; 00232 double h=0.01; 00233 00234 cmd.mapvar(w0,"w0"); 00235 cmd.mapvar(Dw0,"Dw0"); 00236 cmd.mapvar(w1,"w1"); 00237 cmd.mapvar(Dw1,"Dw1"); 00238 cmd.mapvar(h,"h"); 00239 00240 de.yiGet(0,0)=w0; 00241 de.yiGet(0,1)=Dw0; 00242 de.yiGet(1,0)=w1; 00243 de.yiGet(1,1)=Dw1; 00244 de.hstep=h; 00245 00246 double k0=0.1; 00247 double k1=0.3; 00248 double k2=0.2; 00249 00250 cmd.mapvar(k0,"k0"); 00251 cmd.mapvar(k1,"k1"); 00252 cmd.mapvar(k2,"k2"); 00253 de.integrator.yDorder.ki[0] = k0; 00254 de.integrator.yDorder.ki[1] = k1; 00255 de.integrator.yDorder.ki[2] = k2; 00256 00257 /* 00258 helixtestspring2plotter* plot = 00259 new helixtestspring2plotter(&de.yiGet(0,0),&de.yiGet(1,0),500,10.0); 00260 00261 Singleton<helixtestspring2plotter>::ptr = plot; 00262 gobjpush(plot); 00263 00264 sd.masscolor[0] = plot->col0; 00265 sd.masscolor[1] = plot->col1; 00266 */ 00267 00268 zpr zz; 00269 zz.update(); 00270 00271 camera::lookatxz(cmd,4.0,4.0); 00272 00273 glutMainLoop(); 00274 } 00275 00276 } 00277
1.5.8