pyunity.meshes module¶
Module for meshes created at runtime.
-
class
pyunity.meshes.Mesh(verts, triangles, normals, texcoords=None)[source]¶ Bases:
objectClass to create a mesh for rendering with a MeshRenderer
Parameters: - verts (list) – List of Vector3’s containing each vertex
- triangles (list) – List of ints containing triangles joining up the vertices. Each int is the index of a vertex above.
- normals (list) – List of Vector3’s containing the normal of each vertex.
-
verts¶ List of Vector3’s containing each vertex
Type: list
-
triangles¶ List of lists containing triangles joining up the vertices. Each int is the index of a vertex above. The list is two-dimesional, meaning that each item in the list is a list of three ints.
Type: list
-
normals¶ List of Vector3’s containing the normal of each vertex.
Type: list
-
texcoords¶ List of lists containing the texture coordinate of each vertex. The list is two-dimesional, meaning that each item in the list is a list of two floats.
Type: list (optional)
Notes
When any of the mesh attributes are updated while a scene is running, you must use
recompile()to update the mesh so that it is displayed correctly.>>> mesh = Mesh.cube(2) >>> mesh.vertices[1] = Vector3(2, 0, 0) >>> mesh.recompile()
-
static
cube(size)[source]¶ Creates a cube mesh.
Parameters: size (float) – Side length of cube Returns: A cube centered at Vector3(0, 0, 0) that has a side length of sizeReturn type: Mesh