UnityUtilities
UnityUtilities.MeshCreator Class Reference

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< MeshVertexMeshVertices [get]
 The registered vertices. Use AddVertex to add a vertex. Content of existing vertices can be freely updated. More...
 
List< MeshTriangleMeshTriangles [get]
 The registered triangles. Use AddTriangle or AddQuad to add triangles. More...
 

Detailed Description

Stores the vertex/triangle data of a mesh in easily modifiable form - which can then be used to actually create or update a mesh.

Constructor & Destructor Documentation

§ MeshCreator()

UnityUtilities.MeshCreator.MeshCreator ( int  estimatedTriangleCount,
int  estimatedVertexCount 
)

Creates a new MeshCreator.

Parameters
estimatedTriangleCountUsed to create the initial size of the MeshTriangles list.
estimatedVertexCountUsed to set the initial size of the MeshVertices list.

Member Function Documentation

§ AddQuad()

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.

Parameters
aThe first vertex in clockwise order.
bThe second vertex in clockwise order.
cThe third vertex in clockwise order.
dThe fourth vertex in clockwise order.

§ AddTriangle()

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.

Parameters
aThe first vertex in clockwise order.
bThe second vertex in clockwise order.
cThe third vertex in clockwise order.
Returns
The created triangle.

§ AddVertex()

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.

Parameters
vertexThe vertex to be added.

§ Clear()

void UnityUtilities.MeshCreator.Clear ( )

Clear the triangles and vertices.

§ CreateMesh()

Mesh UnityUtilities.MeshCreator.CreateMesh ( )

Creates a new mesh and fills it via UpdateMesh.

Returns
The filled mesh.

§ 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.

Parameters
meshThe mesh to be updated.
updatePositionsShould the vertex positions be updated?
updateNormalsShould the vertex normals be updated?
updateColorsShould the vertex colors be updated?
updateUVsShould the UVs be updated?
updateTrianglesShould 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.
Returns
The filled mesh.

Property Documentation

§ MeshTriangles

List<MeshTriangle> UnityUtilities.MeshCreator.MeshTriangles
get

The registered triangles. Use AddTriangle or AddQuad to add triangles.

§ MeshVertices

List<MeshVertex> UnityUtilities.MeshCreator.MeshVertices
get

The registered vertices. Use AddVertex to add a vertex. Content of existing vertices can be freely updated.

§ MeshVerticesCount

int UnityUtilities.MeshCreator.MeshVerticesCount
get

The amount of registered vertices.


The documentation for this class was generated from the following file: