MeshData — pyqtgraph 0.9.8 documentation

### Navigation

- index
- modules |
- next |
- previous |
- pyqtgraph 0.9.8 documentation »
- API Reference »
- Pyqtgraph’s 3D Graphics System »

# MeshData

class `pyqtgraph.opengl.` `MeshData`(vertexes=None, faces=None, edges=None, vertexColors=None, faceColors=None)

  Class for storing and operating on 3D mesh data. May contain:

  - list of vertex locations
  - list of edges
  - list of triangles
  - colors per vertex, edge, or tri
  - normals per vertex or tri

  This class handles conversion between the standard [list of vertexes, list of faces] format (suitable for use with glDrawElements) and ‘indexed’ [list of vertexes] format (suitable for use with glDrawArrays). It will automatically compute face normal vectors as well as averaged vertex normal vectors.

  The class attempts to be as efficient as possible in caching conversion results and avoiding unnecessary conversions.

  `__init__`(vertexes=None, faces=None, edges=None, vertexColors=None, faceColors=None)

    Arguments |
    vertexes | (Nv, 3) array of vertex coordinates. If faces is not specified, then this will instead be interpreted as (Nf, 3, 3) array of coordinates.
    faces | (Nf, 3) array of indexes into the vertex array.
    edges | [not available yet]
    vertexColors | (Nv, 4) array of vertex colors. If faces is not specified, then this will instead be interpreted as (Nf, 3, 4) array of colors.
    faceColors | (Nf, 4) array of face colors.

    All arguments are optional.

  `edges`()

    Return an array (Nf, 3) of vertex indexes, two per edge in the mesh.

  `faceColors`(indexed=None)

    Return an array (Nf, 4) of face colors. If indexed==’faces’, then instead return an indexed array (Nf, 3, 4) (note this is just the same array with each color repeated three times).

  `faceCount`()

    Return the number of faces in the mesh.

  `faceNormals`(indexed=None)

    Return an array (Nf, 3) of normal vectors for each face. If indexed=’faces’, then instead return an indexed array (Nf, 3, 3) (this is just the same array with each vector copied three times).

  `faces`()

    Return an array (Nf, 3) of vertex indexes, three per triangular face in the mesh.

  `hasFaceColor`()

    Return True if this data set has face color information

  `hasFaceIndexedData`()

    Return True if this object already has vertex positions indexed by face

  `hasVertexColor`()

    Return True if this data set has vertex color information

  `restore`(state)

    Restore the state of a mesh previously saved using save()

  `save`()

    Serialize this mesh to a string appropriate for disk storage

  `setFaceColors`(colors, indexed=None)

    Set the face color array (Nf, 4). If indexed==’faces’, then the array will be interpreted as indexed and should have shape (Nf, 3, 4)

  `setFaces`(faces)

    Set the (Nf, 3) array of faces. Each rown in the array contains three indexes into the vertex array, specifying the three corners of a triangular face.

  `setVertexColors`(colors, indexed=None)

    Set the vertex color array (Nv, 4). If indexed==’faces’, then the array will be interpreted as indexed and should have shape (Nf, 3, 4)

  `setVertexes`(verts=None, indexed=None, resetNormals=True)

    Set the array (Nv, 3) of vertex coordinates. If indexed==’faces’, then the data must have shape (Nf, 3, 3) and is assumed to be already indexed as a list of faces. This will cause any pre-existing normal vectors to be cleared unless resetNormals=False.

  static `sphere`(rows, cols, radius=1.0, offset=True)

    Return a MeshData instance with vertexes and faces computed for a spherical surface.

  `vertexColors`(indexed=None)

    Return an array (Nv, 4) of vertex colors. If indexed==’faces’, then instead return an indexed array (Nf, 3, 4).

  `vertexFaces`()

    Return list mapping each vertex index to a list of face indexes that use the vertex.

  `vertexNormals`(indexed=None)

    Return an array of normal vectors. By default, the array will be (N, 3) with one entry per unique vertex in the mesh. If indexed is ‘faces’, then the array will contain three normal vectors per face (and some vertexes may be repeated).

  `vertexes`(indexed=None)

    Return an array (N,3) of the positions of vertexes in the mesh. By default, each unique vertex appears only once in the array. If indexed is ‘faces’, then the array will instead contain three vertexes per face in the mesh (and a single vertex may appear more than once in the array).

### Navigation

- index
- modules |
- next |
- previous |
- pyqtgraph 0.9.8 documentation »
- API Reference »
- Pyqtgraph’s 3D Graphics System »