33 #include <OgreMeshManager.h> 
   34 #include <OgreSceneManager.h> 
   35 #include <OgreSceneNode.h> 
   36 #include <OgreEntity.h> 
   37 #include <OgreMaterialManager.h> 
   38 #include <OgreManualObject.h> 
   40 #include <rviz_common/logging.hpp> 
   46   : Shape(Shape::Mesh, scene_manager, parent_node), started_(false)
 
   48   static uint32_t count = 0;
 
   49   manual_object_ = scene_manager->createManualObject(
"MeshShape_ManualObject" + std::to_string(count++));
 
   50   material_->setCullingMode(Ogre::CULL_NONE);
 
   56   scene_manager_->destroyManualObject(manual_object_);
 
   61   if (entity_ == 
nullptr && !started_)
 
   62     manual_object_->estimateVertexCount(vcount);
 
   67   if (!started_ && entity_)
 
   69     RVIZ_COMMON_LOG_WARNING(
"Cannot modify mesh once construction is complete");
 
   76     manual_object_->begin(material_name_, Ogre::RenderOperation::OT_TRIANGLE_LIST, 
"rviz_rendering");
 
   83   manual_object_->position(position);
 
   89   manual_object_->position(position);
 
   90   manual_object_->normal(normal);
 
   93 void MeshShape::addVertex(
const Ogre::Vector3& position, 
const Ogre::Vector3& normal, 
const Ogre::ColourValue& color)
 
   96   manual_object_->position(position);
 
   97   manual_object_->normal(normal);
 
   98   manual_object_->colour(color);
 
  103   manual_object_->normal(normal);
 
  108   manual_object_->colour(color);
 
  113   manual_object_->triangle(v1, v2, v3);
 
  121     manual_object_->end();
 
  122     static uint32_t count = 0;
 
  123     std::string 
name = 
"ConvertedMeshShape@" + std::to_string(count++);
 
  124     manual_object_->convertToMesh(
name);
 
  125     entity_ = scene_manager_->createEntity(
name);
 
  128       entity_->setMaterialName(material_name_, 
"rviz_rendering");
 
  129       offset_node_->attachObject(entity_);
 
  132       RVIZ_COMMON_LOG_ERROR(
"Unable to construct triangle mesh");
 
  135     RVIZ_COMMON_LOG_ERROR(
"No triangles added");
 
  142     entity_->detachFromParent();
 
  143     const auto& mesh_name = entity_->getMesh()->getName();
 
  144     if (Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().getByName(mesh_name))
 
  146       Ogre::MeshManager::getSingleton().remove(mesh);
 
  148     scene_manager_->destroyEntity(entity_);
 
  151   manual_object_->clear();
 
void addColor(const Ogre::ColourValue &color)
Add color for a vertex.
 
void beginTriangles()
Start adding triangles to the mesh.
 
void addTriangle(unsigned int p1, unsigned int p2, unsigned int p3)
Add a triangle by indexing in the defined vertices.
 
void addVertex(const Ogre::Vector3 &position)
Add a vertex to the mesh (no normal defined). If using this function only (not using addTriangle()) i...
 
MeshShape(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node=nullptr)
Constructor.
 
void clear()
Clear the mesh.
 
void estimateVertexCount(size_t vcount)
 
void endTriangles()
Notify that the set of triangles to add is complete. No more triangles can be added,...
 
void addNormal(const Ogre::Vector3 &normal)
Add normal for a vertex.