Go to the documentation of this file.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
00029
00030 #ifndef OGRE_TOOLS_OGRE_POINT_CLOUD_H
00031 #define OGRE_TOOLS_OGRE_POINT_CLOUD_H
00032
00033 #include <OGRE/OgreSimpleRenderable.h>
00034 #include <OGRE/OgreMovableObject.h>
00035 #include <OGRE/OgreString.h>
00036 #include <OGRE/OgreAxisAlignedBox.h>
00037 #include <OGRE/OgreVector3.h>
00038 #include <OGRE/OgreMaterial.h>
00039 #include <OGRE/OgreColourValue.h>
00040 #include <OGRE/OgreRoot.h>
00041 #include <OGRE/OgreHardwareBufferManager.h>
00042
00043 #include <stdint.h>
00044
00045 #include <vector>
00046
00047 #include <boost/shared_ptr.hpp>
00048
00049 namespace Ogre
00050 {
00051 class SceneManager;
00052 class ManualObject;
00053 class SceneNode;
00054 class RenderQueue;
00055 class Camera;
00056 class RenderSystem;
00057 class Matrix4;
00058 }
00059
00060 namespace rviz
00061 {
00062
00063 class PointCloud;
00064 class PointCloudRenderable : public Ogre::SimpleRenderable
00065 {
00066 public:
00067 PointCloudRenderable(PointCloud* parent, bool use_tex_coords);
00068 ~PointCloudRenderable();
00069
00070 Ogre::RenderOperation* getRenderOperation() { return &mRenderOp; }
00071 Ogre::HardwareVertexBufferSharedPtr getBuffer();
00072
00073 virtual Ogre::Real getBoundingRadius(void) const;
00074 virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
00075 virtual void _notifyCurrentCamera(Ogre::Camera* camera);
00076 virtual void getWorldTransforms(Ogre::Matrix4* xform) const;
00077 virtual const Ogre::LightList& getLights() const;
00078
00079 private:
00080 Ogre::MaterialPtr material_;
00081 PointCloud* parent_;
00082 };
00083 typedef boost::shared_ptr<PointCloudRenderable> PointCloudRenderablePtr;
00084 typedef std::vector<PointCloudRenderablePtr> V_PointCloudRenderable;
00085
00096 class PointCloud : public Ogre::MovableObject
00097 {
00098 public:
00099 enum RenderMode
00100 {
00101 RM_POINTS,
00102 RM_BILLBOARDS,
00103 RM_BILLBOARD_SPHERES,
00104 RM_BILLBOARDS_COMMON_FACING,
00105 RM_BOXES,
00106 };
00107
00108 PointCloud();
00109 ~PointCloud();
00110
00114 void clear();
00115
00120 struct Point
00121 {
00122 inline void setColor(float r, float g, float b)
00123 {
00124 Ogre::Root* root = Ogre::Root::getSingletonPtr();
00125 root->convertColourValue(Ogre::ColourValue(r, g, b), &color);
00126 }
00127
00128 float x;
00129 float y;
00130 float z;
00131 uint32_t color;
00132 };
00133
00140 void addPoints( Point* points, uint32_t num_points );
00141
00146 void popPoints( uint32_t num_points );
00147
00151 void setRenderMode(RenderMode mode);
00158 void setDimensions( float width, float height, float depth );
00159
00161 void setCommonDirection( const Ogre::Vector3& vec );
00163 void setCommonUpVector( const Ogre::Vector3& vec );
00164
00165 void setAlpha( float alpha );
00166
00167 void setPickColor(const Ogre::ColourValue& color);
00168 void setColorByIndex(bool set);
00169
00170 void setHighlightColor( float r, float g, float b );
00171
00172 virtual const Ogre::String& getMovableType() const { return sm_Type; }
00173 virtual const Ogre::AxisAlignedBox& getBoundingBox() const;
00174 virtual float getBoundingRadius() const;
00175 virtual void getWorldTransforms( Ogre::Matrix4* xform ) const;
00176 virtual void _updateRenderQueue( Ogre::RenderQueue* queue );
00177 virtual void _notifyCurrentCamera( Ogre::Camera* camera );
00178 virtual void _notifyAttached(Ogre::Node *parent, bool isTagPoint=false);
00179 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
00180 virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables);
00181 #endif
00182
00183 private:
00184
00185 uint32_t getVerticesPerPoint();
00186 PointCloudRenderablePtr getOrCreateRenderable();
00187 void regenerateAll();
00188 void shrinkRenderables();
00189
00190 Ogre::AxisAlignedBox bounding_box_;
00191 float bounding_radius_;
00192
00193 typedef std::vector<Point> V_Point;
00194 V_Point points_;
00195 uint32_t point_count_;
00196
00197 RenderMode render_mode_;
00198 float width_;
00199 float height_;
00200 float depth_;
00201 Ogre::Vector3 common_direction_;
00202 Ogre::Vector3 common_up_vector_;
00203
00204 Ogre::MaterialPtr point_material_;
00205 Ogre::MaterialPtr billboard_material_;
00206 Ogre::MaterialPtr billboard_sphere_material_;
00207 Ogre::MaterialPtr billboard_common_facing_material_;
00208 Ogre::MaterialPtr box_material_;
00209 Ogre::MaterialPtr current_material_;
00210 float alpha_;
00211
00212 bool color_by_index_;
00213
00214 V_PointCloudRenderable renderables_;
00215
00216 bool current_mode_supports_geometry_shader_;
00217 Ogre::ColourValue pick_color_;
00218
00219 static Ogre::String sm_Type;
00220 };
00221
00222 }
00223
00224 #endif