textured_mesh_visual.h
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  * textured_mesh_visual.h
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 TEXTURED_MESH_VISUAL_H
54 #define TEXTURED_MESH_VISUAL_H
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 namespace Ogre
80 {
81 // Forward declaration
82 class Vector3;
83 class Quaternion;
84 class SceneNode;
85 class Entity;
86 
87 } // End namespace Ogre
88 
89 namespace rviz_mesh_plugin
90 {
95 {
96 public:
105  TexturedMeshVisual(rviz::DisplayContext* context, size_t displayID, size_t meshID, size_t randomID);
106 
110  virtual ~TexturedMeshVisual();
111 
115  void reset();
116 
122  bool setGeometry(const mesh_msgs::MeshGeometryStamped::ConstPtr& meshMsg);
123 
129  bool setVertexColors(const mesh_msgs::MeshVertexColorsStamped::ConstPtr& vertexColorsMsg);
130 
136  bool setVertexCosts(const mesh_msgs::MeshVertexCostsStamped::ConstPtr& vertexCostsMsg, int costColorType);
137 
138  bool setVertexCosts(const mesh_msgs::MeshVertexCostsStamped::ConstPtr& vertexCostsMsg, int costColorType,
139  float minCost, float maxCost);
140 
146  bool setMaterials(const mesh_msgs::MeshMaterialsStamped::ConstPtr& materialMsg);
147 
153  bool addTexture(const mesh_msgs::MeshTexture::ConstPtr& textureMsg);
154 
160  void setFramePosition(const Ogre::Vector3& position);
161 
167  void setFrameOrientation(const Ogre::Quaternion& orientation);
168 
186  void updateMaterial(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha, bool showFaces,
187  Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors, bool showVertexCosts,
188  bool showTextures, bool showTexturedFacesOnly, bool showNormals, Ogre::ColourValue normalsColor,
189  float normalsAlpha, float normalsScallingFactor);
190 
196  void updateNormals(float scallingFactor);
197 
198 private:
205  void showWireframe(Ogre::Pass* pass, Ogre::ColourValue wireframeColor, float wireframeAlpha);
206 
210  void showFaces(Ogre::Pass* pass, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors);
211 
212  void showNormals(Ogre::Pass* pass, Ogre::ColourValue normalsColor, float normalsAlpha);
213 
214  void showTextures(Ogre::Pass* pass);
215 
216  void enteringGeneralTriangleMesh(const mesh_msgs::MeshGeometry& mesh);
217  void enteringColoredTriangleMesh(const mesh_msgs::MeshGeometry& mesh,
218  const mesh_msgs::MeshVertexColors& vertexColors);
219  void enteringTriangleMeshWithVertexCosts(const mesh_msgs::MeshGeometry& mesh,
220  const mesh_msgs::MeshVertexCosts& vertexCosts, int costColorType);
221  void enteringTriangleMeshWithVertexCosts(const mesh_msgs::MeshGeometry& mesh,
222  const mesh_msgs::MeshVertexCosts& vertexCosts, int costColorType,
223  float minCost, float maxCost);
224  void enteringTexturedTriangleMesh(const mesh_msgs::MeshGeometry& mesh, const mesh_msgs::MeshMaterials& meshMaterials);
225  void enteringNormals(const mesh_msgs::MeshGeometry& mesh);
226 
227  Ogre::PixelFormat getOgrePixelFormatFromRosString(std::string encoding);
228 
229  void loadImageIntoTextureMaterial(size_t textureIndex);
230 
239  Ogre::ColourValue calculateColorFromCost(float cost, int costColorType);
240 
247 
249  Ogre::SceneNode* m_sceneNode;
250 
253 
255  size_t m_prefix;
256 
258  size_t m_postfix;
259 
261  size_t m_random;
262 
264  Ogre::ManualObject* m_mesh;
265 
267  Ogre::ManualObject* m_normals;
268 
270  Ogre::ManualObject* m_vertexCostsMesh;
271 
273  Ogre::ManualObject* m_texturedMesh;
274 
276  Ogre::ManualObject* m_noTexCluMesh;
277 
278  // The textures for the mesh
279  std::vector<Ogre::Image> m_images;
280 
281  // The material for the textured mesh
282  Ogre::MaterialPtr m_texturedMeshMaterial;
283 
285  Ogre::MaterialPtr m_meshGeneralMaterial;
286 
289 
291  Ogre::MaterialPtr m_normalMaterial;
292 
294  Ogre::MaterialPtr m_noTexCluMaterial;
295 
297  Ogre::MaterialPtr m_vertexCostMaterial;
298 
300  std::vector<Ogre::MaterialPtr> m_textureMaterials;
301 
304 
306  mesh_msgs::MeshGeometry m_meshMsg;
307 
309  std::string m_meshUuid;
310 
312  std::string m_vertexColorsUuid;
313 
315  std::string m_vertexCostsUuid;
316 
318  std::string m_materialsUuid;
319 };
320 } // End namespace rviz_mesh_plugin
321 
322 #endif
rviz_mesh_plugin::TexturedMeshVisual::enteringTriangleMeshWithVertexCosts
void enteringTriangleMeshWithVertexCosts(const mesh_msgs::MeshGeometry &mesh, const mesh_msgs::MeshVertexCosts &vertexCosts, int costColorType)
Definition: textured_mesh_visual.cpp:556
rviz_mesh_plugin::TexturedMeshVisual::reset
void reset()
Clears whole stored data.
Definition: textured_mesh_visual.cpp:143
rviz_mesh_plugin::TexturedMeshVisual::m_noTexCluMaterial
Ogre::MaterialPtr m_noTexCluMaterial
The materials of the not textured clusters.
Definition: textured_mesh_visual.h:294
Ogre
rviz_mesh_plugin::TexturedMeshVisual::m_meshUuid
std::string m_meshUuid
Uuid of the currently shown vertex colors.
Definition: textured_mesh_visual.h:309
rviz_mesh_plugin::TexturedMeshVisual::m_materials_enabled
bool m_materials_enabled
Definition: textured_mesh_visual.h:244
rviz_mesh_plugin::TexturedMeshVisual::~TexturedMeshVisual
virtual ~TexturedMeshVisual()
Destructor.
Definition: textured_mesh_visual.cpp:112
rviz_mesh_plugin::TexturedMeshVisual::m_vertex_costs_enabled
bool m_vertex_costs_enabled
Definition: textured_mesh_visual.h:243
rviz_mesh_plugin::TexturedMeshVisual::m_sceneNode
Ogre::SceneNode * m_sceneNode
Ogre Scenenode.
Definition: textured_mesh_visual.h:249
rviz_mesh_plugin::TexturedMeshVisual
Class to display mesh data in the main panel of rviz.
Definition: textured_mesh_visual.h:94
rviz_mesh_plugin::TexturedMeshVisual::m_normals
Ogre::ManualObject * m_normals
The manual object to display normals.
Definition: textured_mesh_visual.h:267
rviz_mesh_plugin::TexturedMeshVisual::m_materialsUuid
std::string m_materialsUuid
Uuid of the currently shown materials.
Definition: textured_mesh_visual.h:318
rviz_mesh_plugin::TexturedMeshVisual::updateNormals
void updateNormals(float scallingFactor)
Updates the size of the normals dynamically.
Definition: textured_mesh_visual.cpp:384
frame_manager.h
rviz_mesh_plugin::TexturedMeshVisual::getOgrePixelFormatFromRosString
Ogre::PixelFormat getOgrePixelFormatFromRosString(std::string encoding)
Definition: textured_mesh_visual.cpp:1130
rviz_mesh_plugin::TexturedMeshVisual::setFrameOrientation
void setFrameOrientation(const Ogre::Quaternion &orientation)
Sets the orientation of the coordinate frame the message refers to.
Definition: textured_mesh_visual.cpp:1197
rviz_mesh_plugin::TexturedMeshVisual::m_random
size_t m_random
Random ID of the created mesh.
Definition: textured_mesh_visual.h:261
rviz_mesh_plugin::TexturedMeshVisual::m_postfix
size_t m_postfix
Second ID of the created mesh.
Definition: textured_mesh_visual.h:258
rviz_mesh_plugin::TexturedMeshVisual::enteringNormals
void enteringNormals(const mesh_msgs::MeshGeometry &mesh)
Definition: textured_mesh_visual.cpp:832
rviz_mesh_plugin::TexturedMeshVisual::m_meshMsg
mesh_msgs::MeshGeometry m_meshMsg
Triangle Mesh contained in the given message.
Definition: textured_mesh_visual.h:306
rviz_mesh_plugin::TexturedMeshVisual::m_meshTexturedTrianglesMaterial
Ogre::MaterialPtr m_meshTexturedTrianglesMaterial
The material for the textured triangle mesh.
Definition: textured_mesh_visual.h:288
rviz_mesh_plugin::TexturedMeshVisual::m_images
std::vector< Ogre::Image > m_images
Definition: textured_mesh_visual.h:279
rviz_mesh_plugin::TexturedMeshVisual::m_textures_enabled
bool m_textures_enabled
Definition: textured_mesh_visual.h:246
rviz_mesh_plugin::TexturedMeshVisual::m_displayContext
rviz::DisplayContext * m_displayContext
The context that contains the display information.
Definition: textured_mesh_visual.h:252
rviz_mesh_plugin::TexturedMeshVisual::m_vertexCostsMesh
Ogre::ManualObject * m_vertexCostsMesh
The manual object to display the mesh with vertex costs.
Definition: textured_mesh_visual.h:270
rviz_mesh_plugin::TexturedMeshVisual::showWireframe
void showWireframe(Ogre::Pass *pass, Ogre::ColourValue wireframeColor, float wireframeAlpha)
Enables the wireframe.
Definition: textured_mesh_visual.cpp:218
rviz_mesh_plugin::TexturedMeshVisual::loadImageIntoTextureMaterial
void loadImageIntoTextureMaterial(size_t textureIndex)
Definition: textured_mesh_visual.cpp:1145
rviz_mesh_plugin::TexturedMeshVisual::m_texture_coords_enabled
bool m_texture_coords_enabled
Definition: textured_mesh_visual.h:245
rviz_mesh_plugin::TexturedMeshVisual::m_vertex_normals_enabled
bool m_vertex_normals_enabled
Definition: textured_mesh_visual.h:241
rviz_mesh_plugin::TexturedMeshVisual::m_meshGeneralMaterial
Ogre::MaterialPtr m_meshGeneralMaterial
The material for the general mesh.
Definition: textured_mesh_visual.h:285
rviz_mesh_plugin::TexturedMeshVisual::m_texturedMeshMaterial
Ogre::MaterialPtr m_texturedMeshMaterial
Definition: textured_mesh_visual.h:282
rviz_mesh_plugin::TexturedMeshVisual::showNormals
void showNormals(Ogre::Pass *pass, Ogre::ColourValue normalsColor, float normalsAlpha)
Definition: textured_mesh_visual.cpp:283
rviz_mesh_plugin::TexturedMeshVisual::updateMaterial
void updateMaterial(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha, bool showFaces, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors, bool showVertexCosts, bool showTextures, bool showTexturedFacesOnly, bool showNormals, Ogre::ColourValue normalsColor, float normalsAlpha, float normalsScallingFactor)
Updates the visible parts of the mesh depending on input from the rviz display.
Definition: textured_mesh_visual.cpp:308
Vector3
rviz_mesh_plugin::TexturedMeshVisual::m_vertexColorsUuid
std::string m_vertexColorsUuid
Uuid of the currently shown vertex colors.
Definition: textured_mesh_visual.h:312
rviz_mesh_plugin::TexturedMeshVisual::setMaterials
bool setMaterials(const mesh_msgs::MeshMaterialsStamped::ConstPtr &materialMsg)
Extracts data from the ros-messages and creates a textured mesh.
Definition: textured_mesh_visual.cpp:1039
rviz_mesh_plugin::TexturedMeshVisual::m_vertexCostMaterial
Ogre::MaterialPtr m_vertexCostMaterial
The material of the mesh with vertex costs.
Definition: textured_mesh_visual.h:297
rviz_mesh_plugin::TexturedMeshVisual::m_normalsScalingFactor
float m_normalsScalingFactor
Factor the normal-size is multiplied with.
Definition: textured_mesh_visual.h:303
rviz_mesh_plugin::TexturedMeshVisual::addTexture
bool addTexture(const mesh_msgs::MeshTexture::ConstPtr &textureMsg)
Extracts data from the ros-messages and adds textures to the textured mesh.
Definition: textured_mesh_visual.cpp:1088
rviz_mesh_plugin::TexturedMeshVisual::m_normalMaterial
Ogre::MaterialPtr m_normalMaterial
The material of the normals.
Definition: textured_mesh_visual.h:291
rviz::DisplayContext
rviz_mesh_plugin::TexturedMeshVisual::m_vertex_colors_enabled
bool m_vertex_colors_enabled
Definition: textured_mesh_visual.h:242
rviz_mesh_plugin::TexturedMeshVisual::enteringGeneralTriangleMesh
void enteringGeneralTriangleMesh(const mesh_msgs::MeshGeometry &mesh)
Definition: textured_mesh_visual.cpp:439
rviz_mesh_plugin::TexturedMeshVisual::enteringColoredTriangleMesh
void enteringColoredTriangleMesh(const mesh_msgs::MeshGeometry &mesh, const mesh_msgs::MeshVertexColors &vertexColors)
Definition: textured_mesh_visual.cpp:493
rviz_mesh_plugin::TexturedMeshVisual::showTextures
void showTextures(Ogre::Pass *pass)
rviz_mesh_plugin::TexturedMeshVisual::setVertexCosts
bool setVertexCosts(const mesh_msgs::MeshVertexCostsStamped::ConstPtr &vertexCostsMsg, int costColorType)
Extracts data from the ros-messages and creates a colored mesh with colors calculated from vertex cos...
Definition: textured_mesh_visual.cpp:971
rviz_mesh_plugin::TexturedMeshVisual::m_vertexCostsUuid
std::string m_vertexCostsUuid
Uuid of the currently shown vertex costs.
Definition: textured_mesh_visual.h:315
rviz_mesh_plugin::TexturedMeshVisual::showFaces
void showFaces(Ogre::Pass *pass, Ogre::ColourValue facesColor, float facesAlpha, bool useVertexColors)
Definition: textured_mesh_visual.cpp:250
rviz_mesh_plugin::TexturedMeshVisual::setFramePosition
void setFramePosition(const Ogre::Vector3 &position)
Sets the pose of the coordinate frame the message refers to.
Definition: textured_mesh_visual.cpp:1192
rviz_mesh_plugin
Definition: face_selection_tool.h:117
rviz_mesh_plugin::TexturedMeshVisual::m_mesh
Ogre::ManualObject * m_mesh
The mesh-object to display.
Definition: textured_mesh_visual.h:264
rviz_mesh_plugin::TexturedMeshVisual::TexturedMeshVisual
TexturedMeshVisual(rviz::DisplayContext *context, size_t displayID, size_t meshID, size_t randomID)
Constructor.
Definition: textured_mesh_visual.cpp:44
rviz_mesh_plugin::TexturedMeshVisual::calculateColorFromCost
Ogre::ColourValue calculateColorFromCost(float cost, int costColorType)
Calculates a color for a given cost value using a spectrum from red to green.
Definition: textured_mesh_visual.cpp:1167
rviz_mesh_plugin::TexturedMeshVisual::m_textureMaterials
std::vector< Ogre::MaterialPtr > m_textureMaterials
The materials of the textures.
Definition: textured_mesh_visual.h:300
rviz_mesh_plugin::TexturedMeshVisual::enteringTexturedTriangleMesh
void enteringTexturedTriangleMesh(const mesh_msgs::MeshGeometry &mesh, const mesh_msgs::MeshMaterials &meshMaterials)
Definition: textured_mesh_visual.cpp:654
rviz_mesh_plugin::TexturedMeshVisual::setGeometry
bool setGeometry(const mesh_msgs::MeshGeometryStamped::ConstPtr &meshMsg)
Extracts data from the ros-messages and creates meshes.
Definition: textured_mesh_visual.cpp:869
rviz_mesh_plugin::TexturedMeshVisual::m_texturedMesh
Ogre::ManualObject * m_texturedMesh
The manual object to display the textured mesh.
Definition: textured_mesh_visual.h:273
rviz_mesh_plugin::TexturedMeshVisual::m_noTexCluMesh
Ogre::ManualObject * m_noTexCluMesh
The manual object to display the not textured parts of the textured mesh.
Definition: textured_mesh_visual.h:276
rviz_mesh_plugin::TexturedMeshVisual::setVertexColors
bool setVertexColors(const mesh_msgs::MeshVertexColorsStamped::ConstPtr &vertexColorsMsg)
Extracts data from the ros-messages and creates a colored mesh.
Definition: textured_mesh_visual.cpp:935
display_context.h
rviz_mesh_plugin::TexturedMeshVisual::m_prefix
size_t m_prefix
First ID of the created mesh.
Definition: textured_mesh_visual.h:255


rviz_mesh_plugin
Author(s): Sebastian Pütz , Henning Deeken , Marcel Mrozinski , Kristin Schmidt , Jan Philipp Vogtherr
autogenerated on Fri Feb 12 2021 04:03:57