vispy.visuals.mesh module#
A MeshVisual Visual that uses the new shader Function.
- class vispy.visuals.mesh.MeshVisual(vertices=None, faces=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), vertex_values=None, meshdata=None, shading=None, mode='triangles', **kwargs)#
Bases:
Visual
Mesh visual
- Parameters:
- verticesarray-like | None
The vertices.
- facesarray-like | None
The faces.
- vertex_colorsarray-like | None
Colors to use for each vertex.
- face_colorsarray-like | None
Colors to use for each face.
- colorinstance of Color
The color to use.
- vertex_valuesarray-like | None
The values to use for each vertex (for colormapping).
- meshdatainstance of MeshData | None
The meshdata.
- shadingstr | None
Shading to use. This uses the
ShadingFilter
filter introduced in VisPy 0.7. This class provides additional features that are available when the filter is attached manually. See ‘examples/basics/scene/mesh_shading.py’ for an example.- modestr
The drawing mode.
- **kwargsdict
Keyword arguments to pass to Visual.
Notes
Additional functionality is available through filters. Mesh-specific filters can be found in the
vispy.visuals.filters.mesh
module.This class emits a data_updated event when the mesh data is updated. This is used for example by filters for synchronization.
Examples
Create a primitive shape from a helper function:
>>> from vispy.geometry import create_sphere >>> meshdata = create_sphere() >>> mesh = MeshVisual(meshdata=meshdata)
Create a custom shape:
>>> # A rectangle made out of two triangles. >>> vertices = [(0, 0, 0), (1, 0, 1), (1, 1, 1), (0, 1, 0)] >>> faces = [(0, 1, 2), (0, 2, 3)] >>> mesh = MeshVisual(vertices=vertices, faces=faces)
- property clim#
- property cmap#
- property color#
The uniform color for this mesh
- property mesh_data#
The mesh data
- mesh_data_changed()#
- property mode#
The triangle mode used to draw this mesh.
Options are:
‘triangles’: Draw one triangle for every three vertices (eg, [1,2,3], [4,5,6], [7,8,9)
‘triangle_strip’: Draw one strip for every vertex excluding the first two (eg, [1,2,3], [2,3,4], [3,4,5])
‘triangle_fan’: Draw each triangle from the first vertex and the last two vertices (eg, [1,2,3], [1,3,4], [1,4,5])
- set_data(vertices=None, faces=None, vertex_colors=None, face_colors=None, color=None, vertex_values=None, meshdata=None)#
Set the mesh data
- Parameters:
- verticesarray-like | None
The vertices.
- facesarray-like | None
The faces.
- vertex_colorsarray-like | None
Colors to use for each vertex.
- face_colorsarray-like | None
Colors to use for each face.
- colorinstance of Color
The color to use.
- vertex_valuesarray-like | None
Values for each vertex.
- meshdatainstance of MeshData | None
The meshdata.
- property shading#
The shading method.