Uranium
Application Framework
|
Builds new meshes by adding primitives. More...
Public Member Functions | |
def | __init__ (self) |
Creates a new MeshBuilder with an empty mesh. More... | |
def | build (self) |
Build a MeshData object. More... | |
def | setCenterPosition |
def | getCenterPosition (self) |
def | setType (self, mesh_type) |
Set the type of the mesh. More... | |
def | getType (self) |
def | getFaceCount (self) |
def | getVertices (self) |
Get the array of vertices. | |
def | setVertices (self, vertices) |
def | getVertexCount (self) |
Get the number of vertices. | |
def | getVertex (self, index) |
Get a vertex by index. | |
def | removeVertex (self, index) |
def | hasNormals (self) |
Return whether this mesh has vertex normals. More... | |
def | getNormals (self) |
Return the list of vertex normals. More... | |
def | hasIndices (self) |
Return whether this mesh has indices. More... | |
def | getIndices (self) |
Get the array of indices. More... | |
def | setIndices (self, indices) |
def | hasColors (self) |
def | getColors (self) |
def | hasUVCoordinates (self) |
def | getUVCoordinates (self) |
def | getFileName (self) |
def | setFileName |
def | reserveFaceCount |
Set the amount of faces before loading data to the mesh. More... | |
def | reserveVertexCount (self, num_vertices) |
Preallocate space for vertices before loading data to the mesh. More... | |
def | reserveFaceAndVertexCount (self, num_faces, num_vertices) |
Set the amount of faces and vertices before loading data to the mesh. More... | |
def | addVertex |
Add a vertex to the mesh. More... | |
def | addVertexWithNormal (self, x, y, z, nx, ny, nz) |
Add a vertex to the mesh. More... | |
def | addFaceByPoints (self, x0, y0, z0, x1, y1, z1, x2, y2, z2) |
Add a face by providing three verts. More... | |
def | addFaceWithNormals (self, x0, y0, z0, nx0, ny0, nz0, x1, y1, z1, nx1, ny1, nz1, x2, y2, z2, nx2, ny2, nz2) |
Add a face by providing three vertices and the normals that go with those vertices. More... | |
def | setVertexColor (self, index, color) |
Sets the color for a vertex. More... | |
def | setVertexUVCoordinates (self, index, u, v) |
def | addVertices (self, vertices) |
def | addIndices (self, indices) |
def | addColors (self, colors) |
def | addFacesWithColor (self, vertices, indices, colors) |
Add faces defined by indices into vertices with vetex colors defined by colors Assumes vertices and colors have the same length. More... | |
def | setColors (self, colors) |
/param colors is a vertexCount by 4 numpy array with floats in range of 0 to 1. More... | |
def | calculateNormals |
Calculate the normals of this mesh, assuming it was created by using addFace (eg; the verts are connected) More... | |
def | addLine |
Adds a 3-dimensional line to the mesh of this mesh builder. More... | |
def | addFace |
Adds a triangle to the mesh of this mesh builder. More... | |
def | addQuad |
Add a quadrilateral to the mesh of this mesh builder. More... | |
def | addCube (self, width, height, depth, center=Vector(0, 0) |
Add a rectangular cuboid to the mesh of this mesh builder. More... | |
def | addArc (self, radius, axis, angle=math.pi *2, center=Vector(0, 0) |
Add an arc to the mesh of this mesh builder. More... | |
def | addDonut (self, inner_radius, outer_radius, width, center=Vector(0, 0) |
Adds a torus to the mesh of this mesh builder. More... | |
def | addPyramid (self, width, height, depth, angle=0, axis=Vector.Unit_Y, center=Vector(0, 0) |
Adds a pyramid to the mesh of this mesh builder. More... | |
def | addConvexPolygon |
Create a mesh from points that represent a convex hull. More... | |
def | addConvexPolygonExtrusion |
Create an extrusion from xy coordinates that represent a convex polygon. More... | |
Builds new meshes by adding primitives.
This class functions in much the same way as a normal StringBuilder would. Each instance of MeshBuilder creates one mesh. This mesh starts empty, but you can add primitives to it via the various methods of this class. The result can then be converted to a normal mesh.
def UM.Mesh.MeshBuilder.MeshBuilder.__init__ | ( | self, | |
None | |||
) |
Creates a new MeshBuilder with an empty mesh.
def UM.Mesh.MeshBuilder.MeshBuilder.addArc | ( | self, | |
radius, | |||
axis, | |||
angle = math.pi * 2 , |
|||
center = Vector(0, 0 , |
|||
sections = 32 , |
|||
color = None |
|||
) |
Add an arc to the mesh of this mesh builder.
An arc is a curve that is also a segment of a circle.
radius | The radius of the circle this arc is a segment of. |
axis | The axis perpendicular to the plane on which the arc lies. |
angle | (Optional) The length of the arc, in radians. If not provided, the entire circle is used (2 pi). |
center | (Optional) The position of the centre of the arc in space. If no position is provided, the arc is centred around the coordinate origin. |
sections | (Optional) The resolution of the arc. The arc is approximated by this number of line segments. |
color | (Optional) The colour for the arc. If no colour is provided, the colour is determined by the shader. |
def UM.Mesh.MeshBuilder.MeshBuilder.addConvexPolygon | ( | self, | |
hull_points, | |||
height, | |||
color = None |
|||
) |
Create a mesh from points that represent a convex hull.
hull_points | list of xy values |
height | the opengl y position of the generated mesh |
def UM.Mesh.MeshBuilder.MeshBuilder.addConvexPolygonExtrusion | ( | self, | |
xy_points, | |||
y0, | |||
y1, | |||
color = None |
|||
) |
Create an extrusion from xy coordinates that represent a convex polygon.
xy_points | list of xy values |
y0,y1 | opengl y locations |
def UM.Mesh.MeshBuilder.MeshBuilder.addCube | ( | self, | |
width, | |||
height, | |||
depth, | |||
center = Vector(0, 0 , |
|||
color = None |
|||
) |
Add a rectangular cuboid to the mesh of this mesh builder.
A rectangular cuboid is a square block with arbitrary width, height and depth.
width | The size of the rectangular cuboid in the X dimension. |
height | The size of the rectangular cuboid in the Y dimension. |
depth | The size of the rectangular cuboid in the Z dimension. |
center | (Optional) The position of the centre of the rectangular cuboid in space. If not provided, the cuboid is placed at the coordinate origin. |
color | (Optional) The colour for the rectangular cuboid. If no colour is provided, the colour is determined by the shader. |
def UM.Mesh.MeshBuilder.MeshBuilder.addDonut | ( | self, | |
inner_radius, | |||
outer_radius, | |||
width, | |||
center = Vector(0, 0 , |
|||
sections = 32 , |
|||
color = None , |
|||
angle = 0 , |
|||
axis = Vector.Unit_Y |
|||
) |
Adds a torus to the mesh of this mesh builder.
The torus is the shape of a doughnut. This doughnut is delicious and moist, but not very healthy.
inner_radius | The radius of the hole inside the torus. Must be smaller than outer_radius. |
outer_radius | The radius of the outside of the torus. Must be larger than inner_radius. |
width | The radius of the torus in perpendicular direction to its perimeter. This is the "thickness". |
center | (Optional) The position of the centre of the torus. If no position is provided, the torus will be centred around the coordinate origin. |
sections | (Optional) The resolution of the torus in the circumference. The resolution of the intersection of the torus cannot be changed. |
color | (Optional) The colour of the torus. If no colour is provided, a colour will be determined by the shader. |
angle | (Optional) An angle of rotation to rotate the torus by, in radians. |
axis | (Optional) An axis of rotation to rotate the torus around. If no axis is provided and the angle of rotation is nonzero, the torus will be rotated around the Y-axis. |
def UM.Mesh.MeshBuilder.MeshBuilder.addFace | ( | self, | |
v0, | |||
v1, | |||
v2, | |||
normal = None , |
|||
color = None |
|||
) |
Adds a triangle to the mesh of this mesh builder.
v0 | The first corner of the triangle. |
v1 | The second corner of the triangle. |
v2 | The third corner of the triangle. |
normal | (Optional) The normal vector for the triangle. If no normal vector is provided, it will be calculated automatically. |
color | (Optional) The colour for the triangle. If no colour is provided, the colour is determined by the shader. |
def UM.Mesh.MeshBuilder.MeshBuilder.addFaceByPoints | ( | self, | |
x0, | |||
y0, | |||
z0, | |||
x1, | |||
y1, | |||
z1, | |||
x2, | |||
y2, | |||
z2 | |||
) |
Add a face by providing three verts.
x0 | x coordinate of first vertex. |
y0 | y coordinate of first vertex. |
z0 | z coordinate of first vertex. |
x1 | x coordinate of second vertex. |
y1 | y coordinate of second vertex. |
z1 | z coordinate of second vertex. |
x2 | x coordinate of third vertex. |
y2 | y coordinate of third vertex. |
z2 | z coordinate of third vertex. |
def UM.Mesh.MeshBuilder.MeshBuilder.addFacesWithColor | ( | self, | |
vertices, | |||
indices, | |||
colors | |||
) |
Add faces defined by indices into vertices with vetex colors defined by colors Assumes vertices and colors have the same length.
vertices | is a numpy array where each row corresponds to a 3D point used to define the faces. |
indices | consists of row triplet indices into the input vertices to build up the triangular faces. |
colors | defines the color of each vertex in vertices . |
def UM.Mesh.MeshBuilder.MeshBuilder.addFaceWithNormals | ( | self, | |
x0, | |||
y0, | |||
z0, | |||
nx0, | |||
ny0, | |||
nz0, | |||
x1, | |||
y1, | |||
z1, | |||
nx1, | |||
ny1, | |||
nz1, | |||
x2, | |||
y2, | |||
z2, | |||
nx2, | |||
ny2, | |||
nz2 | |||
) |
Add a face by providing three vertices and the normals that go with those vertices.
x0 | The X coordinate of the first vertex. |
y0 | The Y coordinate of the first vertex. |
z0 | The Z coordinate of the first vertex. |
nx0 | The X coordinate of the normal of the first vertex. |
ny0 | The Y coordinate of the normal of the first vertex. |
nz0 | The Z coordinate of the normal of the first vertex. |
x1 | The X coordinate of the second vertex. |
y1 | The Y coordinate of the second vertex. |
z1 | The Z coordinate of the second vertex. |
nx1 | The X coordinate of the normal of the second vertex. |
ny1 | The Y coordinate of the normal of the second vertex. |
nz1 | The Z coordinate of the normal of the second vertex. |
x2 | The X coordinate of the third vertex. |
y2 | The Y coordinate of the third vertex. |
z2 | The Z coordinate of the third vertex. |
nx2 | The X coordinate of the normal of the third vertex. |
ny2 | The Y coordinate of the normal of the third vertex. |
nz2 | The Z coordinate of the normal of the third vertex. |
def UM.Mesh.MeshBuilder.MeshBuilder.addLine | ( | self, | |
v0, | |||
v1, | |||
color = None |
|||
) |
Adds a 3-dimensional line to the mesh of this mesh builder.
v0 | One endpoint of the line to add. |
v1 | The other endpoint of the line to add. |
color | (Optional) The colour of the line, if any. If no colour is provided, the colour is determined by the shader. |
def UM.Mesh.MeshBuilder.MeshBuilder.addPyramid | ( | self, | |
width, | |||
height, | |||
depth, | |||
angle = 0 , |
|||
axis = Vector.Unit_Y , |
|||
center = Vector(0, 0 , |
|||
color = None |
|||
) |
Adds a pyramid to the mesh of this mesh builder.
width | The width of the base of the pyramid. |
height | The height of the pyramid (from base to notch). |
depth | The depth of the base of the pyramid. |
angle | (Optional) An angle of rotation to rotate the pyramid by, in degrees. |
axis | (Optional) An axis of rotation to rotate the pyramid around. If no axis is provided and the angle of rotation is nonzero, the pyramid will be rotated around the Y-axis. |
center | (Optional) The position of the centre of the base of the pyramid. If not provided, the pyramid will be placed on the coordinate origin. |
color | (Optional) The colour of the pyramid. If no colour is provided, a colour will be determined by the shader. |
def UM.Mesh.MeshBuilder.MeshBuilder.addQuad | ( | self, | |
v0, | |||
v1, | |||
v2, | |||
v3, | |||
normal = None , |
|||
color = None |
|||
) |
Add a quadrilateral to the mesh of this mesh builder.
The quadrilateral will be constructed as two triangles. v0 and v2 are the two vertices across the diagonal of the quadrilateral.
v0 | The first corner of the quadrilateral. |
v1 | The second corner of the quadrilateral. |
v2 | The third corner of the quadrilateral. |
v3 | The fourth corner of the quadrilateral. |
normal | (Optional) The normal vector for the quadrilateral. Both triangles will get the same normal vector, if provided. If no normal vector is provided, the normal vectors for both triangles are computed automatically. |
color | (Optional) The colour for the quadrilateral. If no colour is provided, the colour is determined by the shader. |
def UM.Mesh.MeshBuilder.MeshBuilder.addVertex | ( | self, | |
x | |||
) |
Add a vertex to the mesh.
x | x coordinate of vertex. |
y | y coordinate of vertex. |
z | z coordinate of vertex. |
def UM.Mesh.MeshBuilder.MeshBuilder.addVertexWithNormal | ( | self, | |
x, | |||
y, | |||
z, | |||
nx, | |||
ny, | |||
nz | |||
) |
Add a vertex to the mesh.
x | x coordinate of vertex. |
y | y coordinate of vertex. |
z | z coordinate of vertex. |
nx | x part of normal. |
ny | y part of normal. |
nz | z part of normal. |
def UM.Mesh.MeshBuilder.MeshBuilder.build | ( | self, | |
MeshData | |||
) |
Build a MeshData object.
def UM.Mesh.MeshBuilder.MeshBuilder.calculateNormals | ( | self, | |
fast = False |
|||
) |
Calculate the normals of this mesh, assuming it was created by using addFace (eg; the verts are connected)
Keyword arguments:
def UM.Mesh.MeshBuilder.MeshBuilder.getIndices | ( | self, | |
Optional, | |||
numpy, | |||
ndarray | |||
) |
Get the array of indices.
def UM.Mesh.MeshBuilder.MeshBuilder.getNormals | ( | self, | |
Optional, | |||
numpy, | |||
ndarray | |||
) |
Return the list of vertex normals.
def UM.Mesh.MeshBuilder.MeshBuilder.hasIndices | ( | self | ) |
Return whether this mesh has indices.
def UM.Mesh.MeshBuilder.MeshBuilder.hasNormals | ( | self | ) |
Return whether this mesh has vertex normals.
def UM.Mesh.MeshBuilder.MeshBuilder.reserveFaceAndVertexCount | ( | self, | |
num_faces, | |||
num_vertices | |||
) |
Set the amount of faces and vertices before loading data to the mesh.
This way we can create the array before we fill it. This method will reserve num_vertices
amount of space for vertices, num_vertices
amount of space for colors and num_faces
amount of space for indices.
num_faces | Number of faces for which memory must be reserved. |
num_vertices | Number of vertices for which memory must be reserved. |
def UM.Mesh.MeshBuilder.MeshBuilder.reserveFaceCount | ( | self, | |
num_faces | |||
) |
Set the amount of faces before loading data to the mesh.
This way we can create the array before we fill it. This method will reserve (num_faces * 3)
amount of space for vertices, (num_faces * 3)
amount of space for normals and num_faces
amount of space for indices.
num_faces | Number of faces for which memory must be reserved. |
def UM.Mesh.MeshBuilder.MeshBuilder.reserveVertexCount | ( | self, | |
num_vertices | |||
) |
Preallocate space for vertices before loading data to the mesh.
This way we can create the array before we fill it. This method will reserve num_vertices
amount of space for vertices. It deletes any existing normals and indices but does not reserve space for them.
num_vertices | Number of verts to be reserved. |
def UM.Mesh.MeshBuilder.MeshBuilder.setColors | ( | self, | |
colors | |||
) |
/param colors is a vertexCount by 4 numpy array with floats in range of 0 to 1.
def UM.Mesh.MeshBuilder.MeshBuilder.setType | ( | self, | |
mesh_type | |||
) |
Set the type of the mesh.
mesh_type | MeshType enum |
def UM.Mesh.MeshBuilder.MeshBuilder.setVertexColor | ( | self, | |
index, | |||
color | |||
) |
Sets the color for a vertex.
index | int the index of the vertex in the vertices array. |
color | UM.Math.Color the color of the vertex. |