GLBVRender.h

Go to the documentation of this file.
00001 /* $Id:$ */
00002 
00003 #ifndef __GL_BV_RENDER_H
00004 #define __GL_BV_RENDER_H
00005 
00006 #include <gra/render/GLRender.h>
00007 #include <gra/shader/Shader.h>
00008 #include <esg/explorer/BVExplorer.h>
00009 #include <esg/Shape.h>
00010 
00011 using namespace esg;
00012 
00013 namespace gra {
00014 
00021 class GRA_EXPORT GLBVRender : public GLRender {
00022 protected:
00023         unsigned     _depth;
00024         bool         _showSubBVs;
00025         bool         _showObjects;
00026         GLint        _bvDisplayList;
00027         Diffuse      _bvColor;
00028         Transparency _bvTransp;
00029 
00030 protected:
00037         virtual void _render (Shader&      shader,
00038                               FrameBuffer& fb,
00039                               Camera&      camera,
00040                               Scene&       scene);
00041 
00042 public:
00053         GLBVRender (int * stopFlag,
00054                     bool  useDisplayList  = true,
00055                     bool  showSubBVs      = false,
00056                     bool  showObjects     = false,
00057                     const Vector3 bvColor = Vector3(1.0, 1.0, 1.0),
00058                     float bvTransp        = 0.5)
00059             : GLRender(stopFlag, useDisplayList),
00060               _depth(0),
00061               _showSubBVs(showSubBVs),
00062               _showObjects(showObjects),
00063               _bvDisplayList(0),
00064               _bvColor(bvColor),
00065               _bvTransp(bvTransp, bvTransp, bvTransp) {}
00066 
00070         ~GLBVRender () { if (_bvDisplayList) glDeleteLists(_bvDisplayList,1); }
00071 
00077         void setDepth (unsigned d) {
00078             if (d != _depth) clearBVDisplayList();
00079             _depth = d;
00080         }
00081 
00087         void setShowSubVolumes (bool s = true) {
00088             if (s != _showSubBVs) clearBVDisplayList();
00089             _showSubBVs = s;
00090         }
00091 
00097         void setShowObjects (bool s = true) { _showObjects = s; }
00098 
00104         void setVolumesColor (const Vector3& c) {
00105             _bvColor.setValue(c);
00106             clearBVDisplayList();
00107         }
00108 
00114         void setVolumesAlpha (float a) {
00115             _bvTransp.setValue(a, a, a);
00116             clearBVDisplayList();
00117         }
00118 
00119         unsigned       getDepth          () const { return _depth;                }
00120         bool           getShowSubVolumes () const { return _showSubBVs;           }
00121         bool           getShowObjects    () const { return _showObjects;          }
00122         const Vector3& getVolumesColor   () const { return _bvColor.value();      }
00123         float          getVolumesAlpha   () const { return _bvTransp.avgValue();  }
00124 
00125         virtual void useDisplayList (bool use) {
00126             GLRender::useDisplayList(use);
00127             if (!use) clearBVDisplayList();
00128         }
00129         
00130         void clearBVDisplayList (void) {
00131             if (!_bvDisplayList) return;
00132             glDeleteLists(_bvDisplayList, 1);
00133             _bvDisplayList = 0;
00134         }
00135         
00136         virtual void clearDisplayList (void) {
00137             GLRender::clearDisplayList();
00138             clearBVDisplayList();
00139         }
00140 };
00141     
00142 } // namespace
00143 
00144 #endif // __GL_BV_RENDER_H

Generated on Tue Nov 21 15:11:42 2006 for gra by  doxygen 1.4.6