00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00022
00023
00024 #include "OpenGL\GL_Cylinder.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 GL_Cylinder::GL_Cylinder (FrameManager* frameManager)
00035
00036 : slices(10), stacks(3), rings(3)
00037
00038
00039 ,MPK_Cylinder( frameManager )
00040
00041 {
00042
00043
00044 }
00045
00046 GL_Cylinder::GL_Cylinder (const GL_Cylinder& right)
00047
00048 : slices(10), stacks(3), rings(3)
00049
00050
00051 ,MPK_Cylinder( right )
00052
00053 {
00054
00055
00056 }
00057
00058
00059 GL_Cylinder::~GL_Cylinder()
00060 {
00061
00062
00063 }
00064
00065
00066
00067
00068 Entity* GL_Cylinder::Clone () const
00069 {
00070
00071 return new GL_Cylinder( *this ) ;
00072
00073 }
00074
00075 bool GL_Cylinder::DrawExplicit () const
00076 {
00077
00078 glPushMatrix() ;
00079
00080
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
00089
00090 glTranslated( 0, 0, -this->height / 2.0 ) ;
00091
00092
00093
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 ) ;
00100 glPopMatrix() ;
00101
00102
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 ) ;
00109 glPopMatrix() ;
00110
00111
00112 GLUquadricObj* qobj = gluNewQuadric() ;
00113 gluQuadricDrawStyle( qobj, GLU_FILL ) ;
00114 gluQuadricNormals( qobj, GLU_SMOOTH ) ;
00115 gluCylinder( qobj, radius, radius, height, 10, 3 ) ;
00116 gluDeleteQuadric( qobj ) ;
00117 glPopMatrix() ;
00118 return true ;
00119
00120 }
00121
00122 bool GL_Cylinder::Verify() const
00123 {
00124 return true;
00125 }