APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics.g3d.utils

public Class MeshBuilder

extends Object
implements MeshPartBuilder
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder
Imports
com.badlogic.gdx.graphics.Color, .GL20, .Mesh, .VertexAttribute, .VertexAttributes, .VertexAttributes.Usage, com.badlogic.gdx.graphics.g2d.TextureRegion, com.badlogic.gdx.graphics.g3d.model.MeshPart, com.badlogic.gdx.graphics.g3d.utils.shapebuilders.ArrowShapeBuilder, .BoxShapeBuilder, .CapsuleShapeBuilder, .ConeShapeBuilder, .CylinderShapeBuilder, .EllipseShapeBuilder, .PatchShapeBuilder, .SphereShapeBuilder, com.badlogic.gdx.graphics.glutils.ShaderProgram, com.badlogic.gdx.math.MathUtils, .Matrix3, .Matrix4, .Vector2, .Vector3, com.badlogic.gdx.math.collision.BoundingBox, com.badlogic.gdx.utils.Array, .FloatArray, .GdxRuntimeException, .IntIntMap, .ShortArray

Class to construct a mesh, optionally splitting it into one or more mesh parts. Before you can call any other method you must call begin(VertexAttributes) or begin(VertexAttributes, int). To use mesh parts you must call part(String, int) before you start building the part. The MeshPart itself is only valid after the call to end().
Author
Xoppa

Field Summary

Modifier and TypeField and Description
protected VertexAttributes
attributes

The vertex attributes of the resulting mesh

protected int
biNorOffset

The offset within a vertex to binormal, or -1 if not available

protected final BoundingBox
protected int
colOffset

The offset within an vertex to color, or -1 if not available

protected final Color
color

The color used if no vertex color is specified.

protected int
colSize

The size (in number of floats) of the color attribute

protected int
cpOffset

The offset within an vertex to packed color, or -1 if not available

protected boolean
protected boolean
protected ShortArray
indices

The indices to construct, no size checking is done

private static IntIntMap
protected int
istart

The offset in the indices array when begin() was called, used to define a meshpart.

private int
public static final int
MAX_INDEX

highest index mesh builder can get (64k - 1)

public static final int
MAX_VERTICES

maximum number of vertices mesh builder can hold (64k)

protected final Matrix3
protected int
norOffset

The offset within an vertex to normal, or -1 if not available

protected MeshPart
part

The meshpart currently being created

protected Array<MeshPart>
parts

The parts created between begin and end

protected final Matrix4
protected int
posOffset

The offset within an vertex to position

protected int
posSize

The size (in number of floats) of the position attribute

protected int
primitiveType

The current primitiveType

protected int
stride

The size (in number of floats) of each vertex

protected int
tangentOffset

The offset within a vertex to tangent, or -1 if not available

protected final Color
protected static final ShortArray
private final Vector3
protected static final FloatArray
protected float
uOffset

The UV range used when building

protected float
uScale

The UV range used when building

protected int
uvOffset

The offset within an vertex to texture coordinates, or -1 if not available

protected float[]
protected boolean
protected FloatArray
vertices

The vertices to construct, no size checking is done

protected final MeshPartBuilder.VertexInfo
protected final MeshPartBuilder.VertexInfo
protected final MeshPartBuilder.VertexInfo
protected final MeshPartBuilder.VertexInfo
protected int
vindex

The current vertex index, used for indexing

protected float
vOffset

The UV range used when building

protected float
vScale

The UV range used when building

private static final Vector3

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addMesh(Mesh mesh)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.addMesh.

Copies a mesh to the mesh (part) currently being build.

public void
addMesh(MeshPart meshpart)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.addMesh.

Copies a MeshPart to the mesh (part) currently being build.

public void
addMesh(Mesh mesh, int indexOffset, int numIndices)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.addMesh.

Copies a (part of a) mesh to the mesh (part) currently being build.

public void
addMesh(float[] vertices, short[] indices, int indexOffset, int numIndices)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.addMesh.

Copies a (part of a) mesh to the mesh (part) currently being build.

public void
addMesh(float[] vertices, short[] indices)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.addMesh.

Copies a mesh to the mesh (part) currently being build.

private final void
addVertex(final float[] values, final int offset)

public void
arrow(float x1, float y1, float z1, float x2, float y2, float z2, float capLength, float stemThickness, int divisions)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.arrow.

Deprecated

public void
begin(final long
bitwise mask of the com.badlogic.gdx.graphics.VertexAttributes.Usage, only Position, Color, Normal and TextureCoordinates is supported.
attributes
)

Begin building a mesh.

public void
begin(final VertexAttributes attributes)

Begin building a mesh.

public void
begin(final long
bitwise mask of the com.badlogic.gdx.graphics.VertexAttributes.Usage, only Position, Color, Normal and TextureCoordinates is supported.
attributes
,
int primitiveType)

Begin building a mesh.

public void
begin(final VertexAttributes attributes, int primitiveType)

Begin building a mesh

public void
public void
box(Vector3 corner000, Vector3 corner010, Vector3 corner100, Vector3 corner110, Vector3 corner001, Vector3 corner011, Vector3 corner101, Vector3 corner111)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.box.

Deprecated

public void
public void
box(float width, float height, float depth)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.box.

Deprecated

public void
box(float x, float y, float z, float width, float height, float depth)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.box.

Deprecated

public void
capsule(float radius, float height, int divisions)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.capsule.

Deprecated

public void
circle(float radius, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, final Vector3 center, final Vector3 normal)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, final Vector3 center, final Vector3 normal, final Vector3 tangent, final Vector3 binormal)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float tangentX, float tangentY, float tangentZ, float binormalX, float binormalY, float binormalZ)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, final Vector3 center, final Vector3 normal, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, final Vector3 center, final Vector3 normal, final Vector3 tangent, final Vector3 binormal, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
circle(float radius, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float tangentX, float tangentY, float tangentZ, float binormalX, float binormalY, float binormalZ, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.circle.

Deprecated

public void
clear()

Clears the data being built up until now, including the vertices, indices and all parts.

public void
cone(float width, float height, float depth, int divisions)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.cone.

Deprecated

public void
cone(float width, float height, float depth, int divisions, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.cone.

Deprecated

public static VertexAttributes
createAttributes(long
bitwise mask of the com.badlogic.gdx.graphics.VertexAttributes.Usage, only Position, Color, Normal and TextureCoordinates is supported.
usage
)

public void
cylinder(float width, float height, float depth, int divisions)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.cylinder.

Deprecated

public void
cylinder(float width, float height, float depth, int divisions, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.cylinder.

Deprecated

public void
cylinder(float width, float height, float depth, int divisions, float angleFrom, float angleTo, boolean close)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.cylinder.

Deprecated

public void
ellipse(float width, float height, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, final Vector3 center, final Vector3 normal)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, final Vector3 center, final Vector3 normal, final Vector3 tangent, final Vector3 binormal)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float tangentX, float tangentY, float tangentZ, float binormalX, float binormalY, float binormalZ)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, final Vector3 center, final Vector3 normal, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, final Vector3 center, final Vector3 normal, final Vector3 tangent, final Vector3 binormal, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float tangentX, float tangentY, float tangentZ, float binormalX, float binormalY, float binormalZ, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, float innerWidth, float innerHeight, int divisions, Vector3 center, Vector3 normal)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, float innerWidth, float innerHeight, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, float innerWidth, float innerHeight, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public void
ellipse(float width, float height, float innerWidth, float innerHeight, int divisions, float centerX, float centerY, float centerZ, float normalX, float normalY, float normalZ, float tangentX, float tangentY, float tangentZ, float binormalX, float binormalY, float binormalZ, float angleFrom, float angleTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ellipse.

Deprecated

public Mesh
end(Mesh
The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold the data, any existing data will be overwritten.
mesh
)

End building the mesh and returns the mesh

public Mesh
end()

End building the mesh and returns the mesh

private void
public void
ensureCapacity(int numVertices, int numIndices)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ensureCapacity.

Increases the size of the backing vertices and indices arrays to accommodate the specified number of additional vertices and indices.

public void
ensureIndices(int numIndices)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ensureIndices.

Increases the size of the backing indices array to accommodate the specified number of additional indices.

public void
ensureRectangleIndices(int numRectangles)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ensureRectangleIndices.

Increases the size of the backing indices array to accommodate the specified number of additional rectangles.

public void
ensureRectangles(int numVertices, int numRectangles)
Deprecated use ensureVertices(int) followed by ensureRectangleIndices(int) instead.

public void
ensureRectangles(int numRectangles)
Deprecated use ensureVertices(int) followed by ensureRectangleIndices(int) instead.

public void
ensureTriangleIndices(int numTriangles)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ensureTriangleIndices.

Increases the size of the backing indices array to accommodate the specified number of additional triangles.

public void
ensureTriangles(int numVertices, int numTriangles)
Deprecated use ensureVertices(int) followed by ensureTriangleIndices(int) instead.

public void
ensureTriangles(int numTriangles)
Deprecated use ensureVertices(int) followed by ensureTriangleIndices(int) instead.

public void
ensureVertices(int numVertices)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.ensureVertices.

Increases the size of the backing vertices array to accommodate the specified number of additional vertices.

public VertexAttributes
public int
getFloatsPerVertex()

Returns: the size in number of floats of one vertex, multiply by four to get the size in bytes.

public void
getIndices(short[]
The short array to receive the copy of the indices, must be at least `destOffset` + getNumIndices() in size.
out
,
int
The offset (number of shorts) in the out array where to start copying
destOffset
)

Get a copy of the indices built so far.

protected short[]
getIndices()

Provides direct access to the indices array being built, use with care.

public MeshPart
public int
getNumIndices()

Returns: The number of indices built up until now, only valid in between the call to begin() and end().

public int
getNumVertices()

Returns: The number of vertices built up until now, only valid in between the call to begin() and end().

public int
public Matrix4
getVertexTransform(Matrix4 out)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.getVertexTransform.

Get the current vertex transformation matrix.

public void
getVertices(float[]
The float array to receive the copy of the vertices, must be at least `destOffset` + getNumVertices() * getFloatsPerVertex() in size.
out
,
int
The offset (number of floats) in the out array where to start copying
destOffset
)

Get a copy of the vertices built so far.

protected float[]
getVertices()

Provides direct access to the vertices array being built, use with care.

public void
index(final short value)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.index.

Add an index, MeshPartBuilder expects all meshes to be indexed.

public void
index(final short value1, final short value2)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.index.

Add multiple indices, MeshPartBuilder expects all meshes to be indexed.

public void
index(final short value1, final short value2, final short value3)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.index.

Add multiple indices, MeshPartBuilder expects all meshes to be indexed.

public void
index(final short value1, final short value2, final short value3, final short value4)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.index.

Add multiple indices, MeshPartBuilder expects all meshes to be indexed.

public void
index(short value1, short value2, short value3, short value4, short value5, short value6)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.index.

Add multiple indices, MeshPartBuilder expects all meshes to be indexed.

public void
index(short value1, short value2, short value3, short value4, short value5, short value6, short value7, short value8)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.index.

Add multiple indices, MeshPartBuilder expects all meshes to be indexed.

public boolean
public int
public void
line(short index1, short index2)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.line.

Add a line by indices.

public void
public void
public void
line(float x1, float y1, float z1, float x2, float y2, float z2)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.line.

Add a line.

public void
public MeshPart
part(final String id, int primitiveType)

Starts a new MeshPart.

public MeshPart
part(final String
The id (name) of the part
id
,
final int primitiveType, MeshPart
The part to receive the result
meshPart
)

Starts a new MeshPart.

public void
public void
patch(Vector3 corner00, Vector3 corner10, Vector3 corner11, Vector3 corner01, Vector3 normal, int divisionsU, int divisionsV)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.patch.

Deprecated

public void
patch(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ, int divisionsU, int divisionsV)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.patch.

Deprecated

public void
rect(short corner00, short corner10, short corner11, short corner01)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.rect.

Add a rectangle by indices.

public void
public void
rect(Vector3 corner00, Vector3 corner10, Vector3 corner11, Vector3 corner01, Vector3 normal)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.rect.

Add a rectangle.

public void
rect(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.rect.

Add a rectangle Requires GL_POINTS, GL_LINES or GL_TRIANGLES primitive type.

public void
setColor(float r, float g, float b, float a)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.setColor.

Set the color used to tint the vertex color, defaults to white.

public void
setColor(final Color color)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.setColor.

Set the color used to tint the vertex color, defaults to white.

public void
setUVRange(float u1, float v1, float u2, float v2)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.setUVRange.

Set range of texture coordinates used (default is 0,0,1,1).

public void
setUVRange(TextureRegion region)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.setUVRange.

Set range of texture coordinates from the specified TextureRegion.

public void
setVertexTransform(Matrix4 transform)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.setVertexTransform.

Set the current vertex transformation matrix and enables vertex transformation.

public void
setVertexTransformationEnabled(boolean enabled)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.setVertexTransformationEnabled.

Sets whether vertex transformation is enabled.

public void
sphere(float width, float height, float depth, int divisionsU, int divisionsV)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.sphere.

Deprecated

public void
sphere(final Matrix4 transform, float width, float height, float depth, int divisionsU, int divisionsV)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.sphere.

Deprecated

public void
sphere(float width, float height, float depth, int divisionsU, int divisionsV, float angleUFrom, float angleUTo, float angleVFrom, float angleVTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.sphere.

Deprecated

public void
sphere(final Matrix4 transform, float width, float height, float depth, int divisionsU, int divisionsV, float angleUFrom, float angleUTo, float angleVFrom, float angleVTo)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.sphere.

Deprecated

private static final void
transformNormal(final float[] values, final int offset, final int size, Matrix3 transform)

private static final void
transformPosition(final float[] values, final int offset, final int size, Matrix4 transform)

public void
triangle(short index1, short index2, short index3)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.triangle.

Add a triangle by indices.

public void
public void
public void
public short
vertex(Vector3 pos, Vector3 nor, Color col, Vector2 uv)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.vertex.

Add a vertex, returns the index.

public short
vertex(final float... values)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.vertex.

Add one or more vertices, returns the index of the last vertex added.

public short
vertex(final MeshPartBuilder.VertexInfo info)

Implements com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.vertex.

Add a vertex, returns the index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait