3rd Eye Scene C#
3rd Eye Scene C# documentation
Tes::Runtime::MeshBuilder Class Reference

Supports construction of UnityEngine.Mesh objects from raw vertex and index data. More...

List of all members.

Classes

class  PartDetails
 Represents details of part of the mesh. More...

Public Types

enum  DirtyFlag {
  None = 0, Indices = (1 << 0), Vertices = (1 << 1), Normals = (1 << 2),
  Colours = (1 << 3), UVs = (1 << 4), All = Indices | Vertices | Normals | Colours | UVs
}
 Flags identifying which parts of the mesh data are dirty. More...

Public Member Functions

void RecalculateBounds ()
 Forces a full bounds recalculation.
int IndexAt (int iind)
 Query the index at the given index.
Mesh[] GetMeshes ()
 Generate mesh objects or return cached mesh objects.
Mesh[] GetReindexedMeshes (int[] indices, MeshTopology topology)
 Create a set of mesh objects using the given set of indices instead of the stored indices.
void AddVertex (Vector3 v)
 Add a vertex.
void AddVertices (IEnumerable< Vector3 > verts)
 A a number of vertices.
void UpdateVertex (int index, Vector3 v)
 Update the vertex at index , or add a new vertex if index is out of range.
void UpdateVertices (int baseIndex, IEnumerable< Vector3 > verts)
 Update the vertices starting at baseIndex , or add a new vertices if out of range.
void AddIndex (int i)
 Add a single mesh index.
void AddIndices (IEnumerable< int > inds)
 Add a range of indices.
void UpdateIndex (int index, int i)
 Update the index at index , or add a new index if index is out of range.
void UpdateIndices (int baseIndex, IEnumerable< int > inds)
 Update the indices starting at baseIndex , or add a new indices out of range.
void AddNormal (Vector3 n)
 Add a single mesh vertex normal.
void AddNormals (IEnumerable< Vector3 > normals)
 Add a range of vertex normals.
void UpdateNormal (int index, Vector3 n)
 Update the normal at index , or add a new normal if index is out of range.
void UpdateNormals (int baseIndex, IEnumerable< Vector3 > normals)
 Update the normals starting at baseIndex , or add a new normals out of range.
void AddUV (Vector2 uv)
 Add a single UV coordinate.
void AddUVs (IEnumerable< Vector2 > uvs)
 Add a range of UV coordinates.
void UpdateUV (int index, Vector2 uv)
 Update the UV at index , or add a new UV if index is out of range.
void UpdateUVs (int baseIndex, IEnumerable< Vector2 > uvs)
 Update the UVs starting at baseIndex , or add a new UVs out of range.
void AddColour (Color32 c)
 Add a single vertex colour.
void AddColours (IEnumerable< Color32 > colours)
 Add a range of vertex colours.
void UpdateColour (int index, Color32 c)
 Update the colour at index , or add a new colour if index is out of range.
void UpdateColours (int baseIndex, IEnumerable< Color32 > colours)
 Update the colours beginning at baseIndex , or add a new colour if out of range.

Static Public Member Functions

static int GetTopologyIndexStep (MeshTopology topology)
 Query the number of indices per element for topology .

Public Attributes

const int UnityIndexLimit = 65000
 Limit on the number of indices per Mesh part imposed by Unity.
Vector3 BoundsPadding = Vector3.zero
 Padding value applied to the bounds of all generated meshes.

Protected Member Functions

void DirtyVertex (int vertexIndex, DirtyFlag flag)
 Mark some vertex data as dirty.
void DirtyVertices (int firstVertexIndex, int count, DirtyFlag flag)
 Mark a range of vertex data as dirty.
void DirtyIndex (int indexIndex)
 Mark an index as dirty.
void DirtyIndices (int firstIndexIndex, int count)
 Mark a range of indices as dirty.

Static Protected Member Functions

static void EnsureListSize< T > (List< T > list, int requiredCount, T value)
 A utility method which ensures list contains at least requiredCount elements.

Properties

bool Dirty [get]
 Is any part of the mesh data dirty?
MeshTopology Topology [get, set]
 Defines the indexing topology for the mesh objects.
Vector3[] Vertices [get]
 Access the vertex array.
int[] Indices [get]
 Access the index array.
Vector3[] Normals [get]
 Access the normals array.
Color32[] Colours [get]
 Access the colours array.
Vector2[] UVs [get]
 Access the uvs array.
int TopologyIndexStep [get]
 Query the per primitive index count for this mesh.
bool CalculateNormals [get, set]
 Calculate per vertex normals during construction?
int IndexCount [get]
 Gets the number of indices across the complete mesh data.
bool ExplicitIndices [get]
 Has a set of explicit indices been provided, or are vertices indexed in sequence?
int VertexCount [get]
 Returns the number of vertices in the mesh.

Detailed Description

Supports construction of UnityEngine.Mesh objects from raw vertex and index data.

This class supports taking arbitrarily large meshes and breaking them up into multiple UnityEngine.Mesh objects, respecting the indexing limits of that mesh class.

The class also supports updating mesh data and rebuilding the mesh objects, though it is not intended for highly dynamic meshes. That is, the update support is intended for sporadic updates rather than per frame updates of all vertex data.

The class attempts to discriminately rebuild only components which need it using various dirty flags.

Note: it is up to the caller to maintain valid element counts in the various containers.


Member Enumeration Documentation

Flags identifying which parts of the mesh data are dirty.

Enumerator:
None 

Zero flag.

Indices 

Indices have been modified.

Vertices 

Indices have been modified.

Normals 

Normals have been modified.

Colours 

Vertex colours have been modified.

UVs 

UV coordinates have been modified.

All 

Everything is dirty.


Member Function Documentation

void Tes::Runtime::MeshBuilder::AddColour ( Color32  c) [inline]

Add a single vertex colour.

Parameters:
cThe colour to add.
void Tes::Runtime::MeshBuilder::AddColours ( IEnumerable< Color32 >  colours) [inline]

Add a range of vertex colours.

Parameters:
coloursThe range of elements to add.
void Tes::Runtime::MeshBuilder::AddIndex ( int  i) [inline]

Add a single mesh index.

Parameters:
iThe index value to add.
void Tes::Runtime::MeshBuilder::AddIndices ( IEnumerable< int >  inds) [inline]

Add a range of indices.

Parameters:
indsThe element to add.
void Tes::Runtime::MeshBuilder::AddNormal ( Vector3  n) [inline]

Add a single mesh vertex normal.

Parameters:
nThe normal to add.
void Tes::Runtime::MeshBuilder::AddNormals ( IEnumerable< Vector3 >  normals) [inline]

Add a range of vertex normals.

Parameters:
normalsThe range of elements to add.
void Tes::Runtime::MeshBuilder::AddUV ( Vector2  uv) [inline]

Add a single UV coordinate.

Parameters:
uvThe UV coordinate to add.
void Tes::Runtime::MeshBuilder::AddUVs ( IEnumerable< Vector2 >  uvs) [inline]

Add a range of UV coordinates.

Parameters:
uvsThe range of elements to add.
void Tes::Runtime::MeshBuilder::AddVertex ( Vector3  v) [inline]

Add a vertex.

Parameters:
vThe vertex to add.
void Tes::Runtime::MeshBuilder::AddVertices ( IEnumerable< Vector3 >  verts) [inline]

A a number of vertices.

Parameters:
vertsThe vertices to add.
void Tes::Runtime::MeshBuilder::DirtyIndex ( int  indexIndex) [inline, protected]

Mark an index as dirty.

Parameters:
indexIndexIdentifies the index of interest.
void Tes::Runtime::MeshBuilder::DirtyIndices ( int  firstIndexIndex,
int  count 
) [inline, protected]

Mark a range of indices as dirty.

Parameters:
firstIndexIndexIdentifies the first index of interest.
countThe number of indices to dirty.
void Tes::Runtime::MeshBuilder::DirtyVertex ( int  vertexIndex,
DirtyFlag  flag 
) [inline, protected]

Mark some vertex data as dirty.

Parameters:
vertexIndexIdentifies the vertex of interest.
flagThe dirty flag to apply. Should be one of the vertex related values.
void Tes::Runtime::MeshBuilder::DirtyVertices ( int  firstVertexIndex,
int  count,
DirtyFlag  flag 
) [inline, protected]

Mark a range of vertex data as dirty.

Parameters:
firstVertexIndexIdentifies the first vertex of interest.
countThe number of vertices to dirty.
flagThe dirty flag to apply. Should be one of the vertex related values.
static void Tes::Runtime::MeshBuilder::EnsureListSize< T > ( List< T >  list,
int  requiredCount,
value 
) [inline, static, protected]

A utility method which ensures list contains at least requiredCount elements.

value is added to pad the list as required.

Template Parameters:
TList content type.
Parameters:
listThe list to potentially expand.
requiredCountThe required number of elements in list .
valueThe value to add which additional elements are required.
Mesh [] Tes::Runtime::MeshBuilder::GetMeshes ( ) [inline]

Generate mesh objects or return cached mesh objects.

Returns:
The mesh objects required to represent the stored mesh data.

This may generate new mesh objects when the mesh data are Dirty or return a cached set of objects.

Mesh [] Tes::Runtime::MeshBuilder::GetReindexedMeshes ( int[]  indices,
MeshTopology  topology 
) [inline]

Create a set of mesh objects using the given set of indices instead of the stored indices.

Returns:
The mesh objects created from by using indices with the stored vertex data.
Parameters:
indicesThe index data to use with the given meshes.
topologyThe topology of the given index set.

This supports creating a sub-mesh using indices from the stored mesh data. The topology may also be changed by specifying a different topology to that of this builder. The indices are assumed to suit the specified topology.

This method never uses cached meshes and is only recommended for small index sets.

static int Tes::Runtime::MeshBuilder::GetTopologyIndexStep ( MeshTopology  topology) [inline, static]

Query the number of indices per element for topology .

Parameters:
topologyThe mesh topology
Returns:
The number of indices per primitive.
TypeIndex Count
MeshTopology.Points1
MeshTopology.LineStrip1 (not supported).
MeshTopology.Lines2
MeshTopology.Triangles3
MeshTopology.Quads4
Else1
int Tes::Runtime::MeshBuilder::IndexAt ( int  iind) [inline]

Query the index at the given index.

Parameters:
iindThe index index to query.
Returns:
The index at iind

This is a convenience function which caters for inferred, sequential indexing (no explicit indices). It either returns an index from the index array, or returns iind when indexing is inferred. No bounds checking.

void Tes::Runtime::MeshBuilder::RecalculateBounds ( ) [inline]

Forces a full bounds recalculation.

This forces a full mesh rebuild on the next call to GetMeshes().

void Tes::Runtime::MeshBuilder::UpdateColour ( int  index,
Color32  c 
) [inline]

Update the colour at index , or add a new colour if index is out of range.

Parameters:
indexThe index of the colour of interest.
cThe new colour value.
void Tes::Runtime::MeshBuilder::UpdateColours ( int  baseIndex,
IEnumerable< Color32 >  colours 
) [inline]

Update the colours beginning at baseIndex , or add a new colour if out of range.

Parameters:
baseIndexThe index of the first colour of interest.
coloursThe new colour values.
void Tes::Runtime::MeshBuilder::UpdateIndex ( int  index,
int  i 
) [inline]

Update the index at index , or add a new index if index is out of range.

Parameters:
indexThe index of the index of interest.
iThe new index value.
void Tes::Runtime::MeshBuilder::UpdateIndices ( int  baseIndex,
IEnumerable< int >  inds 
) [inline]

Update the indices starting at baseIndex , or add a new indices out of range.

Parameters:
baseIndexThe index of the first index of interest.
indsThe new index values.
void Tes::Runtime::MeshBuilder::UpdateNormal ( int  index,
Vector3  n 
) [inline]

Update the normal at index , or add a new normal if index is out of range.

Parameters:
indexThe index of the normal of interest.
nThe new normal value.
void Tes::Runtime::MeshBuilder::UpdateNormals ( int  baseIndex,
IEnumerable< Vector3 >  normals 
) [inline]

Update the normals starting at baseIndex , or add a new normals out of range.

Parameters:
baseIndexThe index of the first normal of interest.
normalsThe new normal values.
void Tes::Runtime::MeshBuilder::UpdateUV ( int  index,
Vector2  uv 
) [inline]

Update the UV at index , or add a new UV if index is out of range.

Parameters:
indexThe index of the vertex of interest.
uvThe new uv value.
void Tes::Runtime::MeshBuilder::UpdateUVs ( int  baseIndex,
IEnumerable< Vector2 >  uvs 
) [inline]

Update the UVs starting at baseIndex , or add a new UVs out of range.

Parameters:
baseIndexThe index of the vertex of interest.
uvsThe new uv values.
void Tes::Runtime::MeshBuilder::UpdateVertex ( int  index,
Vector3  v 
) [inline]

Update the vertex at index , or add a new vertex if index is out of range.

Parameters:
indexThe index of the vertex of interest.
vThe new vertex value.
void Tes::Runtime::MeshBuilder::UpdateVertices ( int  baseIndex,
IEnumerable< Vector3 >  verts 
) [inline]

Update the vertices starting at baseIndex , or add a new vertices if out of range.

Parameters:
baseIndexThe index of the first vertex of interest.
vertsThe new vertex values.

Member Data Documentation

Padding value applied to the bounds of all generated meshes.

Only effected on subsequent mesh reconstructions.


Property Documentation

bool Tes::Runtime::MeshBuilder::CalculateNormals [get, set]

Calculate per vertex normals during construction?

This may prove expensive for large meshes.

Color32 [] Tes::Runtime::MeshBuilder::Colours [get]

Access the colours array.

Intended for read only access.

bool Tes::Runtime::MeshBuilder::Dirty [get]

Is any part of the mesh data dirty?

true if dirty; otherwise, false.

bool Tes::Runtime::MeshBuilder::ExplicitIndices [get]

Has a set of explicit indices been provided, or are vertices indexed in sequence?

int Tes::Runtime::MeshBuilder::IndexCount [get]

Gets the number of indices across the complete mesh data.

This is based in the number of indices added when indices have been added, or based on the number of vertices when no indices have been added. In the latter case, sequential indexing of vertices is assumed.

int [] Tes::Runtime::MeshBuilder::Indices [get]

Access the index array.

Intended for read only access.

Vector3 [] Tes::Runtime::MeshBuilder::Normals [get]

Access the normals array.

Intended for read only access.

int Tes::Runtime::MeshBuilder::TopologyIndexStep [get]

Query the per primitive index count for this mesh.

See GetTopologyIndexStep(MeshTopology).

Vector2 [] Tes::Runtime::MeshBuilder::UVs [get]

Access the uvs array.

Intended for read only access.

Vector3 [] Tes::Runtime::MeshBuilder::Vertices [get]

Access the vertex array.

Intended for read only access.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Enumerations Properties Events