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_COpenGLStandardObject_H
00029 #define opengl_COpenGLStandardObject_H
00030
00031 #include <mrpt/opengl/CRenderizable.h>
00032 #include <mrpt/poses/CPoint3D.h>
00033
00034 #include <mrpt/utils/stl_extensions.h>
00035
00036 namespace mrpt {
00037 namespace opengl {
00038 using namespace mrpt::utils;
00039 using namespace mrpt::poses;
00040 class MRPTDLLIMPEXP COpenGLStandardObject;
00041 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(COpenGLStandardObject,CRenderizable)
00044 class MRPTDLLIMPEXP COpenGLStandardObject:public CRenderizable {
00045 DEFINE_SERIALIZABLE(COpenGLStandardObject)
00046 protected:
00047 unsigned int type;
00048 vector_serializable<CPoint3D> vertices;
00049 uint32_t chunkSize;
00050 public:
00053 virtual void render() const;
00056 virtual bool traceRay(const mrpt::poses::CPose3D &o,float &dist) const;
00057 static COpenGLStandardObjectPtr Create(unsigned int t,const std::vector<CPoint3D> &v,uint32_t cs=0) {
00058 if (cs!=0&&v.size()%cs!=0) throw std::logic_error("Vertices vector does not match chunk size");
00059 return COpenGLStandardObjectPtr(new COpenGLStandardObject(t,v,cs));
00060 }
00061 private:
00064 COpenGLStandardObject(unsigned int t,const std::vector<CPoint3D> &v,uint32_t cs):type(t),vertices(v),chunkSize(cs) {}
00065 COpenGLStandardObject():type(0),vertices(std::vector<CPoint3D>(0)),chunkSize(0) {}
00067 virtual ~COpenGLStandardObject() {}
00068 };
00069 }
00070 }
00071 #endif