00001 #include "GLBbox.h" 00002 00003 #include <GL/gl.h> 00004 #include <iostream> 00005 00006 using namespace std; 00007 using namespace X3DTK; 00008 00009 BboxDrawArray GLBbox::bbox_array = BboxDrawArray(); 00010 00011 GLBbox::GLBbox() 00012 : Bbox() 00013 { 00014 } 00015 00016 GLBbox::GLBbox(const Bbox &BB) 00017 : Bbox(BB) 00018 { 00019 } 00020 00021 GLBbox::GLBbox(const SFVec3f &min, const SFVec3f &max) 00022 : Bbox(0.5f*(min + max), max - min) 00023 { 00024 } 00025 00026 void GLBbox::draw() const 00027 { 00028 SFVec3f center = getCenter(); 00029 SFVec3f size = getSize(); 00030 00031 glPushAttrib(GL_ALL_ATTRIB_BITS); 00032 glMatrixMode(GL_MODELVIEW); 00033 glEnable(GL_COLOR_MATERIAL); 00034 glDisable(GL_LIGHTING); 00035 glColor3f(1.0f, 1.0f, 1.0f); 00036 glPushMatrix(); 00037 00038 glTranslatef(center.x, center.y, center.z); 00039 glScalef(0.5f*size.x, 0.5f*size.y, 0.5f*size.z); 00040 00041 glInterleavedArrays(GL_V3F, 0, bbox_array.getBboxVertexArrayAddress()); 00042 glDrawElements(GL_LINES, bbox_array.getBboxSize(), GL_UNSIGNED_INT, bbox_array.getBboxIndexArrayAddress()); 00043 00044 glPopMatrix(); 00045 glPopAttrib(); 00046 }