proj home

Files   Classes   Functions   Hierarchy  

pointgrid3Ddraw.cpp

Go to the documentation of this file.
00001 #include <pointgrid3Ddraw.h>
00002 
00003 
00004 pointgrid3Ddraw::pointgrid3Ddraw(pointgrid3D const & _pg)
00005   : gobjContainer(true), pg(_pg)
00006 {
00007   displaypoints=true;
00008 
00009   quadric = new gobjQuadric();
00010   quadric->radius = 0.02;
00011   quadric->slices=20;
00012   quadric->loops=6;
00013 
00014   displayedges=true;
00015 
00016   update();
00017 }
00018 
00019 pointgrid3Ddraw::~pointgrid3Ddraw()
00020 {
00021   delete quadric;
00022 }
00023 
00024 void pointgrid3Ddraw::update()
00025 {
00026   nuke();
00027 
00028   push( new gobjglPushAttrib(GL_LIGHTING) );
00029   push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00030 
00031   if (displaypoints==true)
00032   {
00033     push(new gobjglEnable(GL_LIGHTING) );
00034     
00035     push( new gobjglColor3ub(0,255,0) );
00036     uintc sz = pg.M*pg.N;
00037     for (uint i=0; i<sz; ++i)
00038       push( new gobjMySphereDraw(pg.pt[i],quadric) );
00039   }
00040 
00041   if (displayedges==true)
00042   {
00043     push(new gobjglDisable(GL_LIGHTING) );
00044 
00045     push( new gobjglColor3ub(255,0,0) );
00046 
00047     uintc M = pg.M;
00048     uintc N = pg.N;
00049     uint r,k;
00050     push( new gobjglBegin(GL_LINE) ); 
00051 
00052     for (r=0; r<M; ++r)
00053     {
00054       for (k=1; k<N; ++k)
00055       {
00056         // Draw line pij(k-1,i) to pij(k,i)
00057         push( new gobjglVertex3f(pg.pij(k-1,r )) );
00058         push( new gobjglVertex3f(pg.pij(k,r )) );
00059       }
00060     }
00061 
00062     for (k=0; k<N; ++k)
00063     {
00064       for (r=1; r<M; ++r)
00065       {
00066         push( new gobjglVertex3f(pg.pij(k,r-1 )) );
00067         push( new gobjglVertex3f(pg.pij(k,r )) );
00068       }
00069     }
00070 
00071     push( new gobjglEnd() );
00072 
00073     push( new gobjglPopAttrib() );
00074     push( new gobjglPopAttrib() );
00075   }
00076 }
00077 
00078 

Generated on Fri Mar 4 00:49:25 2011 for Chelton Evans Source by  doxygen 1.5.8