proj home

Files   Classes   Functions   Hierarchy  

triangles3Tdisplay.h

Go to the documentation of this file.
00001 #ifndef TRIANGLES3TDISPLAY_H
00002 #define TRIANGLES3TDISPLAY_H
00003 
00004 #include <GL/glut.h>
00005 
00006 #include <print.h>
00007 #include <point.h>
00008 #include <gobj.h>
00009 #include <OpenGLtemplated.h>
00010 
00011 
00012 
00013 
00022 template< typename T, typename W >
00023 class triangles3Tdisplay : public gobj
00024 {
00025 public:
00026 
00028   uint visize;
00029 
00031   point3<uint> const * vi;
00032 
00034   point3<W> const * pts;
00035 
00037   triangles3Tdisplay
00038   (
00039     uintc visize_, 
00040     point3<uint> const * vi_,
00041     point3<W> const * pts_
00042   )
00043     : visize(visize_), vi(vi_), pts(pts_) {}
00044 
00046   void draw()
00047   {
00048     GOBJDEBUGCODE
00049     point3<uint> const * t;
00050     glBegin(GL_TRIANGLES);
00051     for (uint i=0; i<visize; ++i)
00052     {
00053       t = & vi[i];
00054       point3<W> const & p0( pts[t->x] );
00055       glVertex3T<T>()(p0.x,p0.y,p0.z);
00056       point3<W> const & p1( pts[t->y] );
00057       glVertex3T<T>()(p1.x,p1.y,p1.z);
00058       point3<W> const & p2( pts[t->z] );
00059       glVertex3T<T>()(p2.x,p2.y,p2.z);
00060     }
00061 
00062     glEnd();
00063   }
00064 
00065 };
00066 
00067 
00068 
00069 
00070 
00075 template< typename T, typename W >
00076 class triangles3TdisplayN : public triangles3Tdisplay<T,W>
00077 {
00078 public:
00079 
00081   point3<W> const * normals;
00082 
00084   triangles3TdisplayN
00085   (
00086     uintc visize_, 
00087     point3<uint> const * vi_,
00088     point3<W> const * pts_,
00089     point3<W> const * normals_
00090   )
00091     : triangles3Tdisplay<T,W>(visize_,vi_,pts_), 
00092     normals(normals_) {}
00093 
00095   void draw()
00096   {
00097     GOBJDEBUGCODE
00098     point3<uint> const * t;
00099     glBegin(GL_TRIANGLES);
00100     for (uint i=0; i<triangles3Tdisplay<T,W>::visize; ++i)
00101     {
00102       t = & triangles3Tdisplay<T,W>::vi[i];
00103 
00104       point3<W> const & n0( normals[t->x] );
00105       glNormal3T<T>()(n0.x,n0.y,n0.z);
00106       point3<W> const & p0( triangles3Tdisplay<T,W>::pts[t->x] );
00107       glVertex3T<T>()(p0.x,p0.y,p0.z);
00108 
00109       point3<W> const & n1( normals[t->y] );
00110       glNormal3T<T>()(n1.x,n1.y,n1.z);
00111       point3<W> const & p1( triangles3Tdisplay<T,W>::pts[t->y] );
00112       glVertex3T<T>()(p1.x,p1.y,p1.z);
00113 
00114       point3<W> const & n2( normals[t->z] );
00115       glNormal3T<T>()(n2.x,n2.y,n2.z);
00116       point3<W> const & p2( triangles3Tdisplay<T,W>::pts[t->z] );
00117       glVertex3T<T>()(p2.x,p2.y,p2.z);
00118     }
00119 
00120     glEnd();
00121   }
00122 
00123 };
00124 
00125 
00126 
00131 template< typename T, typename W, typename C >
00132 class triangles3TdisplayNC : public triangles3Tdisplay<T,W>
00133 {
00134 public:
00135 
00137   point3<W> const * normals;
00138 
00140   point3<C> const * colors;
00141 
00143   triangles3TdisplayNC
00144   (
00145     uintc visize_, 
00146     point3<uint> const * vi_,
00147     point3<W> const * pts_,
00148     point3<W> const * normals_,
00149     point3<C> const * colors_
00150   )
00151     : triangles3Tdisplay<T,W>(visize_,vi_,pts_), 
00152     normals(normals_), colors(colors_) {}
00153 
00155   void draw()
00156   {
00157     GOBJDEBUGCODE
00158     point3<uint> const * t;
00159     glBegin(GL_TRIANGLES);
00160     for (uint i=0; i<triangles3Tdisplay<T,W>::visize; ++i)
00161     {
00162       t = & triangles3Tdisplay<T,W>::vi[i];
00163 
00164       uintc k0(t->x);
00165       point3<C> const & c0(colors[k0]);
00166       glColor3T<C>()(c0.x,c0.y,c0.z);
00167       point3<W> const & n0( normals[k0] );
00168       glNormal3T<T>()(n0.x,n0.y,n0.z);
00169       point3<W> const & p0( triangles3Tdisplay<T,W>::pts[k0] );
00170       glVertex3T<T>()(p0.x,p0.y,p0.z);
00171 
00172       uintc k1(t->y);
00173       point3<C> const & c1(colors[k1]);
00174       glColor3T<C>()(c1.x,c1.y,c1.z);
00175       point3<W> const & n1( normals[k1] );
00176       glNormal3T<T>()(n1.x,n1.y,n1.z);
00177       point3<W> const & p1( triangles3Tdisplay<T,W>::pts[k1] );
00178       glVertex3T<T>()(p1.x,p1.y,p1.z);
00179 
00180       uintc k2(t->z);
00181       point3<C> const & c2(colors[k2]);
00182       glColor3T<C>()(c2.x,c2.y,c2.z);
00183       point3<W> const & n2( normals[k2] );
00184       glNormal3T<T>()(n2.x,n2.y,n2.z);
00185       point3<W> const & p2( triangles3Tdisplay<T,W>::pts[k2] );
00186       glVertex3T<T>()(p2.x,p2.y,p2.z);
00187     }
00188 
00189     glEnd();
00190   }
00191 
00192 };
00193 
00194 
00195 
00200 template< typename T, typename W, typename C >
00201 class triangles3TdisplayNCpertriangle 
00202   : public triangles3Tdisplay<T,W>
00203 {
00204 public:
00205 
00207   point3<W> const * normals;
00208 
00210   point3<C> const * colors;
00211 
00213   triangles3TdisplayNCpertriangle
00214   (
00215     uintc visize_, 
00216     point3<uint> const * vi_,
00217     point3<W> const * pts_,
00218     point3<W> const * normals_,
00219     point3<C> const * colors_
00220   )
00221     : triangles3Tdisplay<T,W>(visize_,vi_,pts_), 
00222     normals(normals_), colors(colors_) {}
00223 
00225   void draw()
00226   {
00227     GOBJDEBUGCODE
00228     point3<uint> const * t;
00229     glBegin(GL_TRIANGLES);
00230     for (uint i=0; i<triangles3Tdisplay<T,W>::visize; ++i)
00231     {
00232       point3<C> const & c0(colors[i]);
00233       glColor3T<C>()(c0.x,c0.y,c0.z);
00234 
00235       t = & triangles3Tdisplay<T,W>::vi[i];
00236 
00237       uintc k0(t->x);
00238       point3<W> const & n0( normals[k0] );
00239       glNormal3T<T>()(n0.x,n0.y,n0.z);
00240       point3<W> const & p0( triangles3Tdisplay<T,W>::pts[k0] );
00241       glVertex3T<T>()(p0.x,p0.y,p0.z);
00242 
00243       uintc k1(t->y);
00244       point3<W> const & n1( normals[k1] );
00245       glNormal3T<T>()(n1.x,n1.y,n1.z);
00246       point3<W> const & p1( triangles3Tdisplay<T,W>::pts[k1] );
00247       glVertex3T<T>()(p1.x,p1.y,p1.z);
00248 
00249       uintc k2(t->z);
00250       point3<W> const & n2( normals[k2] );
00251       glNormal3T<T>()(n2.x,n2.y,n2.z);
00252       point3<W> const & p2( triangles3Tdisplay<T,W>::pts[k2] );
00253       glVertex3T<T>()(p2.x,p2.y,p2.z);
00254     }
00255 
00256     glEnd();
00257   }
00258 
00259 };
00260 
00261 
00262 
00263 
00264 
00265 
00269 template< typename T, typename W, typename C >
00270 class triangles3TdisplayCpertriangle : public triangles3Tdisplay<T,W>
00271 {
00272 public:
00273 
00275   point3<C> const * colors;
00276 
00278   triangles3TdisplayCpertriangle
00279   (
00280     uintc visize_, 
00281     point3<uint> const * vi_,
00282     point3<W> const * pts_,
00283     point3<W> const * colors_
00284   )
00285     : triangles3Tdisplay<T,W>(visize_,vi_,pts_), 
00286     colors(colors_) {}
00287 
00289   void draw()
00290   {
00291     GOBJDEBUGCODE
00292     point3<uint> const * t;
00293     glBegin(GL_TRIANGLES);
00294     for (uint i=0; i<triangles3Tdisplay<T,W>::visize; ++i)
00295     {
00296       point3<C> const & c0(colors[i]);
00297       glColor3T<C>()(c0.x,c0.y,c0.z);
00298 
00299       t = & triangles3Tdisplay<T,W>::vi[i];
00300 
00301       point3<W> const & p0( triangles3Tdisplay<T,W>::pts[t->x] );
00302       glVertex3T<T>()(p0.x,p0.y,p0.z);
00303 
00304       point3<W> const & p1( triangles3Tdisplay<T,W>::pts[t->y] );
00305       glVertex3T<T>()(p1.x,p1.y,p1.z);
00306 
00307       point3<W> const & p2( triangles3Tdisplay<T,W>::pts[t->z] );
00308       glVertex3T<T>()(p2.x,p2.y,p2.z);
00309     }
00310 
00311     glEnd();
00312   }
00313 
00314 };
00315 
00316 
00317 
00318 
00319 #endif
00320 
00321 

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