moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rviz_rendering::MeshShape Class Reference

This class allows constructing Ogre shapes manually, from triangle lists. More...

#include <mesh_shape.hpp>

Inheritance diagram for rviz_rendering::MeshShape:
Inheritance graph
[legend]
Collaboration diagram for rviz_rendering::MeshShape:
Collaboration graph
[legend]

Public Member Functions

 MeshShape (Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node=nullptr)
 Constructor.
 
 ~MeshShape () override
 
void estimateVertexCount (size_t vcount)
 
void beginTriangles ()
 Start adding triangles to the mesh.
 
void addVertex (const Ogre::Vector3 &position)
 Add a vertex to the mesh (no normal defined). If using this function only (not using addTriangle()) it is assumed that triangles are added by specifying the 3 vertices in order (3 consecutive calls to this function). This means there must be 3*n calls to this function to add n triangles. If addTriangle() is used, indexing in the defined vertices is done.
 
void addVertex (const Ogre::Vector3 &position, const Ogre::Vector3 &normal)
 Add a vertex to the mesh with a normal defined. If using this function only (not using addTriangle()) it is assumed that triangles are added by specifying the 3 vertices in order (3 consecutive calls to this function). This means there must be 3*n calls to this function to add n triangles.If addTriangle() is used, indexing in the defined vertices is done.

 
void addVertex (const Ogre::Vector3 &position, const Ogre::Vector3 &normal, const Ogre::ColourValue &color)
 Add a vertex to the mesh with normal and color defined. If using this function only (not using addTriangle()) it is assumed that triangles are added by specifying the 3 vertices in order (3 consecutive calls to this function). This means there must be 3*n calls to this function to add n triangles.If addTriangle() is used, indexing in the defined vertices is done.
 
void addNormal (const Ogre::Vector3 &normal)
 Add normal for a vertex.
 
void addColor (const Ogre::ColourValue &color)
 Add color for a vertex.
 
void addTriangle (unsigned int p1, unsigned int p2, unsigned int p3)
 Add a triangle by indexing in the defined vertices.
 
void endTriangles ()
 Notify that the set of triangles to add is complete. No more triangles can be added, beginTriangles() can no longer be called unless clear() was called.
 
void clear ()
 Clear the mesh.
 
Ogre::ManualObject * getManualObject ()
 Get the manual object created for the mesh.
 

Detailed Description

This class allows constructing Ogre shapes manually, from triangle lists.

For example: Assuming we have a set of mesh triangles represented like this:

struct Triangle
{
  unsigned v1, v2, v3; // index for the 3 vertices that make up a triangle
};
std::vector<Triangle> triangles;
std::vector<Ogre::Vector3> vertices;
std::vector<Ogre::Vector3> normals; // normal at every vertex

we can use this class to render the mesh as follows:

rviz::MeshShape *shape = new MeshShape(scene_manager);
mesh->estimateVertexCount(vertices.size());
mesh->beginTriangles();
for (std::size_t i = 0 ; i < vertices.size() ; ++i)
  mesh->addVertex(vertices[i], normals[i]);
for (std::size_t i = 0 ; i < triangles.size() ; ++i)
  mesh->addTriangle(triangles[i].v1, triangles[i].v2, triangles[i].v3);
mesh->endTriangles();

Definition at line 68 of file mesh_shape.hpp.

Constructor & Destructor Documentation

◆ MeshShape()

rviz_rendering::MeshShape::MeshShape ( Ogre::SceneManager *  scene_manager,
Ogre::SceneNode *  parent_node = nullptr 
)

Constructor.

Parameters
scene_managerThe scene manager this object is associated with
parent_nodeA scene node to use as the parent of this object. If nullptr, uses the root scene node.

Definition at line 45 of file mesh_shape.cpp.

◆ ~MeshShape()

rviz_rendering::MeshShape::~MeshShape ( )
override

Definition at line 53 of file mesh_shape.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addColor()

void rviz_rendering::MeshShape::addColor ( const Ogre::ColourValue &  color)

Add color for a vertex.

Definition at line 106 of file mesh_shape.cpp.

◆ addNormal()

void rviz_rendering::MeshShape::addNormal ( const Ogre::Vector3 &  normal)

Add normal for a vertex.

Definition at line 101 of file mesh_shape.cpp.

◆ addTriangle()

void rviz_rendering::MeshShape::addTriangle ( unsigned int  p1,
unsigned int  p2,
unsigned int  p3 
)

Add a triangle by indexing in the defined vertices.

Definition at line 111 of file mesh_shape.cpp.

◆ addVertex() [1/3]

void rviz_rendering::MeshShape::addVertex ( const Ogre::Vector3 &  position)

Add a vertex to the mesh (no normal defined). If using this function only (not using addTriangle()) it is assumed that triangles are added by specifying the 3 vertices in order (3 consecutive calls to this function). This means there must be 3*n calls to this function to add n triangles. If addTriangle() is used, indexing in the defined vertices is done.

Definition at line 80 of file mesh_shape.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addVertex() [2/3]

void rviz_rendering::MeshShape::addVertex ( const Ogre::Vector3 &  position,
const Ogre::Vector3 &  normal 
)

Add a vertex to the mesh with a normal defined. If using this function only (not using addTriangle()) it is assumed that triangles are added by specifying the 3 vertices in order (3 consecutive calls to this function). This means there must be 3*n calls to this function to add n triangles.If addTriangle() is used, indexing in the defined vertices is done.

Definition at line 86 of file mesh_shape.cpp.

Here is the call graph for this function:

◆ addVertex() [3/3]

void rviz_rendering::MeshShape::addVertex ( const Ogre::Vector3 &  position,
const Ogre::Vector3 &  normal,
const Ogre::ColourValue &  color 
)

Add a vertex to the mesh with normal and color defined. If using this function only (not using addTriangle()) it is assumed that triangles are added by specifying the 3 vertices in order (3 consecutive calls to this function). This means there must be 3*n calls to this function to add n triangles.If addTriangle() is used, indexing in the defined vertices is done.

Definition at line 93 of file mesh_shape.cpp.

Here is the call graph for this function:

◆ beginTriangles()

void rviz_rendering::MeshShape::beginTriangles ( )

Start adding triangles to the mesh.

Definition at line 65 of file mesh_shape.cpp.

Here is the caller graph for this function:

◆ clear()

void rviz_rendering::MeshShape::clear ( )

Clear the mesh.

Definition at line 138 of file mesh_shape.cpp.

Here is the caller graph for this function:

◆ endTriangles()

void rviz_rendering::MeshShape::endTriangles ( )

Notify that the set of triangles to add is complete. No more triangles can be added, beginTriangles() can no longer be called unless clear() was called.

Definition at line 116 of file mesh_shape.cpp.

Here is the caller graph for this function:

◆ estimateVertexCount()

void rviz_rendering::MeshShape::estimateVertexCount ( size_t  vcount)

Definition at line 59 of file mesh_shape.cpp.

◆ getManualObject()

Ogre::ManualObject * rviz_rendering::MeshShape::getManualObject ( )
inline

Get the manual object created for the mesh.

Definition at line 127 of file mesh_shape.hpp.


The documentation for this class was generated from the following files: