point_cloud.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef OGRE_TOOLS_OGRE_POINT_CLOUD_H
31 #define OGRE_TOOLS_OGRE_POINT_CLOUD_H
32 
33 #include <OgreSimpleRenderable.h>
34 #include <OgreMovableObject.h>
35 #include <OgreString.h>
36 #include <OgreAxisAlignedBox.h>
37 #include <OgreVector3.h>
38 #include <OgreMaterial.h>
39 #include <OgreColourValue.h>
40 #include <OgreRoot.h>
41 #include <OgreHardwareBufferManager.h>
42 #include <OgreSharedPtr.h>
43 
44 #include <stdint.h>
45 
46 #include <vector>
47 
48 #include <boost/shared_ptr.hpp>
49 
50 namespace Ogre
51 {
52 class SceneManager;
53 class ManualObject;
54 class SceneNode;
55 class RenderQueue;
56 class Camera;
57 class RenderSystem;
58 class Matrix4;
59 } // namespace Ogre
60 
61 namespace rviz
62 {
63 class PointCloud;
64 class PointCloudRenderable : public Ogre::SimpleRenderable
65 {
66 public:
67  PointCloudRenderable(PointCloud* parent, int num_points, bool use_tex_coords);
68  ~PointCloudRenderable() override;
69 
70  Ogre::RenderOperation* getRenderOperation()
71  {
72  return &mRenderOp;
73  }
74 
75  Ogre::HardwareVertexBufferSharedPtr getBuffer();
76 
77  Ogre::Real getBoundingRadius() const override;
78  Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const override;
79  void _notifyCurrentCamera(Ogre::Camera* camera) override;
80  unsigned short getNumWorldTransforms() const override
81  {
82  return 1;
83  }
84  void getWorldTransforms(Ogre::Matrix4* xform) const override;
85  const Ogre::LightList& getLights() const override;
86 
87 private:
88  Ogre::MaterialPtr material_;
90 };
92 typedef std::vector<PointCloudRenderablePtr> V_PointCloudRenderable;
93 
107 class PointCloud : public Ogre::MovableObject
108 {
109 public:
111  {
118  };
119 
120  PointCloud();
121  ~PointCloud() override;
122 
126  void clear();
127 
132  struct Point
133  {
134  inline void setColor(float r, float g, float b, float a = 1.0)
135  {
136  color = Ogre::ColourValue(r, g, b, a);
137  }
138 
139  Ogre::Vector3 position;
140  Ogre::ColourValue color;
141  };
142 
149  void addPoints(Point* points, uint32_t num_points);
150 
155  void popPoints(uint32_t num_points);
156 
161  void setRenderMode(RenderMode mode);
168  void setDimensions(float width, float height, float depth);
169 
170  /*
171  * If set to true, the size of each point will be multiplied by it z component.
172  * (Used for depth image based point clouds)
173  */
174  void setAutoSize(bool auto_size);
175 
177  void setCommonDirection(const Ogre::Vector3& vec);
179  void setCommonUpVector(const Ogre::Vector3& vec);
180 
185  void setAlpha(float alpha, bool per_point_alpha = false);
186 
187  void setPickColor(const Ogre::ColourValue& color);
188  void setColorByIndex(bool set);
189 
190  void setHighlightColor(float r, float g, float b);
191 
192  const Ogre::String& getMovableType() const override
193  {
194  return sm_Type;
195  }
196  const Ogre::AxisAlignedBox& getBoundingBox() const override;
197  float getBoundingRadius() const override;
198  virtual void getWorldTransforms(Ogre::Matrix4* xform) const;
199  virtual unsigned short getNumWorldTransforms() const
200  {
201  return 1;
202  }
203  void _updateRenderQueue(Ogre::RenderQueue* queue) override;
204  void _notifyCurrentCamera(Ogre::Camera* camera) override;
205  void _notifyAttached(Ogre::Node* parent, bool isTagPoint = false) override;
206 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
207  void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables) override;
208 #endif
209 
210  virtual void setName(const std::string& name)
211  {
212  mName = name;
213  }
214 
215 private:
216  uint32_t getVerticesPerPoint();
217  PointCloudRenderablePtr createRenderable(int num_points);
218  void regenerateAll();
219  void shrinkRenderables();
220 
221  Ogre::AxisAlignedBox bounding_box_;
223 
224  typedef std::vector<Point> V_Point;
225  V_Point points_;
226  uint32_t point_count_;
227 
229  float width_;
230  float height_;
231  float depth_;
232  Ogre::Vector3 common_direction_;
233  Ogre::Vector3 common_up_vector_;
234 
235  Ogre::MaterialPtr point_material_;
236  Ogre::MaterialPtr square_material_;
237  Ogre::MaterialPtr flat_square_material_;
238  Ogre::MaterialPtr sphere_material_;
239  Ogre::MaterialPtr tile_material_;
240  Ogre::MaterialPtr box_material_;
241  Ogre::MaterialPtr current_material_;
242  float alpha_;
243 
245 
246  V_PointCloudRenderable renderables_;
247 
249  Ogre::ColourValue pick_color_;
250 
251  static Ogre::String sm_Type;
252 };
253 
254 } // namespace rviz
255 
256 #endif
float width_
width
Definition: point_cloud.h:229
virtual void setName(const std::string &name)
Definition: point_cloud.h:210
Ogre::MaterialPtr current_material_
Definition: point_cloud.h:241
Ogre::MaterialPtr sphere_material_
Definition: point_cloud.h:238
std::vector< Point > V_Point
Definition: point_cloud.h:224
Ogre::MaterialPtr material_
Definition: point_cloud.h:88
uint32_t point_count_
The number of points currently in points_.
Definition: point_cloud.h:226
const Ogre::String & getMovableType() const override
Definition: point_cloud.h:192
Ogre::AxisAlignedBox bounding_box_
The bounding box of this point cloud.
Definition: point_cloud.h:221
Ogre::MaterialPtr flat_square_material_
Definition: point_cloud.h:237
float depth_
depth
Definition: point_cloud.h:231
boost::shared_ptr< PointCloudRenderable > PointCloudRenderablePtr
Definition: point_cloud.h:91
V_Point points_
The list of points we&#39;re displaying. Allocates to a high-water-mark.
Definition: point_cloud.h:225
Ogre::MaterialPtr square_material_
Definition: point_cloud.h:236
Ogre::Vector3 common_direction_
See Ogre::BillboardSet::setCommonDirection.
Definition: point_cloud.h:232
bool current_mode_supports_geometry_shader_
Definition: point_cloud.h:248
Ogre::MaterialPtr tile_material_
Definition: point_cloud.h:239
Representation of a point, with x/y/z position and r/g/b color.
Definition: point_cloud.h:132
Ogre::Vector3 position
Definition: point_cloud.h:139
Ogre::RenderOperation * getRenderOperation()
Definition: point_cloud.h:70
RenderMode render_mode_
Definition: point_cloud.h:228
std::vector< PointCloudRenderablePtr > V_PointCloudRenderable
Definition: point_cloud.h:92
Ogre::MaterialPtr box_material_
Definition: point_cloud.h:240
unsigned short getNumWorldTransforms() const override
Definition: point_cloud.h:80
float bounding_radius_
The bounding radius of this point cloud.
Definition: point_cloud.h:222
Ogre::ColourValue color
Definition: point_cloud.h:140
Ogre::ColourValue pick_color_
Definition: point_cloud.h:249
virtual unsigned short getNumWorldTransforms() const
Definition: point_cloud.h:199
A visual representation of a set of points.
Definition: point_cloud.h:107
V_PointCloudRenderable renderables_
Definition: point_cloud.h:246
Ogre::MaterialPtr point_material_
Definition: point_cloud.h:235
float height_
height
Definition: point_cloud.h:230
Ogre::Vector3 common_up_vector_
See Ogre::BillboardSet::setCommonUpVector.
Definition: point_cloud.h:233
static Ogre::String sm_Type
The "renderable type" used by Ogre.
Definition: point_cloud.h:251
void setColor(float r, float g, float b, float a=1.0)
Definition: point_cloud.h:134


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:25