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/gl.h>
00018
00019
00020
00021 #include "OpenGL\GL_Box.h"
00022
00023
00024
00025
00026
00027
00028 GL_Box::GL_Box (FrameManager* frameManager)
00029
00030
00031
00032 :
00033 MPK_Box( frameManager )
00034
00035 {
00036
00037
00038 }
00039
00040 GL_Box::GL_Box (const GL_Box& right)
00041
00042
00043
00044 :
00045 MPK_Box( right )
00046
00047 {
00048
00049
00050 }
00051
00052
00053 GL_Box::~GL_Box()
00054 {
00055
00056
00057 }
00058
00059
00060
00061
00062 Entity* GL_Box::Clone () const
00063 {
00064
00065 return new GL_Box( *this ) ;
00066
00067 }
00068
00069 bool GL_Box::DrawExplicit () const
00070 {
00071
00072 GLdouble x = length / 2.0 ;
00073 GLdouble y = width / 2.0 ;
00074 GLdouble z = height / 2.0 ;
00075 GLdouble a[ 3 ] = { -x, y, -z } ;
00076 GLdouble b[ 3 ] = { -x, y, z } ;
00077 GLdouble c[ 3 ] = { x, y, z } ;
00078 GLdouble d[ 3 ] = { x, y, -z } ;
00079 GLdouble e[ 3 ] = { -x, -y, -z } ;
00080 GLdouble f[ 3 ] = { -x, -y, z } ;
00081 GLdouble g[ 3 ] = { x, -y, z } ;
00082 GLdouble h[ 3 ] = { x, -y, -z } ;
00083
00084 static GLfloat up[ 3 ] = { 0, 1, 0 } ;
00085 static GLfloat dn[ 3 ] = { 0, -1, 0 } ;
00086 static GLfloat fr[ 3 ] = { 0, 0, -1 } ;
00087 static GLfloat ba[ 3 ] = { 0, 0, 1 } ;
00088 static GLfloat le[ 3 ] = { -1, 0, 0 } ;
00089 static GLfloat ri[ 3 ] = { 1, 0, 0 } ;
00090
00091
00092 glPushMatrix() ;
00093
00094 Matrix4x4 intermediate = theFrame ;
00095
00096
00097
00098 Matrix4x4 transpose = intermediate.Transpose() ;
00099 ::glMultMatrixd( ( const double* )( transpose.values ) ) ;
00100
00101 glBegin( GL_QUADS ) ;
00102
00103 glNormal3fv( up ) ;
00104 glVertex3dv( a ) ;
00105 glVertex3dv( b ) ;
00106 glVertex3dv( c ) ;
00107 glVertex3dv( d ) ;
00108
00109
00110 glNormal3fv( dn ) ;
00111 glVertex3dv( e ) ;
00112 glVertex3dv( h ) ;
00113 glVertex3dv( g ) ;
00114 glVertex3dv( f ) ;
00115
00116
00117 glNormal3fv( fr ) ;
00118 glVertex3dv( a ) ;
00119 glVertex3dv( d ) ;
00120 glVertex3dv( h ) ;
00121 glVertex3dv( e ) ;
00122
00123
00124 glNormal3fv( ba ) ;
00125 glVertex3dv( b ) ;
00126 glVertex3dv( f ) ;
00127 glVertex3dv( g ) ;
00128 glVertex3dv( c ) ;
00129
00130
00131 glNormal3fv( le ) ;
00132 glVertex3dv( b ) ;
00133 glVertex3dv( a ) ;
00134 glVertex3dv( e ) ;
00135 glVertex3dv( f ) ;
00136
00137
00138 glNormal3fv( ri ) ;
00139 glVertex3dv( d ) ;
00140 glVertex3dv( c ) ;
00141 glVertex3dv( g ) ;
00142 glVertex3dv( h ) ;
00143 glEnd() ;
00144 glPopMatrix() ;
00145 return true ;
00146
00147 }
00148
00149 bool GL_Box::Verify() const
00150 {
00151 return true;
00152 }