UnityUtilities
|
Stores the vertex/triangle data of a mesh in easily modifiable form - which can then be used to actually create or update a mesh. More...
Public Member Functions | |
MeshCreator (int estimatedTriangleCount, int estimatedVertexCount) | |
Creates a new MeshCreator. More... | |
void | Clear () |
Clear the triangles and vertices. More... | |
MeshVertex | AddVertex (MeshVertex vertex) |
Adds a vertex to the MeshCreator and assigns it a VertexIndex. If it already has a VertexIndex, this method does nothing. More... | |
MeshTriangle | AddTriangle (MeshVertex a, MeshVertex b, MeshVertex c) |
Adds a triangle to the MeshCreator. Adds the vertices to the MeshCreator if they aren't already added. More... | |
void | AddQuad (MeshVertex a, MeshVertex b, MeshVertex c, MeshVertex d) |
Adds two triangles forming a quad to the MeshCreator. Adds the vertices to the MeshCreator if they aren't already added. More... | |
Mesh | CreateMesh () |
Creates a new mesh and fills it via UpdateMesh. More... | |
Mesh | UpdateMesh (Mesh mesh, bool updatePositions=true, bool updateNormals=true, bool updateColors=true, bool updateUVs=true, bool updateTriangles=true) |
Takes an existing mesh previously created with CreateMesh or UpdateMesh and fills it with the data from this MeshCreator. More... | |
Properties | |
int | MeshVerticesCount [get] |
The amount of registered vertices. More... | |
List< MeshVertex > | MeshVertices [get] |
The registered vertices. Use AddVertex to add a vertex. Content of existing vertices can be freely updated. More... | |
List< MeshTriangle > | MeshTriangles [get] |
The registered triangles. Use AddTriangle or AddQuad to add triangles. More... | |
Stores the vertex/triangle data of a mesh in easily modifiable form - which can then be used to actually create or update a mesh.
UnityUtilities.MeshCreator.MeshCreator | ( | int | estimatedTriangleCount, |
int | estimatedVertexCount | ||
) |
Creates a new MeshCreator.
estimatedTriangleCount | Used to create the initial size of the MeshTriangles list. |
estimatedVertexCount | Used to set the initial size of the MeshVertices list. |
void UnityUtilities.MeshCreator.AddQuad | ( | MeshVertex | a, |
MeshVertex | b, | ||
MeshVertex | c, | ||
MeshVertex | d | ||
) |
Adds two triangles forming a quad to the MeshCreator. Adds the vertices to the MeshCreator if they aren't already added.
a | The first vertex in clockwise order. |
b | The second vertex in clockwise order. |
c | The third vertex in clockwise order. |
d | The fourth vertex in clockwise order. |
MeshTriangle UnityUtilities.MeshCreator.AddTriangle | ( | MeshVertex | a, |
MeshVertex | b, | ||
MeshVertex | c | ||
) |
Adds a triangle to the MeshCreator. Adds the vertices to the MeshCreator if they aren't already added.
a | The first vertex in clockwise order. |
b | The second vertex in clockwise order. |
c | The third vertex in clockwise order. |
MeshVertex UnityUtilities.MeshCreator.AddVertex | ( | MeshVertex | vertex | ) |
Adds a vertex to the MeshCreator and assigns it a VertexIndex. If it already has a VertexIndex, this method does nothing.
vertex | The vertex to be added. |
void UnityUtilities.MeshCreator.Clear | ( | ) |
Clear the triangles and vertices.
Mesh UnityUtilities.MeshCreator.CreateMesh | ( | ) |
Creates a new mesh and fills it via UpdateMesh.
Mesh UnityUtilities.MeshCreator.UpdateMesh | ( | Mesh | mesh, |
bool | updatePositions = true , |
||
bool | updateNormals = true , |
||
bool | updateColors = true , |
||
bool | updateUVs = true , |
||
bool | updateTriangles = true |
||
) |
Takes an existing mesh previously created with CreateMesh or UpdateMesh and fills it with the data from this MeshCreator.
mesh | The mesh to be updated. |
updatePositions | Should the vertex positions be updated? |
updateNormals | Should the vertex normals be updated? |
updateColors | Should the vertex colors be updated? |
updateUVs | Should the UVs be updated? |
updateTriangles | Should the triangle composition be updated? This only needs to be called when you assigned new vertices to triangles, not when vertices changed their data internally. Calling this also triggers updating every other property. |
|
get |
The registered triangles. Use AddTriangle or AddQuad to add triangles.
|
get |
The registered vertices. Use AddVertex to add a vertex. Content of existing vertices can be freely updated.
|
get |
The amount of registered vertices.