MeshVisual.cpp
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.cpp
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 #include "MeshVisual.hpp"
54 
55 #include <OGRE/OgreSubEntity.h>
56 #include <OGRE/OgreRenderOperation.h>
57 #include <OGRE/OgreTextureManager.h>
58 #include <OGRE/OgreHardwarePixelBuffer.h>
59 #include <OGRE/OgrePixelFormat.h>
60 
61 #include <limits>
62 #include <stdint.h>
63 
64 namespace rviz_map_plugin
65 {
66 Ogre::ColourValue getRainbowColor1(float value)
67 {
68  float r = 0.0f;
69  float g = 0.0f;
70  float b = 0.0f;
71 
72  value = std::min(value, 1.0f);
73  value = std::max(value, 0.0f);
74 
75  float h = value * 5.0f + 1.0f;
76  int i = floor(h);
77  float f = h - i;
78  if (!(i & 1))
79  f = 1 - f; // if i is even
80  float n = 1 - f;
81 
82  if (i <= 1)
83  r = n, g = 0, b = 1;
84  else if (i == 2)
85  r = 0, g = n, b = 1;
86  else if (i == 3)
87  r = 0, g = 1, b = n;
88  else if (i == 4)
89  r = n, g = 1, b = 0;
90  else if (i >= 5)
91  r = 1, g = n, b = 0;
92 
93  return Ogre::ColourValue(r, g, b, 1.0f);
94 }
95 
96 MeshVisual::MeshVisual(rviz::DisplayContext* context, size_t displayID, size_t meshID, size_t randomID)
97  : m_displayContext(context)
98  , m_prefix(displayID)
99  , m_postfix(meshID)
100  , m_random(randomID)
101  , m_vertex_normals_enabled(false)
102  , m_vertex_colors_enabled(false)
103  , m_materials_enabled(false)
104  , m_texture_coords_enabled(false)
105  , m_normalsScalingFactor(1)
106 {
107  ROS_INFO("Creating MeshVisual %lu_TexturedMesh_%lu_%lu", m_prefix, m_postfix, m_random);
108 
109  // get or create the scene node
110  Ogre::SceneManager* sceneManager = m_displayContext->getSceneManager();
111  Ogre::SceneNode* rootNode = sceneManager->getRootSceneNode();
112 
113  std::stringstream strstream;
114  strstream << "TexturedMeshScene" << m_random;
115  std::string sceneId = strstream.str();
116  if (sceneManager->hasSceneNode(sceneId))
117  {
118  // ROS_INFO("Attaching to scene: %s", sceneId);
119  m_sceneNode = (Ogre::SceneNode*)(rootNode->getChild(sceneId));
120  }
121  else
122  {
123  // ROS_INFO("Creating new scene: %s", sceneId);
124  m_sceneNode = rootNode->createChildSceneNode(sceneId);
125  }
126 
127  // create manual objects and attach them to the scene node
128  std::stringstream sstm;
129  sstm << m_prefix << "_TriangleMesh_" << m_postfix << "_" << m_random;
130  m_mesh = sceneManager->createManualObject(sstm.str());
131  m_mesh->setDynamic(false);
132  m_sceneNode->attachObject(m_mesh);
133 
134  std::stringstream sstmNormals;
135  sstmNormals << m_prefix << "_Normals_" << m_postfix << "_" << m_random;
136  m_normals = sceneManager->createManualObject(sstmNormals.str());
137  m_normals->setDynamic(false);
138  m_sceneNode->attachObject(m_normals);
139 
140  std::stringstream sstmTexturedMesh;
141  sstmTexturedMesh << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random;
142  m_texturedMesh = sceneManager->createManualObject(sstmTexturedMesh.str());
143  m_texturedMesh->setDynamic(false);
144  m_sceneNode->attachObject(m_texturedMesh);
145 
146  std::stringstream sstmNoTexCluMesh;
147  sstmNoTexCluMesh << m_prefix << "_NoTexCluMesh_" << m_postfix << "_" << m_random;
148  m_noTexCluMesh = sceneManager->createManualObject(sstmNoTexCluMesh.str());
149  m_noTexCluMesh->setDynamic(false);
150  m_sceneNode->attachObject(m_noTexCluMesh);
151 
152  std::stringstream sstmVertexCostsMesh;
153  sstmVertexCostsMesh << m_prefix << "_VertexCostsMesh_" << m_postfix << "_" << m_random;
154  m_vertexCostsMesh = sceneManager->createManualObject(sstmVertexCostsMesh.str());
155  m_vertexCostsMesh->setDynamic(false);
156  m_sceneNode->attachObject(m_vertexCostsMesh);
157 }
158 
160 {
161  ROS_INFO("Destroying MeshVisual %lu_TexturedMesh_%lu_%lu", m_prefix, m_postfix, m_random);
162 
163  reset();
164 
165  std::stringstream sstm;
166  sstm << m_prefix << "_TriangleMesh_" << m_postfix << "_" << m_random;
167  m_displayContext->getSceneManager()->destroyManualObject(sstm.str());
168 
169  std::stringstream sstmNormals;
170  sstmNormals << m_prefix << "_Normals_" << m_postfix << "_" << m_random;
171  m_displayContext->getSceneManager()->destroyManualObject(sstmNormals.str());
172 
173  std::stringstream sstmTexturedMesh;
174  sstmTexturedMesh << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random;
175  m_displayContext->getSceneManager()->destroyManualObject(sstmTexturedMesh.str());
176 
177  std::stringstream sstmNoTexCluMesh;
178  sstmNoTexCluMesh << m_prefix << "_NoTexCluMesh_" << m_postfix << "_" << m_random;
179  m_displayContext->getSceneManager()->destroyManualObject(sstmNoTexCluMesh.str());
180 
181  std::stringstream sstmVertexCostsMesh;
182  sstmVertexCostsMesh << m_prefix << "_VertexCostsMesh_" << m_postfix << "_" << m_random;
183  m_displayContext->getSceneManager()->destroyManualObject(sstmVertexCostsMesh.str());
184 
185  m_displayContext->getSceneManager()->destroySceneNode(m_sceneNode);
186  sstm.str("");
187  sstm.flush();
188 }
189 
191 {
192  ROS_INFO("Resetting MeshVisual %lu_TexturedMesh_%lu_%lu", m_prefix, m_postfix, m_random);
193 
194  std::stringstream sstm;
195 
196  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "GeneralMaterial_";
197  Ogre::MaterialManager::getSingleton().unload(sstm.str());
198  Ogre::MaterialManager::getSingleton().remove(sstm.str());
199  sstm.str("");
200  sstm.clear();
201 
203  {
204  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "Material_" << 1;
205  Ogre::MaterialManager::getSingleton().unload(sstm.str());
206  Ogre::MaterialManager::getSingleton().remove(sstm.str());
207  sstm.str("");
208  sstm.clear();
209  }
210 
211  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "NormalMaterial";
212  Ogre::MaterialManager::getSingleton().unload(sstm.str());
213  Ogre::MaterialManager::getSingleton().remove(sstm.str());
214  sstm.str("");
215  sstm.clear();
216 
217  for (Ogre::MaterialPtr textureMaterial : m_textureMaterials)
218  {
219  Ogre::MaterialManager::getSingleton().unload(textureMaterial->getName());
220  Ogre::MaterialManager::getSingleton().remove(textureMaterial->getName());
221  }
222 
223  if (!m_noTexCluMaterial.isNull())
224  {
225  Ogre::MaterialManager::getSingleton().unload(m_noTexCluMaterial->getName());
226  Ogre::MaterialManager::getSingleton().remove(m_noTexCluMaterial->getName());
227  }
228 
229  if (!m_vertexCostMaterial.isNull())
230  {
231  Ogre::MaterialManager::getSingleton().unload(m_vertexCostMaterial->getName());
232  Ogre::MaterialManager::getSingleton().remove(m_vertexCostMaterial->getName());
233  }
234 
235  m_mesh->clear();
236  m_normals->clear();
237  m_texturedMesh->clear();
238  m_noTexCluMesh->clear();
239  m_vertexCostsMesh->clear();
240  sstm.str("");
241  sstm.flush();
242 
243  m_meshGeneralMaterial.setNull();
244  m_normalMaterial.setNull();
245  m_noTexCluMaterial.setNull();
246  m_textureMaterials.clear();
247  m_vertexCostMaterial.setNull();
248 
249  m_images.clear();
250 
251  m_vertex_colors_enabled = false;
252  m_materials_enabled = false;
253  m_texture_coords_enabled = false;
254  m_textures_enabled = false;
255  m_vertex_costs_enabled = false;
256 }
257 
258 void MeshVisual::showWireframe(Ogre::Pass* pass, Ogre::ColourValue wireframeColor, float wireframeAlpha)
259 {
260  pass->setAmbient(Ogre::ColourValue(wireframeColor.r, wireframeColor.g, wireframeColor.b, wireframeAlpha));
261  pass->setDiffuse(Ogre::ColourValue(wireframeColor.r, wireframeColor.g, wireframeColor.b, wireframeAlpha));
262 
263  if (wireframeAlpha < 1.0)
264  {
265  pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
266  pass->setDepthWriteEnabled(true);
267  }
268  pass->setPolygonMode(Ogre::PM_WIREFRAME);
269  pass->setCullingMode(Ogre::CULL_NONE);
270 }
271 
272 void MeshVisual::showFaces(Ogre::Pass* pass, Ogre::ColourValue facesColor, float facesAlpha,
273  bool useVertexColors)
274 {
275  pass->setDiffuse(Ogre::ColourValue(facesColor.r, facesColor.g, facesColor.b, facesAlpha));
276  pass->setSelfIllumination(facesColor.r, facesColor.g, facesColor.b);
277 
278  if (useVertexColors)
279  {
280  pass->setLightingEnabled(false);
281  pass->setDepthWriteEnabled(true);
282  }
283  else if (facesAlpha < 1.0)
284  {
285  pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
286  pass->setDepthWriteEnabled(false);
287  }
288  pass->setPolygonMode(Ogre::PM_SOLID);
289  pass->setCullingMode(Ogre::CULL_NONE);
290 }
291 
292 void MeshVisual::showNormals(Ogre::Pass* pass, Ogre::ColourValue normalsColor, float normalsAlpha)
293 {
294  pass->setSelfIllumination(normalsColor.r, normalsColor.g, normalsColor.b);
295  pass->setDiffuse(Ogre::ColourValue(normalsColor.r, normalsColor.g, normalsColor.b, normalsAlpha));
296  if (normalsAlpha < 1.0)
297  {
298  pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
299  pass->setDepthWriteEnabled(true);
300  }
301  pass->setPolygonMode(Ogre::PM_WIREFRAME);
302  pass->setCullingMode(Ogre::CULL_NONE);
303 }
304 
305 void MeshVisual::updateMaterial(bool showFaces, Ogre::ColourValue facesColor, float facesAlpha,
306  bool useVertexColors, bool showVertexCosts, bool showTextures,
307  bool showTexturedFacesOnly)
308 {
309  // remove the faces pass
310  if (!m_meshGeneralMaterial.isNull())
311  {
312  Ogre::Technique* tech = m_meshGeneralMaterial->getTechnique(0);
313  if (tech->getPass("faces") != 0)
314  {
315  tech->removePass(tech->getPass("faces")->getIndex());
316  }
317  }
318 
319  m_texturedMesh->setVisible(false);
320  m_noTexCluMesh->setVisible(false);
321  m_vertexCostsMesh->setVisible(false);
322 
323  // if the material exists and the textures are not enabled
324  // we can use the general mesh with the m_meshGeneralMaterial
325  if (!m_meshGeneralMaterial.isNull() && !showTextures && !showVertexCosts)
326  {
327  Ogre::Technique* tech = m_meshGeneralMaterial->getTechnique(0);
328  if (showFaces)
329  {
330  Ogre::Pass* pass = tech->createPass();
331  pass->setName("faces");
332  this->showFaces(pass, facesColor, facesAlpha, useVertexColors);
333  }
334  }
335 
336  // if there are vertex costs and the vertex cost are enabled
337  // the mesh with the colors calculated from vertex costs is made visible
338  if (m_vertex_costs_enabled && showVertexCosts)
339  {
340  m_vertexCostsMesh->setVisible(true);
341  }
342 
343  // if there are materials or textures the mesh with texture coordinates that
344  // uses the material and texture materials is made visible
346  {
347  m_texturedMesh->setVisible(true);
348  m_noTexCluMesh->setVisible(!showTexturedFacesOnly);
349  }
350 }
351 
352 void MeshVisual::updateMaterial(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha,
353  bool showFaces, Ogre::ColourValue facesColor, float facesAlpha,
354  bool useVertexColors, bool showVertexCosts, bool showTextures,
355  bool showTexturedFacesOnly, bool showNormals, Ogre::ColourValue normalsColor,
356  float normalsAlpha, float normalsScalingFactor)
357 {
358  // remove all passes
359  if (!m_meshGeneralMaterial.isNull())
360  {
361  m_meshGeneralMaterial->getTechnique(0)->removeAllPasses();
362  }
363 
364  if (!m_normalMaterial.isNull())
365  {
366  m_normalMaterial->getTechnique(0)->removeAllPasses();
367  }
368 
369  m_texturedMesh->setVisible(false);
370  m_noTexCluMesh->setVisible(false);
371  m_vertexCostsMesh->setVisible(false);
372 
373  // if the material exists and the textures are not enabled
374  // we can use the general mesh with the m_meshGeneralMaterial
375  if (!m_meshGeneralMaterial.isNull() && !showTextures && !showVertexCosts)
376  {
377  Ogre::Technique* tech = m_meshGeneralMaterial->getTechnique(0);
378 
379  if (showFaces)
380  {
381  this->showFaces(tech->createPass(), facesColor, facesAlpha, useVertexColors);
382  }
383  }
384 
385  // if there are vertex costs and the vertex cost are enabled
386  // the mesh with the colors calculated from vertex costs is made visible
387  if (m_vertex_costs_enabled && showVertexCosts)
388  {
389  m_vertexCostsMesh->setVisible(true);
390  }
391 
392  // if there are materials or textures the mesh with texture coordinates that
393  // uses the material and texture materials is made visible
395  {
396  m_texturedMesh->setVisible(true);
397  m_noTexCluMesh->setVisible(!showTexturedFacesOnly); // TODO: dynamisch
398  }
399 
400  if (showWireframe)
401  {
402  Ogre::Technique* tech = m_meshGeneralMaterial->getTechnique(0);
403  this->showWireframe(tech->createPass(), wireframeColor, wireframeAlpha);
404  }
405 
406  if (!m_normalMaterial.isNull())
407  {
408  if (showNormals)
409  {
410  Ogre::Technique* tech = m_normalMaterial->getTechnique(0);
411  this->showNormals(tech->createPass(), normalsColor, normalsAlpha);
412  updateNormals(normalsScalingFactor);
413  }
414  }
415 }
416 
417 void MeshVisual::updateNormals(float scalingFactor)
418 {
419  m_normalsScalingFactor = scalingFactor;
421 }
422 
423 void MeshVisual::updateNormals(bool showNormals, Ogre::ColourValue normalsColor, float normalsAlpha)
424 {
425  if (!m_normalMaterial.isNull())
426  {
427  m_normalMaterial->getTechnique(0)->removeAllPasses();
428 
429  if (showNormals)
430  {
431  Ogre::Technique* tech = m_normalMaterial->getTechnique(0);
432  this->showNormals(tech->createPass(), normalsColor, normalsAlpha);
433  }
434  }
435 }
436 
437 void MeshVisual::updateNormals(bool showNormals, Ogre::ColourValue normalsColor, float normalsAlpha,
438  float scalingFactor)
439 {
440  updateNormals(showNormals, normalsColor, normalsAlpha);
441  updateNormals(scalingFactor);
442 }
443 
444 void MeshVisual::updateWireframe(bool showWireframe, Ogre::ColourValue wireframeColor, float wireframeAlpha)
445 {
446  if (!m_meshGeneralMaterial.isNull())
447  {
448  Ogre::Technique* tech = m_meshGeneralMaterial->getTechnique(0);
449 
450  if (tech->getPass("wireframe") != 0)
451  {
452  tech->removePass(tech->getPass("wireframe")->getIndex());
453  }
454 
455  if (showWireframe)
456  {
457  Ogre::Pass* pass = tech->createPass();
458  pass->setName("wireframe");
459  this->showWireframe(pass, wireframeColor, wireframeAlpha);
460  }
461  }
462 }
463 
465 {
466  std::stringstream sstm;
467 
468  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "GeneralMaterial_";
469 
470  m_meshGeneralMaterial = Ogre::MaterialManager::getSingleton().create(
471  sstm.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
472 
473  m_meshGeneralMaterial->getTechnique(0)->removeAllPasses();
474 
475  // start entering data
476  m_mesh->clear();
477  m_mesh->begin(sstm.str(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
478 
479  // write vertices
480  for (size_t i = 0; i < mesh.vertices.size(); i++)
481  {
482  // write vertices
483  m_mesh->position(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
484  }
485 
486  // write triangles
487  for (size_t i = 0; i < mesh.faces.size(); i++)
488  {
489  m_mesh->triangle(mesh.faces[i].vertexIndices[0], mesh.faces[i].vertexIndices[1], mesh.faces[i].vertexIndices[2]);
490  }
491 
492  // finish entering data
493  m_mesh->end();
494 }
495 
496 void MeshVisual::enteringColoredTriangleMesh(const Geometry& mesh, const vector<Color>& vertexColors)
497 {
498  if (m_meshGeneralMaterial.isNull())
499  {
500  std::stringstream sstm;
501  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "GeneralMaterial_";
502 
503  m_meshGeneralMaterial = Ogre::MaterialManager::getSingleton().create(
504  sstm.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
505 
506  m_meshGeneralMaterial->getTechnique(0)->removeAllPasses();
507  }
508 
509  // start entering data
510  m_mesh->clear();
511  m_mesh->begin(m_meshGeneralMaterial->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
512 
513  // write vertices
514  // write vertex colors
515  for (size_t i = 0; i < mesh.vertices.size(); i++)
516  {
517  // write vertices
518  m_mesh->position(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
519 
520  // write vertex colors
521  m_mesh->colour(vertexColors[i].r, vertexColors[i].g, vertexColors[i].b, vertexColors[i].a);
522  }
523 
524  // write triangles
525  for (size_t i = 0; i < mesh.faces.size(); i++)
526  {
527  m_mesh->triangle(mesh.faces[i].vertexIndices[0], mesh.faces[i].vertexIndices[1], mesh.faces[i].vertexIndices[2]);
528  }
529 
530  // finish entering data
531  m_mesh->end();
532 }
533 
534 void MeshVisual::enteringTriangleMeshWithVertexCosts(const Geometry& mesh, const vector<float>& vertexCosts,
535  int costColorType)
536 {
537  // Calculate maximum value for vertex costs
538  float maxCost = std::numeric_limits<float>::min();
539  float minCost = std::numeric_limits<float>::max();
540  for (float cost : vertexCosts)
541  {
542  if (std::isfinite(cost) && cost > maxCost)
543  maxCost = cost;
544  if (std::isfinite(cost) && cost < minCost)
545  minCost = cost;
546  }
547 
548  enteringTriangleMeshWithVertexCosts(mesh, vertexCosts, costColorType, minCost, maxCost);
549 }
550 
551 void MeshVisual::enteringTriangleMeshWithVertexCosts(const Geometry& mesh, const vector<float>& vertexCosts,
552  int costColorType, float minCost, float maxCost)
553 {
554  float range = maxCost - minCost;
555  if (range <= 0)
556  {
557  ROS_ERROR("Illegal vertex cost limits!");
558  return;
559  }
560 
561  if (m_vertexCostMaterial.isNull())
562  {
563  std::stringstream sstm;
564  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "VertexCostMaterial_";
565 
566  m_vertexCostMaterial = Ogre::MaterialManager::getSingleton().create(
567  sstm.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
568 
569  Ogre::Pass* pass = m_vertexCostMaterial->getTechnique(0)->getPass(0);
570  pass->setCullingMode(Ogre::CULL_NONE);
571  pass->setLightingEnabled(false);
572 
573  // start entering data
574  m_vertexCostsMesh->clear();
575  m_vertexCostsMesh->begin(m_vertexCostMaterial->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
576  }
577  else
578  {
579  // start updating data
580  m_vertexCostsMesh->beginUpdate(0);
581  }
582 
583  // write vertices
584  // write vertex colors
585  // write vertex normals(if enabled)
586  for (size_t i = 0; i < mesh.vertices.size(); i++)
587  {
588  // write vertices
589  m_vertexCostsMesh->position(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
590 
591  // write vertex colors that are calculated from the cost values
592  float normalizedCost = (vertexCosts[i] - minCost) / range;
593  normalizedCost = std::max(0.0f, normalizedCost);
594  normalizedCost = std::min(1.0f, normalizedCost);
595  m_vertexCostsMesh->colour(calculateColorFromCost(normalizedCost, costColorType));
596  }
597 
598  // write triangles
599  for (size_t i = 0; i < mesh.faces.size(); i++)
600  {
601  m_vertexCostsMesh->triangle(mesh.faces[i].vertexIndices[0], mesh.faces[i].vertexIndices[1],
602  mesh.faces[i].vertexIndices[2]);
603  }
604 
605  // finish entering data
606  m_vertexCostsMesh->end();
607 }
608 
609 void MeshVisual::enteringTexturedTriangleMesh(const Geometry& mesh, const vector<Material>& materials,
610  const vector<TexCoords>& texCoords)
611 {
612  std::stringstream sstm;
613  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "NoTexCluMaterial_";
614  m_noTexCluMaterial = Ogre::MaterialManager::getSingleton().create(
615  sstm.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
616 
617  m_texturedMesh->setVisible(false);
618  m_noTexCluMesh->setVisible(false);
619 
620  Ogre::Pass* pass = m_noTexCluMaterial->getTechnique(0)->getPass(0);
621  pass->setCullingMode(Ogre::CULL_NONE);
622  pass->setLightingEnabled(false);
623 
624  m_noTexCluMesh->begin(m_noTexCluMaterial->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
625 
626  size_t noTexCluVertexCount = 0;
627 
628  size_t materialIndex = 0;
629 
630  for (auto& material : materials)
631  {
632  bool hasTexture = material.textureIndex ? true : false;
633 
634  // if the material has a texture, create an ogre texture and load the image
635  if (hasTexture)
636  {
637  uint32_t textureIndex = *(material.textureIndex);
638  std::stringstream sstm;
639  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "TextureMaterial_" << textureIndex;
640  m_textureMaterials.push_back(Ogre::MaterialManager::getSingleton().create(
641  sstm.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true));
642 
643  // set some rendering options for textured clusters
644  Ogre::Pass* pass = m_textureMaterials[textureIndex]->getTechnique(0)->getPass(0);
645  // pass->setTextureFiltering(Ogre::TFO_NONE);
646  pass->setCullingMode(Ogre::CULL_NONE);
647  pass->setLightingEnabled(false);
648 
649  // check if image was already loaded
650  // this is the case if the vector of images doesn't contain this element yet or
651  // if the image was only default constructed, in which case its width will be 0
652  if (m_images.size() < textureIndex + 1 || m_images[textureIndex].getWidth() == 0)
653  {
654  ROS_DEBUG("Texture with index %u not loaded yet", textureIndex);
655  }
656  else
657  {
658  loadImageIntoTextureMaterial(textureIndex);
659  }
660  }
661 
662  if (hasTexture)
663  {
664  uint32_t textureIndex = *(material.textureIndex);
665  // start entering data
666  m_texturedMesh->begin(m_textureMaterials[textureIndex]->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
667 
668  // write vertices for each triangle
669  // write texture coordinates
670 
671  size_t triangleVertexCount = 0;
672  for (size_t i = 0; i < material.faceIndices.size(); i++)
673  {
674  uint32_t faceIndex = material.faceIndices[i];
675  // write three triangle vertices
676  for (size_t j = 0; j < 3; j++)
677  {
678  uint32_t vertexIndex = mesh.faces[faceIndex].vertexIndices[j];
679  // write vertex positions
680  m_texturedMesh->position(mesh.vertices[vertexIndex].x, mesh.vertices[vertexIndex].y,
681  mesh.vertices[vertexIndex].z);
682  // write texture coordinates
683  m_texturedMesh->textureCoord(texCoords[vertexIndex].u, 1 - texCoords[vertexIndex].v);
684  }
685  // write the three triangle vertex indices
686  m_texturedMesh->triangle(triangleVertexCount, triangleVertexCount + 1, triangleVertexCount + 2);
687  triangleVertexCount += 3;
688  }
689 
690  // finish entering data
691  m_texturedMesh->end();
692  }
693  else
694  {
695  // write vertices for each triangle to enable a coloring for each triangle
696  // write triangle colors as vertex colours
697 
698  size_t triangleVertexCount = 0;
699  for (size_t i = 0; i < material.faceIndices.size(); i++)
700  {
701  uint32_t faceIndex = material.faceIndices[i];
702  // write three triangle vertices
703  for (size_t j = 0; j < 3; j++)
704  {
705  int vertexIndex = mesh.faces[faceIndex].vertexIndices[j];
706  // write vertex positions
707  m_noTexCluMesh->position(mesh.vertices[vertexIndex].x, mesh.vertices[vertexIndex].y,
708  mesh.vertices[vertexIndex].z);
709 
710  // write triangle colors
711  m_noTexCluMesh->colour(material.color.r, material.color.g, material.color.b, material.color.a);
712  }
713  // write the three triangle vertex indices
714  m_noTexCluMesh->triangle(noTexCluVertexCount, noTexCluVertexCount + 1, noTexCluVertexCount + 2);
715  noTexCluVertexCount += 3;
716  }
717  }
718  }
719 
720  m_noTexCluMesh->end();
721 }
722 
723 void MeshVisual::enteringNormals(const Geometry& mesh, const vector<Normal>& normals)
724 {
726  {
727  return;
728  }
729 
730  std::stringstream sstm;
731  if (m_normalMaterial.isNull())
732  {
733  sstm << m_prefix << "_TexturedMesh_" << m_postfix << "_" << m_random << "NormalMaterial";
734  m_normalMaterial = Ogre::MaterialManager::getSingleton().create(
735  sstm.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
736  m_normalMaterial->getTechnique(0)->removeAllPasses();
737 
738  // Create pointNormals
739  m_normals->clear();
740  m_normals->begin(sstm.str(), Ogre::RenderOperation::OT_LINE_LIST);
741  }
742  else
743  {
744  m_normals->beginUpdate(0);
745  }
746 
747  // Vertices
748  for (size_t i = 0; i < mesh.vertices.size(); i++)
749  {
750  m_normals->position(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
751  m_normals->position(mesh.vertices[i].x + m_normalsScalingFactor * normals[i].x,
752  mesh.vertices[i].y + m_normalsScalingFactor * normals[i].y,
753  mesh.vertices[i].z + m_normalsScalingFactor * normals[i].z);
754  // add line to index buffer
755  m_normals->index(2 * i);
756  m_normals->index(2 * i + 1);
757  }
758  m_normals->end();
759 }
760 
762 {
763  reset();
764 
765  m_geometry = mesh;
766 
767  // default: vertex colors are optional and therefore disabled
768  m_vertex_colors_enabled = false;
769 
770  // default: textures and texture_coords are optional and therefore disabled
771  m_textures_enabled = false;
772  m_texture_coords_enabled = false;
773 
774  // default: vertex normals are optional and therefore disabled
775  m_vertex_normals_enabled = false;
776 
777  // default: vertex costs are optional and therefore disabled
778  m_vertex_costs_enabled = false;
779 
780  // check if there are enough vertices given
781  if (mesh.vertices.size() < 3)
782  {
783  ROS_WARN("Received not enough vertices, can't create mesh!");
784  return false;
785  }
786 
787  // defines the buffer sizes
788  int vertex_count = mesh.vertices.size();
789  int index_count = mesh.faces.size() * 3;
790 
791  // avoid memory reallocation
792  m_mesh->estimateVertexCount(vertex_count);
793  m_mesh->estimateIndexCount(index_count);
794 
795  // entering a general triangle mesh into the internal buffer
797 
798  return true;
799 }
800 
801 bool MeshVisual::setNormals(const vector<Normal>& normals)
802 {
803  // vertex normals
804  // check if there are vertex normals for each vertex
805  if (normals.size() == m_geometry.vertices.size())
806  {
807  ROS_INFO("Received %lu vertex normals.", normals.size());
809  }
810  else if (normals.size() > 0)
811  {
812  ROS_WARN("Received not as much vertex normals as vertices, ignoring vertex normals!");
813  return false;
814  }
815 
816  m_geometryNormals = normals;
817 
818  // avoid memory reallocation
819  m_normals->estimateVertexCount(m_geometry.vertices.size() * 2);
820  m_normals->estimateIndexCount(m_geometry.vertices.size() * 2);
821 
822  // entering the normals into the internal buffer
824  {
825  enteringNormals(m_geometry, normals);
826  }
827 
828  return true;
829 }
830 
831 bool MeshVisual::setVertexColors(const vector<Color>& vertexColors)
832 {
833  // check if there are vertex colors for each vertex
834  if (vertexColors.size() == m_geometry.vertices.size())
835  {
836  ROS_INFO("Received %lu vertex colors.", vertexColors.size());
838  }
839  else
840  {
841  ROS_WARN("Received not as much vertex colors as vertices, ignoring the vertex colors!");
842  return false;
843  }
844 
846 
847  return true;
848 }
849 
850 bool MeshVisual::setVertexCosts(const vector<float>& vertexCosts)
851 {
852  return setVertexCosts(vertexCosts, 0);
853 }
854 
855 bool MeshVisual::setVertexCosts(const std::vector<float>& vertexCosts, int costColorType)
856 {
857  // // check if these MeshVertexCosts belong to the current mesh and were not already loaded
858  // if (m_meshUuid != vertexCostsMsg->uuid)
859  // {
860  // ROS_WARN("Can't add vertex costs, uuids do not match.");
861  // return false;
862  // }
863 
864  // check if there are vertex costs for each vertex
865  if (vertexCosts.size() == m_geometry.vertices.size())
866  {
867  ROS_DEBUG("Received %lu vertex costs.", vertexCosts.size());
868  m_vertex_costs_enabled = true;
869  }
870  else
871  {
872  ROS_WARN("Received not as much vertex costs as vertices, ignoring the vertex costs!");
873  return false;
874  }
875 
876  enteringTriangleMeshWithVertexCosts(m_geometry, vertexCosts, costColorType);
877 
878  // m_vertexCostsUuid = vertexCostsMsg->uuid;
879 
880  return true;
881 }
882 
883 bool MeshVisual::setVertexCosts(const std::vector<float>& vertexCosts, int costColorType, float minCost,
884  float maxCost)
885 {
886  // // check if these MeshVertexCosts belong to the current mesh and were not already loaded
887  // if (m_meshUuid != vertexCostsMsg->uuid)
888  // {
889  // ROS_WARN("Can't add vertex costs, uuids do not match.");
890  // return false;
891  // }
892 
893  // check if there are vertex costs for each vertex
894  if (vertexCosts.size() == m_geometry.vertices.size())
895  {
896  ROS_DEBUG("Received %lu vertex costs.", vertexCosts.size());
897  m_vertex_costs_enabled = true;
898  }
899  else
900  {
901  ROS_WARN("Received not as much vertex costs as vertices, ignoring the vertex costs!");
902  return false;
903  }
904 
905  enteringTriangleMeshWithVertexCosts(m_geometry, vertexCosts, costColorType, minCost, maxCost);
906 
907  // m_vertexCostsUuid = vertexCostsMsg->uuid;
908 
909  return true;
910 }
911 
912 bool MeshVisual::setMaterials(const vector<Material>& materials, const vector<TexCoords>& texCoords)
913 {
914  // check if there is a material index for each cluster
915  if (materials.size() >= 0)
916  {
917  ROS_INFO("Received %lu materials.", materials.size());
918  m_materials_enabled = true; // enable materials
919  }
920  else
921  {
922  ROS_WARN("Received zero materials, ignoring materials!");
923  return false;
924  }
925 
926  // texture coords
927  // check if there are texture coords for each vertex
928  if (texCoords.size() == m_geometry.vertices.size())
929  {
930  ROS_INFO("Received %lu texture coords.", texCoords.size());
931  m_texture_coords_enabled = true; // enable texture coords
932  m_textures_enabled = true; // enable textures
933  }
934  else if (texCoords.size() > 0)
935  {
936  ROS_WARN("Received not as much texture coords as vertices, ignoring texture coords!");
937  }
938 
939  enteringTexturedTriangleMesh(m_geometry, materials, texCoords);
940 
941  return true;
942 }
943 
944 bool MeshVisual::addTexture(Texture& texture, uint32_t textureIndex)
945 {
946  uint32_t width = texture.width;
947  uint32_t height = texture.height;
948  uint32_t step = texture.channels;
949 
950  uint32_t dataSize = width * height * step;
951 
952  Ogre::PixelFormat pixelFormat = getOgrePixelFormatFromRosString(texture.pixelFormat);
953 
954  Ogre::Image image = Ogre::Image();
955  image.loadDynamicImage(texture.data.data(), width, height, 1, pixelFormat, false);
956  m_images.insert(m_images.begin() + textureIndex, image);
957 
958  if (m_textureMaterials.size() >= textureIndex + 1)
959  {
960  loadImageIntoTextureMaterial(textureIndex);
961  return true;
962  }
963  else
964  {
965  ROS_WARN("Can't load image into texture material, material does not exist!");
966  return false;
967  }
968 }
969 
970 Ogre::PixelFormat MeshVisual::getOgrePixelFormatFromRosString(std::string encoding)
971 {
972  if (encoding == "rgba8")
973  {
974  return Ogre::PF_BYTE_RGBA;
975  }
976  else if (encoding == "rgb8")
977  {
978  return Ogre::PF_BYTE_RGB;
979  }
980 
981  ROS_WARN("Unknown texture encoding! Using Ogre::PF_UNKNOWN");
982  return Ogre::PF_UNKNOWN;
983 }
984 
986 {
987  std::stringstream textureNameStream;
988  textureNameStream << m_prefix << "_Texture" << textureIndex << "_" << m_postfix << "_" << m_random;
989 
990  Ogre::TexturePtr texturePtr = Ogre::TextureManager::getSingleton().createManual(
991  textureNameStream.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
992  m_images[textureIndex].getWidth(), m_images[textureIndex].getHeight(), 0, m_images[textureIndex].getFormat());
993 
994  texturePtr->loadImage(m_images[textureIndex]);
995 
996  Ogre::Pass* pass = m_textureMaterials[textureIndex]->getTechnique(0)->getPass(0);
997  pass->removeAllTextureUnitStates();
998  pass->createTextureUnitState()->addFrameTextureName(textureNameStream.str());
999 }
1000 
1001 Ogre::ColourValue MeshVisual::calculateColorFromCost(float cost, int costColorType)
1002 {
1003  Ogre::ColourValue color;
1004 
1005  switch (costColorType)
1006  {
1007  case 0: // rainbow
1008  return getRainbowColor1(cost);
1009  case 1: // red green
1010  // calculate a color that is green for 0, yellow for 0.5 and red for 1
1011  color.r = cost * 2;
1012  color.r = color.r > 1.0f ? 1.0f : color.r;
1013  color.g = (1.0f - cost) * 2;
1014  color.g = color.g > 1.0f ? 1.0f : color.g;
1015  color.b = 0.0f;
1016  color.a = 1.0;
1017  return color;
1018  default:
1019  break;
1020  }
1021  // default
1022  return getRainbowColor1(cost);
1023 }
1024 
1025 void MeshVisual::setFramePosition(const Ogre::Vector3& position)
1026 {
1027  m_sceneNode->setPosition(position);
1028 }
1029 
1030 void MeshVisual::setFrameOrientation(const Ogre::Quaternion& orientation)
1031 {
1032  m_sceneNode->setOrientation(orientation);
1033 }
1034 
1035 } // end namespace rviz_map_plugin
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
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
getName
ROSCONSOLE_CONSOLE_IMPL_DECL std::string getName(void *handle)
rviz_map_plugin::MeshVisual::m_geometry
Geometry m_geometry
raw Triangle Mesh
Definition: MeshVisual.hpp:378
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::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::DisplayContext::getSceneManager
virtual Ogre::SceneManager * getSceneManager() const=0
rviz_map_plugin::MeshVisual::m_meshGeneralMaterial
Ogre::MaterialPtr m_meshGeneralMaterial
The material for the general mesh.
Definition: MeshVisual.hpp:357
f
f
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
ROS_DEBUG
#define ROS_DEBUG(...)
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
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::Texture::pixelFormat
string pixelFormat
Definition: Types.hpp:166
MeshVisual.hpp
rviz_map_plugin::MeshVisual::enteringTexturedTriangleMesh
void enteringTexturedTriangleMesh(const Geometry &mesh, const vector< Material > &meshMaterials, const vector< TexCoords > &texCoords)
Definition: MeshVisual.cpp:609
ROS_WARN
#define ROS_WARN(...)
rviz_map_plugin::MeshVisual::m_sceneNode
Ogre::SceneNode * m_sceneNode
Ogre Scenenode.
Definition: MeshVisual.hpp:321
rviz_map_plugin::Texture::data
vector< uint8_t > data
Definition: Types.hpp:165
rviz_map_plugin::Texture::height
uint32_t height
Definition: Types.hpp:163
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
rviz_map_plugin::Texture::width
uint32_t width
Definition: Types.hpp:162
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
ROS_ERROR
#define ROS_ERROR(...)
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::Texture::channels
uint8_t channels
Definition: Types.hpp:164
rviz_map_plugin::getRainbowColor1
Ogre::ColourValue getRainbowColor1(float value)
Definition: MeshVisual.cpp:66
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::Geometry::vertices
vector< Vertex > vertices
Definition: Types.hpp:114
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
ROS_INFO
#define ROS_INFO(...)
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
step
step
rviz_map_plugin::MeshVisual::loadImageIntoTextureMaterial
void loadImageIntoTextureMaterial(size_t textureIndex)
Definition: MeshVisual.cpp:985
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