MeshVisual.hpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Robot Operating System code by the University of Osnabrück
5  * Copyright (c) 2015, University of Osnabrück
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  *
21  * 3. Neither the name of the copyright holder nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
30  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  *
39  *
40  * MeshVisual.hpp
41  *
42  *
43  * authors:
44  *
45  * Sebastian Pütz <spuetz@uni-osnabrueck.de>
46  * Henning Deeken <hdeeken@uni-osnabrueck.de>
47  * Marcel Mrozinski
48  * Nils Oesting
49  * Kristin Schmidt <krschmidt@uni-osnabrueck.de>
50  * Jan Philipp Vogtherr <jvogtherr@uni-osnabrueck.de>
51  */
52 
53 #ifndef MESH_VISUAL_HPP
54 #define MESH_VISUAL_HPP
55 
56 #include <mesh_msgs/MeshGeometryStamped.h>
57 #include <mesh_msgs/MeshGeometry.h>
58 #include <mesh_msgs/MeshVertexColorsStamped.h>
59 #include <mesh_msgs/MeshVertexColors.h>
60 #include <mesh_msgs/MeshVertexCostsStamped.h>
61 #include <mesh_msgs/MeshVertexCosts.h>
62 #include <mesh_msgs/MeshMaterialsStamped.h>
63 #include <mesh_msgs/MeshMaterials.h>
64 #include <mesh_msgs/MeshMaterial.h>
65 #include <mesh_msgs/MeshTexture.h>
66 
67 #include <sensor_msgs/Image.h>
68 
69 #include <rviz/display_context.h>
70 #include <rviz/frame_manager.h>
71 
72 #include <OGRE/OgreSceneNode.h>
73 #include <OGRE/OgreSceneManager.h>
74 #include <OGRE/OgreManualObject.h>
75 #include <OGRE/OgreEntity.h>
76 #include <OGRE/OgreMaterialManager.h>
77 #include <OGRE/OgreColourValue.h>
78 
79 #include <Types.hpp>
80 #include <vector>
81 
82 namespace Ogre
83 {
84 // Forward declaration
85 class Vector3;
86 class Quaternion;
87 class SceneNode;
88 class Entity;
89 
90 } // End namespace Ogre
91 
92 namespace rviz_map_plugin
93 {
98 {
99 public:
108  MeshVisual(rviz::DisplayContext* context, size_t displayID, size_t meshID, size_t randomID);
109 
113  virtual ~MeshVisual();
114 
118  void reset();
119 
125  bool setGeometry(const Geometry& geometry);
126 
132  bool setNormals(const std::vector<Normal>& normals);
133 
139  bool setVertexColors(const std::vector<Color>& vertexColors);
140 
146  bool setVertexCosts(const std::vector<float>& vertexCosts);
147 
154  bool setVertexCosts(const std::vector<float>& vertexCosts, int costColorType);
155 
164  bool setVertexCosts(const std::vector<float>& vertexCosts, int costColorType, float minCost, float maxCost);
165 
172  bool setMaterials(const vector<Material>& materials, const vector<TexCoords>& texCoords);
173 
180  bool addTexture(Texture& texture, uint32_t textureIndex);
181 
187  void setFramePosition(const Ogre::Vector3& position);
188 
194  void setFrameOrientation(const Ogre::Quaternion& orientation);
195 
207  void updateMaterial(bool showFaces, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors,
208  bool showVertexCosts, bool showTextures, bool showTexturedFacesOnly);
209 
228  void updateMaterial(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha, bool showFaces,
229  Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors, bool showVertexCosts,
230  bool showTextures, bool showTexturedFacesOnly, bool showNormals, Ogre::ColourValue normalsColor,
231  float normalsAlpha, float normalsScallingFactor);
232 
238  void updateNormals(float scallingFactor);
239 
247  void updateNormals(bool showNormals, Ogre::ColourValue normalsColor, float normalsAlpha);
248 
257  void updateNormals(bool showNormals, Ogre::ColourValue normalsColor, float normalsAlpha, float scalingFactor);
258 
266  void updateWireframe(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha);
267 
268 private:
275  void showWireframe(Ogre::Pass* pass, Ogre::ColourValue wireframeColor, float wireframeAlpha);
276 
280  void showFaces(Ogre::Pass* pass, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors);
281 
282  void showNormals(Ogre::Pass* pass, Ogre::ColourValue normalsColor, float normalsAlpha);
283 
284  void showTextures(Ogre::Pass* pass);
285 
287 
288  void enteringColoredTriangleMesh(const Geometry& mesh, const vector<Color>& vertexColors);
289 
290  void enteringTriangleMeshWithVertexCosts(const Geometry& mesh, const vector<float>& vertexCosts, int costColorType);
291  void enteringTriangleMeshWithVertexCosts(const Geometry& mesh, const vector<float>& vertexCosts, int costColorType,
292  float minCost, float maxCost);
293 
294  void enteringTexturedTriangleMesh(const Geometry& mesh, const vector<Material>& meshMaterials,
295  const vector<TexCoords>& texCoords);
296 
297  void enteringNormals(const Geometry& mesh, const vector<Normal>& normals);
298 
299  Ogre::PixelFormat getOgrePixelFormatFromRosString(std::string encoding);
300 
301  void loadImageIntoTextureMaterial(size_t textureIndex);
302 
311  Ogre::ColourValue calculateColorFromCost(float cost, int costColorType);
312 
319 
321  Ogre::SceneNode* m_sceneNode;
322 
325 
327  size_t m_prefix;
328 
330  size_t m_postfix;
331 
333  size_t m_random;
334 
336  Ogre::ManualObject* m_mesh;
337 
339  Ogre::ManualObject* m_normals;
340 
342  Ogre::ManualObject* m_vertexCostsMesh;
343 
345  Ogre::ManualObject* m_texturedMesh;
346 
348  Ogre::ManualObject* m_noTexCluMesh;
349 
350  // The textures for the mesh
351  std::vector<Ogre::Image> m_images;
352 
353  // The material for the textured mesh
354  Ogre::MaterialPtr m_texturedMeshMaterial;
355 
357  Ogre::MaterialPtr m_meshGeneralMaterial;
358 
361 
363  Ogre::MaterialPtr m_normalMaterial;
364 
366  Ogre::MaterialPtr m_noTexCluMaterial;
367 
369  Ogre::MaterialPtr m_vertexCostMaterial;
370 
372  std::vector<Ogre::MaterialPtr> m_textureMaterials;
373 
376 
379 
381  std::vector<Normal> m_geometryNormals;
382 };
383 } // End namespace rviz_map_plugin
384 
385 #endif
rviz_map_plugin::MeshVisual::enteringNormals
void enteringNormals(const Geometry &mesh, const vector< Normal > &normals)
Definition: MeshVisual.cpp:723
rviz_map_plugin::MeshVisual::updateNormals
void updateNormals(float scallingFactor)
Updates the size of the normals dynamically.
Definition: MeshVisual.cpp:417
Ogre
rviz_map_plugin::MeshVisual::m_materials_enabled
bool m_materials_enabled
Definition: MeshVisual.hpp:316
rviz_map_plugin::MeshVisual::m_normals
Ogre::ManualObject * m_normals
The manual object to display normals.
Definition: MeshVisual.hpp:339
rviz_map_plugin::MeshVisual::updateMaterial
void updateMaterial(bool showFaces, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors, bool showVertexCosts, bool showTextures, bool showTexturedFacesOnly)
Updates the visible parts of the mesh depending on input from the rviz display.
Definition: MeshVisual.cpp:305
rviz_map_plugin::MeshVisual::reset
void reset()
Clears whole stored data.
Definition: MeshVisual.cpp:190
rviz_map_plugin::MeshVisual::setVertexColors
bool setVertexColors(const std::vector< Color > &vertexColors)
Extracts data from the ros-messages and creates a colored mesh.
Definition: MeshVisual.cpp:831
rviz_map_plugin::MeshVisual::m_geometry
Geometry m_geometry
raw Triangle Mesh
Definition: MeshVisual.hpp:378
frame_manager.h
rviz_map_plugin::MeshVisual::getOgrePixelFormatFromRosString
Ogre::PixelFormat getOgrePixelFormatFromRosString(std::string encoding)
Definition: MeshVisual.cpp:970
rviz_map_plugin::MeshVisual::setGeometry
bool setGeometry(const Geometry &geometry)
Extracts data from the ros-messages and creates meshes.
Definition: MeshVisual.cpp:761
rviz_map_plugin::MeshVisual::m_noTexCluMaterial
Ogre::MaterialPtr m_noTexCluMaterial
The materials of the not textured clusters.
Definition: MeshVisual.hpp:366
rviz_map_plugin::MeshVisual
Class to display mesh data in the main panel of rviz.
Definition: MeshVisual.hpp:97
rviz_map_plugin::MeshVisual::m_meshTexturedTrianglesMaterial
Ogre::MaterialPtr m_meshTexturedTrianglesMaterial
The material for the textured triangle mesh.
Definition: MeshVisual.hpp:360
rviz_map_plugin::MeshVisual::addTexture
bool addTexture(Texture &texture, uint32_t textureIndex)
Extracts data from the ros-messages and adds textures to the textured mesh.
Definition: MeshVisual.cpp:944
rviz_map_plugin::MeshVisual::m_texturedMeshMaterial
Ogre::MaterialPtr m_texturedMeshMaterial
Definition: MeshVisual.hpp:354
rviz_map_plugin::MeshVisual::m_meshGeneralMaterial
Ogre::MaterialPtr m_meshGeneralMaterial
The material for the general mesh.
Definition: MeshVisual.hpp:357
rviz_map_plugin::MeshVisual::m_random
size_t m_random
Random ID of the created mesh.
Definition: MeshVisual.hpp:333
rviz_map_plugin::MeshVisual::m_vertex_costs_enabled
bool m_vertex_costs_enabled
Definition: MeshVisual.hpp:315
rviz_map_plugin::MeshVisual::m_normalMaterial
Ogre::MaterialPtr m_normalMaterial
The material of the normals.
Definition: MeshVisual.hpp:363
rviz_map_plugin::MeshVisual::m_geometryNormals
std::vector< Normal > m_geometryNormals
raw normals
Definition: MeshVisual.hpp:381
rviz_map_plugin::MeshVisual::m_noTexCluMesh
Ogre::ManualObject * m_noTexCluMesh
The manual object to display the not textured parts of the textured mesh.
Definition: MeshVisual.hpp:348
rviz_map_plugin::MeshVisual::setFrameOrientation
void setFrameOrientation(const Ogre::Quaternion &orientation)
Sets the orientation of the coordinate frame the message refers to.
Definition: MeshVisual.cpp:1030
rviz_map_plugin::MeshVisual::m_prefix
size_t m_prefix
First ID of the created mesh.
Definition: MeshVisual.hpp:327
rviz_map_plugin::MeshVisual::MeshVisual
MeshVisual(rviz::DisplayContext *context, size_t displayID, size_t meshID, size_t randomID)
Constructor.
Definition: MeshVisual.cpp:96
rviz_map_plugin::MeshVisual::m_texturedMesh
Ogre::ManualObject * m_texturedMesh
The manual object to display the textured mesh.
Definition: MeshVisual.hpp:345
rviz_map_plugin::MeshVisual::setVertexCosts
bool setVertexCosts(const std::vector< float > &vertexCosts)
Extracts data from the ros-messages and creates a colored mesh with colors calculated from vertex cos...
rviz_map_plugin::MeshVisual::m_vertex_normals_enabled
bool m_vertex_normals_enabled
Definition: MeshVisual.hpp:313
rviz_map_plugin::Geometry
Struct for geometry.
Definition: Types.hpp:112
Vector3
rviz_map_plugin::MeshVisual::updateWireframe
void updateWireframe(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha)
Updates the wireframe dynamically.
Definition: MeshVisual.cpp:444
rviz_map_plugin::MeshVisual::m_textureMaterials
std::vector< Ogre::MaterialPtr > m_textureMaterials
The materials of the textures.
Definition: MeshVisual.hpp:372
rviz_map_plugin::MeshVisual::setMaterials
bool setMaterials(const vector< Material > &materials, const vector< TexCoords > &texCoords)
Extracts data from the ros-messages and creates a textured mesh.
Definition: MeshVisual.cpp:912
rviz_map_plugin::MeshVisual::enteringTexturedTriangleMesh
void enteringTexturedTriangleMesh(const Geometry &mesh, const vector< Material > &meshMaterials, const vector< TexCoords > &texCoords)
Definition: MeshVisual.cpp:609
rviz_map_plugin::MeshVisual::m_sceneNode
Ogre::SceneNode * m_sceneNode
Ogre Scenenode.
Definition: MeshVisual.hpp:321
rviz_map_plugin::MeshVisual::showWireframe
void showWireframe(Ogre::Pass *pass, Ogre::ColourValue wireframeColor, float wireframeAlpha)
Enables the wireframe.
Definition: MeshVisual.cpp:258
rviz_map_plugin::MeshVisual::m_normalsScalingFactor
float m_normalsScalingFactor
Factor the normal-size is multiplied with.
Definition: MeshVisual.hpp:375
rviz::DisplayContext
rviz_map_plugin::MeshVisual::~MeshVisual
virtual ~MeshVisual()
Destructor.
Definition: MeshVisual.cpp:159
rviz_map_plugin::MeshVisual::m_vertex_colors_enabled
bool m_vertex_colors_enabled
Definition: MeshVisual.hpp:314
Types.hpp
rviz_map_plugin::MeshVisual::setFramePosition
void setFramePosition(const Ogre::Vector3 &position)
Sets the pose of the coordinate frame the message refers to.
Definition: MeshVisual.cpp:1025
rviz_map_plugin::MeshVisual::enteringTriangleMeshWithVertexCosts
void enteringTriangleMeshWithVertexCosts(const Geometry &mesh, const vector< float > &vertexCosts, int costColorType)
Definition: MeshVisual.cpp:534
rviz_map_plugin::MeshVisual::m_vertexCostMaterial
Ogre::MaterialPtr m_vertexCostMaterial
The material of the mesh with vertex costs.
Definition: MeshVisual.hpp:369
rviz_map_plugin::MeshVisual::setNormals
bool setNormals(const std::vector< Normal > &normals)
Passes the normal data to the mesh visual.
Definition: MeshVisual.cpp:801
rviz_map_plugin::MeshVisual::enteringGeneralTriangleMesh
void enteringGeneralTriangleMesh(const Geometry &mesh)
Definition: MeshVisual.cpp:464
rviz_map_plugin::MeshVisual::showTextures
void showTextures(Ogre::Pass *pass)
rviz_map_plugin::MeshVisual::m_postfix
size_t m_postfix
Second ID of the created mesh.
Definition: MeshVisual.hpp:330
rviz_map_plugin::MeshVisual::showNormals
void showNormals(Ogre::Pass *pass, Ogre::ColourValue normalsColor, float normalsAlpha)
Definition: MeshVisual.cpp:292
rviz_map_plugin
Definition: ClusterLabelDisplay.hpp:120
rviz_map_plugin::MeshVisual::m_texture_coords_enabled
bool m_texture_coords_enabled
Definition: MeshVisual.hpp:317
rviz_map_plugin::MeshVisual::m_images
std::vector< Ogre::Image > m_images
Definition: MeshVisual.hpp:351
rviz_map_plugin::MeshVisual::showFaces
void showFaces(Ogre::Pass *pass, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors)
Definition: MeshVisual.cpp:272
rviz_map_plugin::MeshVisual::enteringColoredTriangleMesh
void enteringColoredTriangleMesh(const Geometry &mesh, const vector< Color > &vertexColors)
Definition: MeshVisual.cpp:496
rviz_map_plugin::MeshVisual::m_vertexCostsMesh
Ogre::ManualObject * m_vertexCostsMesh
The manual object to display the mesh with vertex costs.
Definition: MeshVisual.hpp:342
rviz_map_plugin::Texture
Struct for textures.
Definition: Types.hpp:160
rviz_map_plugin::MeshVisual::calculateColorFromCost
Ogre::ColourValue calculateColorFromCost(float cost, int costColorType)
Calculates a color for a given cost value using a spectrum from red to green.
Definition: MeshVisual.cpp:1001
rviz_map_plugin::MeshVisual::m_mesh
Ogre::ManualObject * m_mesh
The mesh-object to display.
Definition: MeshVisual.hpp:336
mesh
HalfEdgeMesh< Vec > mesh
rviz_map_plugin::MeshVisual::m_textures_enabled
bool m_textures_enabled
Definition: MeshVisual.hpp:318
rviz_map_plugin::MeshVisual::loadImageIntoTextureMaterial
void loadImageIntoTextureMaterial(size_t textureIndex)
Definition: MeshVisual.cpp:985
display_context.h
rviz_map_plugin::MeshVisual::m_displayContext
rviz::DisplayContext * m_displayContext
The context that contains the display information.
Definition: MeshVisual.hpp:324


rviz_map_plugin
Author(s): Sebastian Pütz , Kristin Schmidt , Jan Philipp Vogtherr , Malte kleine Piening
autogenerated on Sun Jan 21 2024 04:06:25