proj home

Files   Classes   Functions   Hierarchy  

triangles3Tdisplaytest Class Reference

Test class for triangle3Tdisplay classes. More...

#include <triangles3Tdisplaytest.h>

Collaboration diagram for triangles3Tdisplaytest:

List of all members.

Public Member Functions

 triangles3Tdisplaytest ()
 Constructor.
void test01 (int argc, char **argv)
 Test faceted triangles display.
void test02 (int argc, char **argv)
 Test PN point and normal triangles.
void test03 (int argc, char **argv)
 Test PNC point, normal and color at each vertex triangles.
void test04 (int argc, char **argv)
 Test PN point and normal triangles with a color at each triangle.
void test05 (int argc, char **argv)
 Test PCpertriangle where each triangle is drawn in a color.
void pipe01 (uintc n, vector< point3< uint > > &tri, vector< point3< double > > &pts)
 Faceted cylinder pipe.
void pipe02 (uintc n, vector< point3< uint > > &tri, vector< point3< double > > &pts, vector< point3< double > > &normals)
 Cylinder pipe with normals.

Static Public Member Functions

static void display01 ()
 Redraw the scene.
static void keyboard01 (unsigned char key, int x, int y)
 ESC key to quit application.


Detailed Description

Test class for triangle3Tdisplay classes.

Definition at line 12 of file triangles3Tdisplaytest.h.


Constructor & Destructor Documentation

triangles3Tdisplaytest::triangles3Tdisplaytest (  ) 

Constructor.

Definition at line 17 of file triangles3Tdisplaytest.cpp.

00018   : xGraphics(true)
00019 {
00020 }


Member Function Documentation

void triangles3Tdisplaytest::display01 (  )  [static]

Redraw the scene.

Definition at line 67 of file triangles3Tdisplaytest.cpp.

References gobjContainer::draw(), glerrordisplay(), and gobj::global.

Referenced by test01(), test02(), test03(), test04(), and test05().

00068 {
00069   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00070 
00071   gobj::global->draw();
00072 
00073   glerrordisplay();
00074   
00075   glutSwapBuffers();
00076 }

void triangles3Tdisplaytest::keyboard01 ( unsigned char  key,
int  x,
int  y 
) [static]

ESC key to quit application.

Definition at line 78 of file triangles3Tdisplaytest.cpp.

Referenced by test01(), test02(), test03(), test04(), and test05().

00079 {
00080   switch (key)
00081   {
00082     case 27:
00083       exit(0);
00084       break;
00085   }
00086 }

void triangles3Tdisplaytest::pipe01 ( uintc  n,
vector< point3< uint > > &  tri,
vector< point3< double > > &  pts 
)

Faceted cylinder pipe.

Definition at line 23 of file triangles3Tdisplaytest.cpp.

References pts.

Referenced by test01(), and test05().

00028 {
00029   uint pts0 = pts.size();
00030   doublec pi(3.141592654);
00031 
00032   assert(n>1);
00033   double angle = pi*2.0/ (double)n;
00034 
00035   for (uint i=0; i<n; ++i)
00036   {
00037     pts.push_back
00038     ( 
00039       point3<double>
00040       ( 
00041         cos(angle*(double)i), 
00042         0.0,
00043         sin(angle*(double)i) 
00044       )
00045     );
00046   }
00047 
00048   for (uint i=0; i<n; ++i)
00049   {
00050     pts.push_back
00051     ( 
00052       point3<double>( pts[pts0+i].x, 1.0, pts[pts0+i].z)
00053     );
00054   }
00055 
00056   for (uint i=1; i<n; ++i)
00057     tri.push_back( point3<uint>(pts0+i-1, pts0+i-1+n, pts0+i) );
00058   tri.push_back( point3<uint>(pts0+n-1, pts0+n-1+n, pts0) );
00059 
00060   for (uint i=1; i<n; ++i)
00061     tri.push_back( point3<uint>(pts0+i-1+n, pts0+i+n, pts0+i) );
00062   tri.push_back( point3<uint>(pts0+n-1+n, pts0+n, pts0) );
00063 }

void triangles3Tdisplaytest::pipe02 ( uintc  n,
vector< point3< uint > > &  tri,
vector< point3< double > > &  pts,
vector< point3< double > > &  normals 
)

Cylinder pipe with normals.

Definition at line 139 of file triangles3Tdisplaytest.cpp.

References pts.

Referenced by test02(), test03(), and test04().

00145 {
00146   uint pts0 = pts.size();
00147   doublec pi(3.141592654);
00148 
00149   assert(n>1);
00150   double angle = pi*2.0/ (double)n;
00151 
00152   for (uint i=0; i<n; ++i)
00153   {
00154     pts.push_back
00155     ( 
00156       point3<double>
00157       ( 
00158         cos(angle*(double)i), 
00159         0.0,
00160         sin(angle*(double)i) 
00161       )
00162     );
00163     normals.push_back( pts[pts0+i] );
00164   }
00165 
00166   for (uint i=0; i<n; ++i)
00167   {
00168     pts.push_back
00169     ( 
00170       point3<double>( pts[pts0+i].x, 1.0, pts[pts0+i].z)
00171     );
00172     normals.push_back( pts[pts0+i] );
00173   }
00174 
00175   for (uint i=1; i<n; ++i)
00176     tri.push_back( point3<uint>(pts0+i-1, pts0+i-1+n, pts0+i) );
00177   tri.push_back( point3<uint>(pts0+n-1, pts0+n-1+n, pts0) );
00178 
00179   for (uint i=1; i<n; ++i)
00180     tri.push_back( point3<uint>(pts0+i-1+n, pts0+i+n, pts0+i) );
00181   tri.push_back( point3<uint>(pts0+n-1+n, pts0+n, pts0) );
00182 }

void triangles3Tdisplaytest::test01 ( int  argc,
char **  argv 
)

Test faceted triangles display.

Mouse interaction.

Definition at line 88 of file triangles3Tdisplaytest.cpp.

References display01(), gobjpush, keyboard01(), commandline::mapvar(), pipe01(), print(), pts, and gobjContainer::set().

00089 {
00090   glutInit(&argc,argv);
00091   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00092   glutInitWindowSize(800,600);
00093   glutCreateWindow("");
00094   glutDisplayFunc(triangles3Tdisplaytest::display01);
00095   glutKeyboardFunc(triangles3Tdisplaytest::keyboard01);
00096 
00097   OpenGLinitialisation();
00098 
00099   glEnable(GL_DEPTH_TEST);
00100   glEnable(GL_CULL_FACE);
00101   glEnable(GL_NORMALIZE);
00102 
00103 
00104   xGraphics.set();
00105 
00106   vector< point3<double> > pts;
00107   vector< point3<uint> > tri;
00108 
00109   commandline cmd(argc,argv);
00110   uint n(80);
00111   cmd.mapvar(n,"n");
00112 
00113   pipe01(n,tri,pts);
00114 
00115   //gobjpush(new gobjglColor3ub(184,134,11) );
00116   gobjpush(new gobjglColor3ub(119,136,153) );
00117 
00118   triangles3Tdisplay<GLfloat,double> * tridisp =
00119     new triangles3Tdisplay<GLfloat,double>(tri.size(), & tri[0], & pts[0]);
00120   gobjpush(tridisp);
00121 
00122   cout << print(pts.begin(),pts.end(),"\n") << endl;
00123   //cout << printvecfunc(& pts[0],pts.size(),"\n") << endl;
00124   //cout << printvecfunc(tridisp->vi,tridisp->visize,"\n") << endl;
00125 
00126   //triangles3Tdisplay<> tridisp(tri.size(), & tri[0], & pts[0] );
00127   //gobjpush(&tridisp);
00128 
00129 
00130 
00132   zpr zz;
00133   glutMainLoop();
00134 }

void triangles3Tdisplaytest::test02 ( int  argc,
char **  argv 
)

Test PN point and normal triangles.

Mouse interaction.

Definition at line 187 of file triangles3Tdisplaytest.cpp.

References display01(), gobjpush, keyboard01(), commandline::mapvar(), pipe02(), pts, and gobjContainer::set().

00188 {
00189   glutInit(&argc,argv);
00190   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00191   glutInitWindowSize(800,600);
00192   glutCreateWindow("");
00193   glutDisplayFunc(triangles3Tdisplaytest::display01);
00194   glutKeyboardFunc(triangles3Tdisplaytest::keyboard01);
00195 
00196   OpenGLinitialisation();
00197 
00198   glEnable(GL_DEPTH_TEST);
00199   glEnable(GL_CULL_FACE);
00200   glEnable(GL_NORMALIZE);
00201 
00202 
00203   xGraphics.set();
00204 
00205   vector< point3<double> > pts;
00206   vector< point3<uint> > tri;
00207   vector< point3<double> > normals;
00208 
00209   commandline cmd(argc,argv);
00210   uint n(80);
00211   cmd.mapvar(n,"n");
00212 
00213   pipe02(n,tri,pts,normals);
00214 
00215   gobjpush(new gobjglColor3ub(119,136,153) );
00216   triangles3TdisplayN<GLfloat,double> * tridisp =
00217     new triangles3TdisplayN<GLfloat,double>(tri.size(), & tri[0], & pts[0], & normals[0]);
00218   gobjpush(tridisp);
00219 
00220 /*
00221   triangles3fdisplayN<> * tridisp =
00222     new triangles3fdisplayN<>(tri.size(), & tri[0], & pts[0], & normals[0]);
00223   gobjpush(tridisp);
00224 */
00225 
00226 /*
00227   cout << printvecfunc(& pts[0],pts.size(),"\n") << endl;
00228   //cout << printvecfunc(tridisp->vi,tridisp->visize,"\n") << endl;
00229 
00230   //triangles3fdisplay<> tridisp(tri.size(), & tri[0], & pts[0] );
00231   //gobjpush(&tridisp);
00232 */
00233 
00235   zpr zz;
00236   glutMainLoop();
00237 }

void triangles3Tdisplaytest::test03 ( int  argc,
char **  argv 
)

Test PNC point, normal and color at each vertex triangles.

Mouse interaction.

Definition at line 242 of file triangles3Tdisplaytest.cpp.

References display01(), gobjpush, keyboard01(), commandline::mapvar(), pipe02(), pts, r, and gobjContainer::set().

00243 {
00244   glutInit(&argc,argv);
00245   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00246   glutInitWindowSize(800,600);
00247   glutCreateWindow("");
00248   glutDisplayFunc(triangles3Tdisplaytest::display01);
00249   glutKeyboardFunc(triangles3Tdisplaytest::keyboard01);
00250 
00251   OpenGLinitialisation();
00252 
00253   glEnable(GL_DEPTH_TEST);
00254   glEnable(GL_CULL_FACE);
00255   glEnable(GL_NORMALIZE);
00256 
00257 
00258   xGraphics.set();
00259 
00260   vector< point3<double> > pts;
00261   vector< point3<uint> > tri;
00262   vector< point3<double> > normals;
00263   vector< point3<double> > colors;
00264 
00265   commandline cmd(argc,argv);
00266   uint n(80);
00267   cmd.mapvar(n,"n");
00268 
00269   pipe02(n,tri,pts,normals);
00270 
00271   random11<double> r;
00272   for (uint i=0; i<pts.size(); ++i)
00273     colors.push_back( point3<double>(r(),r(),r()) );
00274 
00275   //gobjpush(new gobjglColor3ub(119,136,153) );
00276   triangles3TdisplayNC<GLfloat,double,double> * tridisp =
00277     new triangles3TdisplayNC<GLfloat,double,double>
00278       (tri.size(), & tri[0], & pts[0], & normals[0], & colors[0]);
00279   gobjpush(tridisp);  
00280 
00282   zpr zz;
00283   glutMainLoop();
00284 }

void triangles3Tdisplaytest::test04 ( int  argc,
char **  argv 
)

Test PN point and normal triangles with a color at each triangle.

Mouse interaction.

Definition at line 287 of file triangles3Tdisplaytest.cpp.

References display01(), gobjpush, keyboard01(), commandline::mapvar(), pipe02(), pts, r, and gobjContainer::set().

00288 {
00289   glutInit(&argc,argv);
00290   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00291   glutInitWindowSize(800,600);
00292   glutCreateWindow("");
00293   glutDisplayFunc(triangles3Tdisplaytest::display01);
00294   glutKeyboardFunc(triangles3Tdisplaytest::keyboard01);
00295 
00296   OpenGLinitialisation();
00297 
00298   glEnable(GL_DEPTH_TEST);
00299   glEnable(GL_CULL_FACE);
00300   glEnable(GL_NORMALIZE);
00301 
00302 
00303   xGraphics.set();
00304 
00305   vector< point3<double> > pts;
00306   vector< point3<uint> > tri;
00307   vector< point3<double> > normals;
00308   vector< point3<double> > colors;
00309 
00310   commandline cmd(argc,argv);
00311   uint n(80);
00312   cmd.mapvar(n,"n");
00313 
00314   pipe02(n,tri,pts,normals);
00315 
00316   random11<double> r;
00317   for (uint i=0; i<tri.size(); ++i)
00318     colors.push_back( point3<double>(r(),r(),r()) );
00319 
00320   triangles3TdisplayNCpertriangle<GLfloat,double,double> * tridisp =
00321     new triangles3TdisplayNCpertriangle<GLfloat,double,double>
00322       (tri.size(), & tri[0], & pts[0], & normals[0], & colors[0]);
00323   gobjpush(tridisp);  
00324 
00326   zpr zz;
00327   glutMainLoop();
00328 }

void triangles3Tdisplaytest::test05 ( int  argc,
char **  argv 
)

Test PCpertriangle where each triangle is drawn in a color.

Mouse interaction.

Definition at line 332 of file triangles3Tdisplaytest.cpp.

References display01(), gobjpush, keyboard01(), commandline::mapvar(), pipe01(), pts, gobjContainer::set(), and zpr::update().

00333 {
00334   glutInit(&argc,argv);
00335   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00336   glutInitWindowSize(800,600);
00337   glutCreateWindow("");
00338   glutDisplayFunc(triangles3Tdisplaytest::display01);
00339   glutKeyboardFunc(triangles3Tdisplaytest::keyboard01);
00340 
00341   OpenGLinitialisation();
00342 
00343   glEnable(GL_DEPTH_TEST);
00344   glEnable(GL_CULL_FACE);
00345   glEnable(GL_NORMALIZE);
00346 
00347   xGraphics.set();
00348 
00349   vector< point3<double> > pts;
00350   vector< point3<uint> > tri;
00351   vector< point3<double> > colors;
00352 
00353   commandline cmd(argc,argv);
00354   uint n(80);
00355   cmd.mapvar(n,"n");
00356 
00357   pipe01(n,tri,pts);
00358 
00359 /*
00360   random11<double> r;
00361   for (uint i=0; i<tri.size(); ++i)
00362     colors.push_back( point3<double>(r(),r(),r()) );
00363 
00364   triangles3TdisplayCpertriangle<GLfloat,double,double> * tridisp =
00365     new triangles3TdisplayCpertriangle<GLfloat,double,double>
00366       (tri.size(), & tri[0], & pts[0], & colors[0]);
00367   gobjpush(tridisp);  
00368 */
00369 
00370   triangles3Tdisplaymulticolored<GLfloat,double> * tridisp =
00371     new triangles3Tdisplaymulticolored<GLfloat,double>
00372       (tri.size(), & tri[0], & pts[0]);
00373   gobjpush(tridisp);
00374 
00376   zpr zz;
00377   zz.update();
00378   glutMainLoop();
00379 }


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:22 2011 for Chelton Evans Source by  doxygen 1.5.8