## Libraries.Game.Graphics.MeshBuilder Documentation

*Inherits from: *Libraries.Language.Object

## Summary

### Variable Summary Table

Variables | Description |
---|---|

integer TRIANGLES | The TRIANGLES value is one of the possible primitive type values. The Mesh will form triangles from triplets of vertices. |

integer LINES | The LINES value is one of the possible primitive type values. The Mesh will form lines using pairs of vertices. |

integer POINTS | The POINTS value is one of the possible primitive type values. It is used to indicate that each vertex of the Mesh should be considered an individual point, separate from the other vertices. |

### Actions Summary Table

## Actions Documentation

### AddIndex(integer value)

This action will add a new index to the indices of the Mesh under construction.

#### Parameters

### AddLine(Libraries.Game.Graphics.VertexSchematic point1, Libraries.Game.Graphics.VertexSchematic point2)

This action will add two new vertices to the current Mesh under construction, and then create a line between them. This is only valid if the primitive type being used is LINES - otherwise, an error will be thrown.

#### Parameters

### AddLine(integer index1, integer index2)

This action will create a new line between the two given indices in the Mesh under construction. This is only valid if the primitive type being used is LINES - otherwise, an error will be thrown.

#### Parameters

### AddLine(number x1, number y1, number z1, number x2, number y2, number z2)

This action will add two new vertices to the current Mesh under construction, and then create a line between them. This is only valid if the primitive type being used is LINES - otherwise, an error will be thrown.

#### Parameters

### AddLine(Libraries.Compute.Vector3 point1, Libraries.Game.Graphics.Color color1, Libraries.Compute.Vector3 point2, Libraries.Game.Graphics.Color color2)

This action will add two new vertices to the current Mesh under construction, and then create a line between them. This is only valid if the primitive type being used is LINES - otherwise, an error will be thrown.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Game.Graphics.Color
- Libraries.Compute.Vector3
- Libraries.Game.Graphics.Color

### AddLine(Libraries.Compute.Vector3 point1, Libraries.Compute.Vector3 point2)

#### Parameters

### AddMesh(Libraries.Containers.Array<number> vertices, Libraries.Containers.Array<integer> indices)

This action will add the given vertex and index arrays to the geometry of the Mesh currently under construction by the MeshBuilder.

#### Parameters

### AddTriangle(Libraries.Game.Graphics.VertexSchematic point1, Libraries.Game.Graphics.VertexSchematic point2, Libraries.Game.Graphics.VertexSchematic point3)

This action will add three new vertices to the Mesh under construction, and create a triangle between them. The primitive type used must be POINTS, LINES, or TRIANGLES. Otherwise, an error will be thrown.

#### Parameters

- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic

### AddTriangle(integer index1, integer index2, integer index3)

This action will create a new triangle between the three given indices in the Mesh under construction. This is only valid if the primitive type being used is either POINTS, LINES, or TRIANGLES. Otherwise, an error will be thrown.

#### Parameters

### AddTriangle(Libraries.Compute.Vector3 point1, Libraries.Game.Graphics.Color color1, Libraries.Compute.Vector3 point2, Libraries.Game.Graphics.Color color2, Libraries.Compute.Vector3 point3, Libraries.Game.Graphics.Color color3)

This action will add three new vertices to the Mesh under construction, and create a triangle between them. The primitive type used must be POINTS, LINES, or TRIANGLES. Otherwise, an error will be thrown.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Game.Graphics.Color
- Libraries.Compute.Vector3
- Libraries.Game.Graphics.Color
- Libraries.Compute.Vector3
- Libraries.Game.Graphics.Color

### AddTriangle(Libraries.Compute.Vector3 point1, Libraries.Compute.Vector3 point2, Libraries.Compute.Vector3 point3)

This action will add three new vertices to the Mesh under construction, and create a triangle between them. The primitive type used must be POINTS, LINES, or TRIANGLES. Otherwise, an error will be thrown.

#### Parameters

### AddVertex(Libraries.Game.Graphics.VertexSchematic schematic)

This action will add the vertex described by the given VertexSchematic to the Mesh currently under construction. This action will return the index of the newly added vertex.

#### Parameters

#### Return

integer:

### AddVertex(Libraries.Compute.Vector3 pos, Libraries.Compute.Vector3 norm, Libraries.Game.Graphics.Color col, Libraries.Compute.Vector2 uv)

This action will create a new vertex and add it to the Mesh currently under construction. The index of the newly created vertex will be returned.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Game.Graphics.Color
- Libraries.Compute.Vector2

#### Return

integer:

### Begin(Libraries.Game.Graphics.VertexAttributes vAttributes)

This action informs the MeshBuilder to begin constructing a new mesh. If a mesh is already in construction, this will throw an error.

#### Parameters

### Begin(Libraries.Game.Graphics.VertexAttributes vAttributes, integer type)

This action informs the MeshBuilder to begin constructing a new mesh. If a mesh is already in construction, this will throw an error. The VertexAttributes must contain at least a Position attribute, and can also contain Normal, Binormal, Tangent, ColorUnpacked, ColorPacked, or TextureCoordinates attributes. The type should be one of the primitive type constants in the MeshBuilder: POINTS, LINES, or TRIANGLES.

#### Parameters

### BuildBox(Libraries.Compute.Vector3 corner000, Libraries.Compute.Vector3 corner010, Libraries.Compute.Vector3 corner100, Libraries.Compute.Vector3 corner110, Libraries.Compute.Vector3 corner001, Libraries.Compute.Vector3 corner011, Libraries.Compute.Vector3 corner101, Libraries.Compute.Vector3 corner111)

This action will create a box using the 8 provided vertices.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3

### BuildBox(Libraries.Game.Graphics.VertexSchematic corner000, Libraries.Game.Graphics.VertexSchematic corner010, Libraries.Game.Graphics.VertexSchematic corner100, Libraries.Game.Graphics.VertexSchematic corner110, Libraries.Game.Graphics.VertexSchematic corner001, Libraries.Game.Graphics.VertexSchematic corner011, Libraries.Game.Graphics.VertexSchematic corner101, Libraries.Game.Graphics.VertexSchematic corner111)

This action will create a box using the 8 provided vertices.

#### Parameters

- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic

### BuildBox(number width, number height, number depth)

This action will build a box with the given width, height, and depth.

#### Parameters

### BuildBox(number x, number y, number z, number width, number height, number depth)

This action will build a box at the provided coordinates with the given width, height, and depth.

#### Parameters

### BuildCylinder(number width, number height, number depth, integer divisions)

This action will build a cylinder shape with the given width, height, and depth. The curve of the cylinder will be made using the provided number of divisions to approximate the curve using straight edges.

#### Parameters

### BuildCylinder(number width, number height, number depth, integer divisions, number angleFrom, number angleTo, boolean close)

This action will build a cylinder shape with the given width, height, and depth. The curve of the cylinder will be made using the provided number of divisions to form straight edges from the starting angle to the ending angle (in degrees). If the provided boolean is true, the cylinder will be closed (the ends will be capped). Otherwise, the cylinder will be open (the ends will not be capped).

#### Parameters

### BuildCylinder(number width, number height, number depth, integer divisions, number angleFrom, number angleTo)

This action will build a cylinder shape with the given width, height, and depth. The curve of the cylinder will be made using the provided number of divisions to form straight edges from the starting angle to the ending angle (in degrees).

#### Parameters

### BuildEllipse(number width, number height, integer divisions, Libraries.Compute.Vector3 center, Libraries.Compute.Vector3 normal, number angleFrom, number angleTo)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, number innerWidth, number innerHeight, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ, number angleFrom, number angleTo)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, integer divisions, Libraries.Compute.Vector3 center, Libraries.Compute.Vector3 normal, Libraries.Compute.Vector3 tangent, Libraries.Compute.Vector3 binormal)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3

### BuildEllipse(number width, number height, number innerWidth, number innerHeight, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ, number tangentX, number tangentY, number tangentZ, number binormalX, number binormalY, number binormalZ, number angleFrom, number angleTo)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, number innerWidth, number innerHeight, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ, number angleFrom, number angleTo)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, number innerWidth, number innerHeight, integer divisions, Libraries.Compute.Vector3 center, Libraries.Compute.Vector3 normal)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ, number tangentX, number tangentY, number tangentZ, number binormalX, number binormalY, number binormalZ, number angleFrom, number angleTo)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, integer divisions, Libraries.Compute.Vector3 center, Libraries.Compute.Vector3 normal, Libraries.Compute.Vector3 tangent, Libraries.Compute.Vector3 binormal, number angleFrom, number angleTo)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3

### BuildEllipse(number width, number height, integer divisions, Libraries.Compute.Vector3 center, Libraries.Compute.Vector3 normal)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ, number tangentX, number tangentY, number tangentZ, number binormalX, number binormalY, number binormalZ)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildEllipse(number width, number height, integer divisions, number centerX, number centerY, number centerZ, number normalX, number normalY, number normalZ)

This action will add an ellipse to the geometry of the mesh that is under construction.

#### Parameters

### BuildRectangle(integer corner00, integer corner10, integer corner11, integer corner01)

This action will add a new Rectangle to the Mesh under construction, using the given indices to form the rectangle. The supported primitive types are POINTS, LINES, and TRIANGLES - any other primitive type will throw an error.

#### Parameters

### BuildRectangle(Libraries.Game.Graphics.VertexSchematic corner00, Libraries.Game.Graphics.VertexSchematic corner10, Libraries.Game.Graphics.VertexSchematic corner11, Libraries.Game.Graphics.VertexSchematic corner01)

This action will add four new vertices to the Mesh under construction, and form a rectangle between them. The primitive type used must be POINTS, LINES, or TRIANGLES - otherwise, an error will be thrown.

#### Parameters

- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic
- Libraries.Game.Graphics.VertexSchematic

### BuildRectangle(Libraries.Compute.Vector3 corner00, Libraries.Compute.Vector3 corner10, Libraries.Compute.Vector3 corner11, Libraries.Compute.Vector3 corner01, Libraries.Compute.Vector3 normal)

This action will add four new vertices to the Mesh under construction, and form a rectangle between them. The primitive type used must be POINTS, LINES, or TRIANGLES - otherwise, an error will be thrown.

#### Parameters

- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3
- Libraries.Compute.Vector3

### BuildSphere(number width, number height, number depth, integer divisionsU, integer divisionsV, number angleUFrom, number angleUTo, number angleVFrom, number angleVTo)

This action will add a sphere to the geometry of the mesh under construction.

#### Parameters

### BuildSphere(number width, number height, number depth, integer divisionsU, integer divisionsV)

This action will add a sphere to the geometry of the mesh under construction.

#### Parameters

### Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

**Example Code**

```
use Libraries.Language.Support.CompareResult
Object o
Object t
CompareResult result = o:Compare(t)
```

#### Parameters

- Libraries.Language.Object: The object to compare to.

#### Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

### Empty()

Empties the data being built up until now, including the vertices, indices, and all parts. Must be called between Begin() and End() to have any effect. This effectively discards all work done since the initial Begin(), but will not reset state such as UV region, color, or vertex transform.

### End()

This action will finish construction of the current Mesh, and then return it.

#### Return

### EnsureIndices(integer numIndices)

This action will ensure that the current Mesh under construction will support all of its current indices, plus the given number of additional indices.

#### Parameters

### EnsureRectangleIndices(integer numRectangles)

This action will guarantee that the Mesh under construction will have the proper number of indices to form the given number of rectangles, based on what primitive type has already been set for the Mesh.

#### Parameters

### EnsureTriangleIndices(integer numTriangles)

This action will guarantee that the Mesh under construction will have the proper number of indices to form the given number of triangles, based on what primitive type has already been set for the Mesh.

#### Parameters

### EnsureVertices(integer numVertices)

This action will ensure that the current Mesh under construction will have enough room to store the given number of vertices, in addition to what it is currently storing.

#### Parameters

### Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

**Example Code**

```
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
```

#### Parameters

- Libraries.Language.Object: The to be compared.

#### Return

boolean: True if the hash codes are equal and false if they are not equal.

### GetAttributes()

This action will return the attributes that were given for the current Mesh under construction. If there isn't a Mesh currently being built, this will be undefined.

#### Return

Libraries.Game.Graphics.VertexAttributes:

### GetHashCode()

This action gets the hash code for an object.

**Example Code**

```
Object o
integer hash = o:GetHashCode()
```

#### Return

integer: The integer hash code of the object.

### GetIndices()

This action will return a copy of the indices that have been built so far. This action is only valid between calls to Begin() and End() - otherwise, this action will throw an error.

#### Return

### GetIndicesCount()

This action will return the number of indices that has been built so far in the Mesh currently under construction. This is only valid between calls to Begin() and End().

#### Return

integer:

### GetLastIndex()

This action will return what the last index used was during the construction of a Mesh.

#### Return

integer:

### GetMeshPart()

This action will return the MeshPart currently under construction by the MeshBuilder. If there isn't a MeshPart under construction, then this will be undefined.

#### Return

Libraries.Game.Graphics.ModelData.MeshPart:

### GetPrimitiveType()

This action will return the primitive type being used to define the geometry of the current Mesh under construction. The primitive type is an integer value that represents an OpenGL constant, such as TRIANGLES.

#### Return

integer:

### GetVertexSize()

This action will return the amount of number components that makes up each vertex.

#### Return

integer:

### GetVertexTransform()

This action will return a new Matrix4 object containing a copy of the vertex transformation matrix that the current Mesh being built is using.

#### Return

### GetVertices()

This action will return a copy of all of the vertices built so far. This action must be called between Begin() and End() - otherwise, an error will be thrown.

#### Return

### GetVerticesCount()

This action returns the number of vertices that have been built so far for the current Mesh under construction. This will only return a valid result if used between calls to Begin() and End().

#### Return

number:

### IsVertexTransformationEnabled()

This action will return whether or not the Mesh under construction is currently using a Matrix4 to transform its vertices.

#### Return

boolean:

### NewPart(text id, integer type)

This action will start constructing a new MeshPart for the Mesh. The new MeshPart will still not be usable until End() is called. This will reset any current color and vertex transformations.

#### Parameters

#### Return

Libraries.Game.Graphics.ModelData.MeshPart:

### SetColor(Libraries.Game.Graphics.Color newColor)

This action will set the color value of the vertices that are created during Mesh construction.

#### Parameters

### SetColor(number red, number green, number blue, number alpha)

This action will set the color value of the vertices that are created during Mesh construction. The color is made of a red, green, blue, and alpha (or transparency) component.

#### Parameters

### SetUVRange(number u1, number v1, number u2, number v2)

This action will set the UV range that will be applied to the vertices of the Mesh under construction. The UV values are used to determine how a texture should be mapped onto the Mesh.

#### Parameters

### SetUVRange(Libraries.Game.Graphics.TextureRegion region)

This action will set the UV range that will be applied to the vertices of the Mesh under construction. The UV values are used to determine how a texture should be mapped onto the Mesh.

#### Parameters

### SetVertexTransform(Libraries.Compute.Matrix4 transform)

This action will set the transformation matrix for the vertices of the Mesh that is under construction.

#### Parameters

### SetVertexTransformationEnabled(boolean enabled)

This action will set the MeshBuilder to allow for vertex transformation using a Matrix4 object.