Files Classes Functions Hierarchy
#include <helixtest.h>
Static Public Member Functions | |
| static void | test01 (int argc, char **argv) |
| Look at a static helix. | |
| static void | test02 (int argc, char **argv) |
| The static geometry 3 springs 2 masses. | |
| static void | test03 (int argc, char **argv) |
| Three springs two masses connected spring simulation. | |
| static void | display01 () |
| Display the global gobj stream and frame rate. | |
| static void | keyboard01 (unsigned char key, int x, int y) |
| Escape key terminates. | |
| static void | keyboard03 (unsigned char key, int x, int y) |
| Test 03 event (key) handling. | |
| static void | idle03 () |
| Drive the system state. | |
Definition at line 10 of file helixtest.h.
| void helixtestscope::helixtest::display01 | ( | ) | [static] |
Display the global gobj stream and frame rate.
Definition at line 25 of file helixtest.cpp.
References framerate< period >::display(), gobjContainer::draw(), helixtestscope::fr, glerrordisplay(), and gobj::global.
Referenced by test01(), test02(), and test03().
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 }
| void helixtestscope::helixtest::idle03 | ( | ) | [static] |
Drive the system state.
Definition at line 151 of file helixtest.cpp.
References desys< NINT, T >::eval(), helixtestscope::fr, Singleton< T >::ptr, framerate< period >::update(), springlineargeom::xoffsets, and desys< NINT, T >::yiGet().
Referenced by test03().
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 }
| void helixtestscope::helixtest::keyboard01 | ( | unsigned char | key, | |
| int | x, | |||
| int | y | |||
| ) | [static] |
Escape key terminates.
Definition at line 40 of file helixtest.cpp.
Referenced by test01(), and test02().
| void helixtestscope::helixtest::keyboard03 | ( | unsigned char | key, | |
| int | x, | |||
| int | y | |||
| ) | [static] |
Test 03 event (key) handling.
Definition at line 127 of file helixtest.cpp.
References Singleton< T >::ptr.
Referenced by test03().
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 }
| void helixtestscope::helixtest::test01 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Look at a static helix.
Definition at line 50 of file helixtest.cpp.
References display01(), gobjpush, helixtestscope::helixtestxGraphics, keyboard01(), camera::lookatxz(), and gobjContainer::set().
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 }
| void helixtestscope::helixtest::test02 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
The static geometry 3 springs 2 masses.
Definition at line 82 of file helixtest.cpp.
References display01(), gobjpush, helixtestscope::helixtestxGraphics, keyboard01(), springlineargeom::lengths, camera::lookatxz(), gobjQuadric::loops, commandline::mapvar(), springlineardraw::quadric, gobjContainer::set(), gobjQuadric::slices, and springlineardraw::springcolor.
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 }
| void helixtestscope::helixtest::test03 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Three springs two masses connected spring simulation.
Definition at line 183 of file helixtest.cpp.
References display01(), gobjpush, helixtestscope::helixtestxGraphics, desys< NINT, T >::hstep, idle03(), desys< NINT, T >::integrator, keyboard03(), springlineargeom::lengths, camera::lookatxz(), gobjQuadric::loops, commandline::mapvar(), Singleton< T >::ptr, springlineardraw::quadric, gobjContainer::set(), gobjQuadric::slices, springlineardraw::springcolor, zpr::update(), and desys< NINT, T >::yiGet().
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 }
1.5.8