Avogadro::Rendering::MeshGeometry#

class MeshGeometry : public Drawable#

The MeshGeometry is used for triangle mesh geometry.

Author

Marcus D. Hanwell

Subclassed by ArcSector, Quad

Unnamed Group

unsigned int addVertices(const Core::Array<Vector3f> &vertices, const Core::Array<Vector3f> &normals, const Core::Array<Vector4ub> &colors)#

Add vertices to the object. Note that this just adds vertices to the object. Use addTriangles with size_t indices to actually draw them.

Note

All arrays must be the same length, or this function call will fail, returning InvalidIndex.

Parameters:
  • vertices – The 3D vertex points to add to the drawable.

  • normals – The normal direction at the vertex.

  • colors – Vertex color. If not specified, use the current color() and opacity(). If the 3 component color is set, the current opacity() is used.

Returns:

The index of the first vertex added by this call, used to specify element arrays for the actual triangles.

unsigned int addVertices(const Core::Array<Vector3f> &vertices, const Core::Array<Vector3f> &normals, const Core::Array<Vector3ub> &colors)#

Add vertices to the object. Note that this just adds vertices to the object. Use addTriangles with size_t indices to actually draw them.

Note

All arrays must be the same length, or this function call will fail, returning InvalidIndex.

Parameters:
  • vertices – The 3D vertex points to add to the drawable.

  • normals – The normal direction at the vertex.

  • colors – Vertex color. If not specified, use the current color() and opacity(). If the 3 component color is set, the current opacity() is used.

Returns:

The index of the first vertex added by this call, used to specify element arrays for the actual triangles.

unsigned int addVertices(const Core::Array<Vector3f> &vertices, const Core::Array<Vector3f> &normals)#

Add vertices to the object. Note that this just adds vertices to the object. Use addTriangles with size_t indices to actually draw them.

Note

All arrays must be the same length, or this function call will fail, returning InvalidIndex.

Parameters:
  • vertices – The 3D vertex points to add to the drawable.

  • normals – The normal direction at the vertex.

  • colors – Vertex color. If not specified, use the current color() and opacity(). If the 3 component color is set, the current opacity() is used.

Returns:

The index of the first vertex added by this call, used to specify element arrays for the actual triangles.

Unnamed Group

void addTriangle(size_t index1, size_t index2, size_t index3)#

Add triangles to the mesh. Triangles are specified as 3-tuples of vertex indices. Must call addVertices first, and use the return value to obtain the valid index range.

void addTriangles(const Core::Array<unsigned int> &indices)#

Add triangles to the mesh. Triangles are specified as 3-tuples of vertex indices. Must call addVertices first, and use the return value to obtain the valid index range.

Unnamed Group

inline void setColor(const Vector3ub &c)#

The default color of the mesh. This is used to set the color of new vertices when no explicit vertex color is specified.

inline Vector3ub color() const#

The default color of the mesh. This is used to set the color of new vertices when no explicit vertex color is specified.

Unnamed Group

inline void setOpacity(unsigned char opacity_)#

The default opacity of the mesh. This is used when either no explicit vertex color is specified, or a three component color is used.

inline unsigned char opacity() const#

The default opacity of the mesh. This is used when either no explicit vertex color is specified, or a three component color is used.

Public Functions

MeshGeometry()#
MeshGeometry(const MeshGeometry &other)#
~MeshGeometry() override#
inline MeshGeometry &operator=(MeshGeometry)#
virtual void accept(Visitor&) override#

Accept a visit from our friendly visitor.

virtual void render(const Camera &camera) override#

Render the mesh geometry.

Parameters:

camera – The current camera to be used for rendering.

virtual void clear() override#

Clear the contents of the node.

inline size_t vertexCount() const#

Get the number of vertices.

inline size_t indexCount() const#

Get the number of vertices.

inline size_t triangleCount() const#

Get the number of triangles.

inline Core::Array<PackedVertex> vertices()#
inline Core::Array<unsigned int> triangles()#

Public Static Attributes

static const unsigned int InvalidIndex#

Friends

friend void swap(MeshGeometry &lhs, MeshGeometry &rhs)#
struct PackedVertex#

Public Functions

inline PackedVertex(const Vector4ub &c, const Vector3f &n, const Vector3f &v)#

Public Members

Vector4ub color#
Vector3f normal#
Vector3f vertex#
unsigned char padding[4]#

Public Static Functions

static inline int colorOffset()#
static inline int normalOffset()#
static inline int vertexOffset()#