basic/opengl/GL_Cylinder.cpp

Go to the documentation of this file.
00001 //## begin module%3856BCE3012A.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%3856BCE3012A.cm
00004 
00005 //## begin module%3856BCE3012A.cp preserve=no
00006 //## end module%3856BCE3012A.cp
00007 
00008 //## Module: GL_Cylinder%3856BCE3012A; Pseudo Package body
00009 //## Source file: C:\project\mpk\code\OpenGL\GL_Cylinder.cpp
00010 
00011 //## begin module%3856BCE3012A.additionalIncludes preserve=no
00012 //## end module%3856BCE3012A.additionalIncludes
00013 
00014 //## begin module%3856BCE3012A.includes preserve=yes
00015 #include <assert.h>
00016 #include "glos.h"
00017 #include <gl/glu.h>
00018 #include <math.h>
00019 #include <math/math2.h>
00020 #include <math/vector4.h>
00021 //## end module%3856BCE3012A.includes
00022 
00023 // GL_Cylinder
00024 #include "OpenGL\GL_Cylinder.h"
00025 //## begin module%3856BCE3012A.additionalDeclarations preserve=yes
00026 //## end module%3856BCE3012A.additionalDeclarations
00027 
00028 
00029 // Class GL_Cylinder 
00030 
00031 
00032 
00033 
00034 GL_Cylinder::GL_Cylinder (FrameManager* frameManager)
00035   //## begin GL_Cylinder::GL_Cylinder%945198452.hasinit preserve=no
00036       : slices(10), stacks(3), rings(3)
00037   //## end GL_Cylinder::GL_Cylinder%945198452.hasinit
00038   //## begin GL_Cylinder::GL_Cylinder%945198452.initialization preserve=yes
00039   ,MPK_Cylinder( frameManager )
00040   //## end GL_Cylinder::GL_Cylinder%945198452.initialization
00041 {
00042   //## begin GL_Cylinder::GL_Cylinder%945198452.body preserve=yes
00043   //## end GL_Cylinder::GL_Cylinder%945198452.body
00044 }
00045 
00046 GL_Cylinder::GL_Cylinder (const GL_Cylinder& right)
00047   //## begin GL_Cylinder::GL_Cylinder%945198453.hasinit preserve=no
00048       : slices(10), stacks(3), rings(3)
00049   //## end GL_Cylinder::GL_Cylinder%945198453.hasinit
00050   //## begin GL_Cylinder::GL_Cylinder%945198453.initialization preserve=yes
00051   ,MPK_Cylinder( right )
00052   //## end GL_Cylinder::GL_Cylinder%945198453.initialization
00053 {
00054   //## begin GL_Cylinder::GL_Cylinder%945198453.body preserve=yes
00055   //## end GL_Cylinder::GL_Cylinder%945198453.body
00056 }
00057 
00058 
00059 GL_Cylinder::~GL_Cylinder()
00060 {
00061   //## begin GL_Cylinder::~GL_Cylinder%.body preserve=yes
00062   //## end GL_Cylinder::~GL_Cylinder%.body
00063 }
00064 
00065 
00066 
00067 //## Other Operations (implementation)
00068 Entity* GL_Cylinder::Clone () const
00069 {
00070   //## begin GL_Cylinder::Clone%945198442.body preserve=yes
00071         return new GL_Cylinder( *this ) ;
00072   //## end GL_Cylinder::Clone%945198442.body
00073 }
00074 
00075 bool GL_Cylinder::DrawExplicit () const
00076 {
00077   //## begin GL_Cylinder::DrawExplicit%950474930.body preserve=yes
00078         glPushMatrix() ;
00079 
00080                 //improve this is the wrong matrix style
00081                 Matrix4x4 intermediate = theFrame ;
00082                 Matrix4x4 transpose = intermediate.Transpose() ;
00083                 ::glMultMatrixd( ( const double* )( transpose.values ) ) ;
00084                 
00085                 double rootThree = sqrt( 3.0 ) ;
00086                 glRotated( -360 / 3.0, rootThree, rootThree, rootThree ) ;
00087 
00088                 //VRML defines cylinders about their center, but OPENgl draws them from the base 
00089                 //so draw them accordingly
00090                 glTranslated( 0, 0, -this->height / 2.0 ) ;
00091 
00092 
00093                 //cap 1
00094                 glPushMatrix() ;
00095                         GLUquadricObj* cap1 = gluNewQuadric() ;
00096                         gluQuadricDrawStyle( cap1, GLU_FILL ) ;
00097                         gluQuadricNormals( cap1, GLU_SMOOTH ) ;
00098                         glRotated( 180.0, 1.0, 0.0, 0.0 ) ;
00099                         gluDisk( cap1, 0, radius, 10, 3 ) ;                     //IMPROVE: fix the slices/rings
00100                 glPopMatrix() ;
00101 
00102                 //cap 2
00103                 glPushMatrix() ;
00104                         glTranslated( 0, 0, height ) ;
00105                         GLUquadricObj* cap2 = gluNewQuadric() ;
00106                         gluQuadricDrawStyle( cap2, GLU_FILL ) ;
00107                         gluQuadricNormals( cap2, GLU_SMOOTH ) ;
00108                         gluDisk( cap2, 0, radius, 10, 3 ) ;                     //IMPROVE: fix the slices/rings
00109                 glPopMatrix() ;
00110 
00111                 //body
00112                 GLUquadricObj* qobj = gluNewQuadric() ;
00113                 gluQuadricDrawStyle( qobj, GLU_FILL ) ;
00114                 gluQuadricNormals( qobj, GLU_SMOOTH ) ;
00115                 gluCylinder( qobj,  radius, radius, height, 10, 3 ) ;   //IMPROVE: fix the slices/stacks
00116                 gluDeleteQuadric( qobj ) ;
00117         glPopMatrix() ;
00118         return true ;
00119   //## end GL_Cylinder::DrawExplicit%950474930.body
00120 }
00121 
00122 bool GL_Cylinder::Verify() const
00123 {
00124         return true;
00125 }

Generated on Sat Apr 1 21:30:35 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO