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_CCylinder_H
00029 #define opengl_CCylinder_H
00030
00031 #include <mrpt/opengl/CRenderizable.h>
00032
00033 namespace mrpt {
00034 namespace opengl {
00035 class MRPTDLLIMPEXP CCylinder;
00036
00037 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(CCylinder,CRenderizable)
00041 class MRPTDLLIMPEXP CCylinder:public CRenderizable {
00042 DEFINE_SERIALIZABLE(CCylinder)
00043 protected:
00044 float mBaseRadius,mTopRadius,mHeight;
00045 uint32_t mSlices,mStacks;
00046 bool mHasTopBase,mHasBottomBase;
00047 public:
00048 static CCylinderPtr Create(const float baseRadius=1,const float topRadius=1,const float height=1,const int slices=10,const int stacks=10) {
00049 return CCylinderPtr(new CCylinder(baseRadius,topRadius,height,slices,stacks));
00050 }
00051 static CCylinderPtr Create(const float radius=1,const float height=1,const int slices=10,const int stacks=10) {
00052 return CCylinderPtr(new CCylinder(radius,radius,height,slices,stacks));
00053 }
00056 void render() const;
00057 virtual bool traceRay(const mrpt::poses::CPose3D &o,float &dist) const;
00058 inline void setHasBases(bool top=true,bool bottom=true) {
00059 mHasTopBase=top;
00060 mHasBottomBase=bottom;
00061 }
00062 inline bool hasTopBase() const {
00063 return mHasTopBase;
00064 }
00065 inline bool hasBottomBase() const {
00066 return mHasBottomBase;
00067 }
00068 inline void setRadius(float radius) {
00069 mBaseRadius=mTopRadius=radius;
00070 }
00071 inline void setRadii(float bottom,float top) {
00072 mBaseRadius=bottom;
00073 mTopRadius=top;
00074 }
00075 inline void setHeight(float height) {
00076 mHeight=height;
00077 }
00078 inline float getBottomRadius() const {
00079 return mBaseRadius;
00080 }
00081 inline float getTopRadius() const {
00082 return mTopRadius;
00083 }
00084 inline float getHeight() const {
00085 return mHeight;
00086 }
00087 inline void setSlicesCount(uint32_t slices) {
00088 mSlices=slices;
00089 }
00090 inline void setStacksCount(uint32_t stacks) {
00091 mStacks=stacks;
00092 }
00093 inline uint32_t getSlicesCount() const {
00094 return mSlices;
00095 }
00096 inline uint32_t getStacksCount() const {
00097 return mStacks;
00098 }
00099 private:
00100 CCylinder():mBaseRadius(1),mTopRadius(1),mHeight(1),mSlices(10),mStacks(10),mHasTopBase(true),mHasBottomBase(true) {};
00101 CCylinder(const float baseRadius,const float topRadius,const float height,const int slices,const int stacks):mBaseRadius(baseRadius),mTopRadius(topRadius),mHeight(height),mSlices(slices),mStacks(stacks),mHasTopBase(true),mHasBottomBase(true) {};
00102 virtual ~CCylinder() {};
00103 };
00104 }
00105 }
00106 #endif