00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_AABB_H
00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_AABB_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl.h>
00013
00014 namespace OpenTissue
00015 {
00016
00017 namespace gl
00018 {
00019
00027 template<typename aabb_type>
00028 inline void DrawAABB(aabb_type const & aabb, bool wireframe = false)
00029 {
00030 GLfloat min_x = aabb.x();
00031 GLfloat min_y = aabb.y();
00032 GLfloat min_z = aabb.z();
00033 GLfloat max_x = min_x + aabb.w();
00034 GLfloat max_y = min_y + aabb.h();
00035 GLfloat max_z = min_z + aabb.d();
00036
00037 GLenum const mode = wireframe ? GL_LINE_LOOP : GL_POLYGON;
00038
00039
00040 glBegin(mode);
00041 glNormal3f(0,0,1); glVertex3f(min_x,min_y,max_z);
00042 glNormal3f(0,0,1); glVertex3f(max_x,min_y,max_z);
00043 glNormal3f(0,0,1); glVertex3f(max_x,max_y,max_z);
00044 glNormal3f(0,0,1); glVertex3f(min_x,max_y,max_z);
00045 glEnd();
00046
00047
00048 glBegin(mode);
00049 glNormal3f(1,0,0); glVertex3f(max_x,min_y,max_z);
00050 glNormal3f(1,0,0); glVertex3f(max_x,min_y,min_z);
00051 glNormal3f(1,0,0); glVertex3f(max_x,max_y,min_z);
00052 glNormal3f(1,0,0); glVertex3f(max_x,max_y,max_z);
00053 glEnd();
00054
00055
00056 glBegin(mode);
00057 glNormal3f(0,1,0); glVertex3f(min_x,max_y,max_z);
00058 glNormal3f(0,1,0); glVertex3f(max_x,max_y,max_z);
00059 glNormal3f(0,1,0); glVertex3f(max_x,max_y,min_z);
00060 glNormal3f(0,1,0); glVertex3f(min_x,max_y,min_z);
00061 glEnd();
00062
00063
00064 glBegin(mode);
00065 glNormal3f(0,0,-1); glVertex3f(min_x,min_y,min_z);
00066 glNormal3f(0,0,-1); glVertex3f(min_x,max_y,min_z);
00067 glNormal3f(0,0,-1); glVertex3f(max_x,max_y,min_z);
00068 glNormal3f(0,0,-1); glVertex3f(max_x,min_y,min_z);
00069 glEnd();
00070
00071
00072 glBegin(mode);
00073 glNormal3f(0,-1,0); glVertex3f(min_x,min_y,min_z);
00074 glNormal3f(0,-1,0); glVertex3f(max_x,min_y,min_z);
00075 glNormal3f(0,-1,0); glVertex3f(max_x,min_y,max_z);
00076 glNormal3f(0,-1,0); glVertex3f(min_x,min_y,max_z);
00077 glEnd();
00078
00079
00080 glBegin(mode);
00081 glNormal3f(-1,0,0); glVertex3f(min_x,min_y,min_z);
00082 glNormal3f(-1,0,0); glVertex3f(min_x,min_y,max_z);
00083 glNormal3f(-1,0,0); glVertex3f(min_x,max_y,max_z);
00084 glNormal3f(-1,0,0); glVertex3f(min_x,max_y,min_z);
00085 glEnd();
00086 };
00087
00088 }
00089
00090 }
00091
00092
00093 #endif