00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef opengl_CBox_H
00029 #define opengl_CBox_H
00030
00031 #include <mrpt/opengl/CRenderizable.h>
00032 #include <mrpt/math/lightweight_geom_data.h>
00033
00034 namespace mrpt {
00035 namespace opengl {
00036
00037
00038 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(CBox,CRenderizable, OPENGL_IMPEXP)
00039
00040
00041
00042
00043
00044 class OPENGL_IMPEXP CBox :public CRenderizable {
00045 DEFINE_SERIALIZABLE(CBox)
00046
00047 protected:
00048 mrpt::math::TPoint3D m_corner_min,m_corner_max;
00049 bool m_wireframe;
00050 float m_lineWidth;
00051
00052 public:
00053
00054 static CBoxPtr Create(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe = false, float lineWidth = 1.0 )
00055 {
00056 return CBoxPtr(new CBox(corner1,corner2,is_wireframe,lineWidth));
00057 }
00058
00059
00060
00061
00062 void render() const;
00063
00064
00065
00066
00067
00068 virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
00069
00070 inline void setLineWidth(float width) { m_lineWidth = width; }
00071 inline float getLineWidth() const { return m_lineWidth; }
00072
00073 inline void setWireframe(bool is_wireframe=true) { m_wireframe = is_wireframe; }
00074 inline bool isWireframe() const { return m_wireframe; }
00075
00076
00077 void setBoxCorners(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2);
00078 void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const { corner1= m_corner_min; corner2 = m_corner_max; }
00079
00080
00081 private:
00082
00083 CBox():m_corner_min(-1,-1,-1),m_corner_max(1,1,1),m_wireframe(false),m_lineWidth(1) { }
00084
00085
00086 CBox(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe = false, float lineWidth = 1.0) :
00087 m_wireframe(is_wireframe) , m_lineWidth( lineWidth )
00088 {
00089 setBoxCorners(corner1,corner2);
00090 }
00091
00092
00093 virtual ~CBox() { }
00094
00095 };
00096 }
00097 }
00098 #endif