00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "vertexBufferBase.h"
00019 #include "vertexBufferState.h"
00020
00021 namespace mesh
00022 {
00023 void VertexBufferBase::renderBoundingSphere(VertexBufferState& state ) const
00024 {
00025 GLuint displayList = state.getDisplayList( &_boundingSphere );
00026
00027 if( displayList == state.INVALID )
00028 {
00029 displayList = state.newDisplayList( &_boundingSphere );
00030 glNewList( displayList, GL_COMPILE );
00031
00032 const float x = _boundingSphere.x();
00033 const float y = _boundingSphere.y();
00034 const float z = _boundingSphere.z();
00035 const float x1 = x - _boundingSphere.w();
00036 const float x2 = x + _boundingSphere.w();
00037 const float y1 = y - _boundingSphere.w();
00038 const float y2 = y + _boundingSphere.w();
00039 const float z1 = z - _boundingSphere.w();
00040 const float z2 = z + _boundingSphere.w();
00041 const float size = _boundingSphere.w();
00042
00043
00044 glBegin( GL_QUADS );
00045 glNormal3f( 1.0f, 0.0f, 0.0f );
00046 glVertex3f( x1, y - size, z - size );
00047 glVertex3f( x1, y + size, z - size );
00048 glVertex3f( x1, y + size, z + size );
00049 glVertex3f( x1, y - size, z + size );
00050 glNormal3f( -1.0f, 0.0f, 0.0f );
00051 glVertex3f( x2, y - size, z - size );
00052 glVertex3f( x2, y - size, z + size );
00053 glVertex3f( x2, y + size, z + size );
00054 glVertex3f( x2, y + size, z - size );
00055
00056 glNormal3f( 0.0f, -1.0f, 0.0f );
00057 glVertex3f( x - size, y2, z - size );
00058 glVertex3f( x + size, y2, z - size );
00059 glVertex3f( x + size, y2, z + size );
00060 glVertex3f( x - size, y2, z + size );
00061 glNormal3f( 0.0f, 1.0f, 0.0f );
00062 glVertex3f( x - size, y1, z - size );
00063 glVertex3f( x - size, y1, z + size );
00064 glVertex3f( x + size, y1, z + size );
00065 glVertex3f( x + size, y1, z - size );
00066
00067 glNormal3f( 0.0f, 0.0f, -1.0f );
00068 glVertex3f( x - size, y - size, z2 );
00069 glVertex3f( x - size, y + size, z2 );
00070 glVertex3f( x + size, y + size, z2 );
00071 glVertex3f( x + size, y - size, z2 );
00072 glNormal3f( 0.0f, 0.0f, 1.0f );
00073 glVertex3f( x - size, y - size, z1 );
00074 glVertex3f( x + size, y - size, z1 );
00075 glVertex3f( x + size, y + size, z1 );
00076 glVertex3f( x - size, y + size, z1 );
00077 glEnd();
00078
00079
00080 glEndList();
00081 }
00082
00083 glCallList( displayList );
00084 }
00085 }