point_cloud.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
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 ogre_tools
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 } // namespace ogre_tools
00223 
00224 #endif


ogre_tools_qt
Author(s): Josh Faust
autogenerated on Fri Dec 6 2013 20:56:42