3rd Eye Scene C#
3rd Eye Scene C# documentation
|
Supports construction of UnityEngine.Mesh
objects from raw vertex and index data.
More...
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. |
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.
Flags identifying which parts of the mesh data are dirty.
void Tes::Runtime::MeshBuilder::AddColour | ( | Color32 | c | ) | [inline] |
Add a single vertex colour.
c | The colour to add. |
void Tes::Runtime::MeshBuilder::AddColours | ( | IEnumerable< Color32 > | colours | ) | [inline] |
Add a range of vertex colours.
colours | The range of elements to add. |
void Tes::Runtime::MeshBuilder::AddIndex | ( | int | i | ) | [inline] |
Add a single mesh index.
i | The index value to add. |
void Tes::Runtime::MeshBuilder::AddIndices | ( | IEnumerable< int > | inds | ) | [inline] |
Add a range of indices.
inds | The element to add. |
void Tes::Runtime::MeshBuilder::AddNormal | ( | Vector3 | n | ) | [inline] |
Add a single mesh vertex normal.
n | The normal to add. |
void Tes::Runtime::MeshBuilder::AddNormals | ( | IEnumerable< Vector3 > | normals | ) | [inline] |
Add a range of vertex normals.
normals | The range of elements to add. |
void Tes::Runtime::MeshBuilder::AddUV | ( | Vector2 | uv | ) | [inline] |
Add a single UV coordinate.
uv | The UV coordinate to add. |
void Tes::Runtime::MeshBuilder::AddUVs | ( | IEnumerable< Vector2 > | uvs | ) | [inline] |
Add a range of UV coordinates.
uvs | The range of elements to add. |
void Tes::Runtime::MeshBuilder::AddVertex | ( | Vector3 | v | ) | [inline] |
Add a vertex.
v | The vertex to add. |
void Tes::Runtime::MeshBuilder::AddVertices | ( | IEnumerable< Vector3 > | verts | ) | [inline] |
A a number of vertices.
verts | The vertices to add. |
void Tes::Runtime::MeshBuilder::DirtyIndex | ( | int | indexIndex | ) | [inline, protected] |
Mark an index as dirty.
indexIndex | Identifies the index of interest. |
void Tes::Runtime::MeshBuilder::DirtyIndices | ( | int | firstIndexIndex, |
int | count | ||
) | [inline, protected] |
Mark a range of indices as dirty.
firstIndexIndex | Identifies the first index of interest. |
count | The number of indices to dirty. |
void Tes::Runtime::MeshBuilder::DirtyVertex | ( | int | vertexIndex, |
DirtyFlag | flag | ||
) | [inline, protected] |
Mark some vertex data as dirty.
vertexIndex | Identifies the vertex of interest. |
flag | The 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.
firstVertexIndex | Identifies the first vertex of interest. |
count | The number of vertices to dirty. |
flag | The dirty flag to apply. Should be one of the vertex related values. |
static void Tes::Runtime::MeshBuilder::EnsureListSize< T > | ( | List< T > | list, |
int | requiredCount, | ||
T | value | ||
) | [inline, static, protected] |
A utility method which ensures list contains at least requiredCount elements.
value is added to pad the list as required.
T | List content type. |
list | The list to potentially expand. |
requiredCount | The required number of elements in list . |
value | The value to add which additional elements are required. |
Mesh [] Tes::Runtime::MeshBuilder::GetMeshes | ( | ) | [inline] |
Generate mesh objects or return cached mesh objects.
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.
indices | The index data to use with the given meshes. |
topology | The 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 .
topology | The mesh topology |
Type | Index Count |
---|---|
MeshTopology.Points | 1 |
MeshTopology.LineStrip | 1 (not supported). |
MeshTopology.Lines | 2 |
MeshTopology.Triangles | 3 |
MeshTopology.Quads | 4 |
Else | 1 |
int Tes::Runtime::MeshBuilder::IndexAt | ( | int | iind | ) | [inline] |
Query the index at the given index.
iind | The index index to query. |
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.
index | The index of the colour of interest. |
c | The 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.
baseIndex | The index of the first colour of interest. |
colours | The 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.
index | The index of the index of interest. |
i | The 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.
baseIndex | The index of the first index of interest. |
inds | The 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.
index | The index of the normal of interest. |
n | The 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.
baseIndex | The index of the first normal of interest. |
normals | The 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.
index | The index of the vertex of interest. |
uv | The 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.
baseIndex | The index of the vertex of interest. |
uvs | The 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.
index | The index of the vertex of interest. |
v | The 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.
baseIndex | The index of the first vertex of interest. |
verts | The new vertex values. |
Vector3 Tes::Runtime::MeshBuilder::BoundsPadding = Vector3.zero |
Padding value applied to the bounds of all generated meshes.
Only effected on subsequent mesh reconstructions.
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.
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.