Mesh

Inheritance diagram of rumba.Mesh
class Mesh

A mesh value.

This mesh class supports n-gones, per vertex and per face user channel with arbitrary types.

attributes A mesh can have any attributes but some of them have a specific meaning:

  • “UV” : the mesh’s UVs. Must be a Shape::face_varying IndexedBufferV2f.

  • “N” : the mesh’s normals. Must be a Shape::face_varying IndexedBufferV3f.

  • “Color” : the mesh’s vertex color. Must be a Shape::face_varying IndexedBufferV3f. If this attribute exists, this vertex color overrides the shader’s diffuse color.:cvar Mesh default_value: Static. The default value.

Methods

__init__

Constructor(s)

adjacent_vertices()

closest_face(p, max_distance, closest_pos)

Get the closest polygon to a point.

compute_triangle_face_varying_indices(result)

Compute and return the triangle face varying indices.

compute_triangle_indices(result)

Compute and return the triangle vertex indices.

edges_to_faces()

position_topology()

Get the polygons to position lists.

triangulate()

Build a triangle version of the Mesh.

vertex_to_edges()

Properties

default_value

__init__()

Constructor(s)

Mesh ()

Create an empty Mesh.

Mesh (points: BufferConstV3f,indices: BufferConstUInt32,offsets: BufferConstUInt32)

Create a mesh.

Note the buffers may be shared, so you should not modify them after calling this constructor.

Parameters
  • points (BufferConstV3f) - The vertex buffer.

  • indices (BufferConstUInt32) - The polygon indices, this buffer size must be the number of polygon corners in the mesh.

  • offsets (BufferConstUInt32) - The offset in the indices buffer of the start of the i-th polygon. This buffer size must by the polygon count + 1. The last entry must be indices.size().

raises RuntimeError

in case of invalid data.

Mesh (v: Value)

Cast a Value in Mesh.

If v is not a Mesh object, this object will be an empty mesh.

adjacent_vertices()
closest_face(p: Imath.V3f, max_distance: float, closest_pos: Imath.V3f) int

Get the closest polygon to a point.

Return the index of the face closest to p and closer than max_distance, if it exists; returns -1 otherwise. max_distance must be initialized with the maximum search distance, and is returned with the closest hit distance. This function is quite slow and should be used only for few queries. If a lot of queries have to be done, consider to use BVHTriangle. The returned integer is a polygon index.

Parameters
  • max_distance (float) – The maximum search distance. In return, d is filled with the closest triangle distance

  • closest_pos (Imath.V3f) – If not null and if a closest triangle has been found, closest_pos is filled with the closest triangle position.

Return type

int

compute_triangle_face_varying_indices(result: BufferV3i) None

Compute and return the triangle face varying indices.

The mesh internal structure stores polygones of n-vertices. This function computes and returns a buffer of triangle indices. The triangulation is performed trivialy and is stable with deformations. Each integer triplet forms a triangle. Each element is an index per face corner.

compute_triangle_indices(result: BufferV3i) None

Compute and return the triangle vertex indices.

The mesh internal structure stores polygones of n-vertices. This function computes and returns a buffer of triangle indices. The triangulation is performed trivialy and is stable with deformations. Each integer triplet forms a triangle. Each element is a vertex index.

edges_to_faces()
position_topology()

Get the polygons to position lists.

triangulate() Mesh

Build a triangle version of the Mesh.

The mesh internal structure stores polygones of n-vertices. This function builds a mesh, with the same vertices, whose internal structures stores triangles. The triangulation is performed as for compute_triangle_indices(). The returned mesh does not handle attributes.

Return type

Mesh

vertex_to_edges()