A Mesh holds vertices composed of attributes specified by a VertexAttributes instance. The vertices are held either in
VRAM in form of vertex buffer objects or in RAM in form of vertex arrays. The former variant is more performant and is
preferred over vertex arrays if hardware supports it.
Meshes are automatically managed. If the OpenGL context is lost all vertex buffer objects get invalidated and must be reloaded when the context is recreated. This only happens on Android when a user switches to another application or receives an incoming call. A managed Mesh will be reloaded automagically so you don't have to do this manually.
A Mesh consists of vertices and optionally indices which specify which vertices define a triangle. Each vertex is composed of attributes such as position, normal, color or texture coordinate. Note that not all of this attributes must be given, except for position which is non-optional. Each attribute has an alias which is used when rendering a Mesh in OpenGL ES 2.0. The alias is used to bind a specific vertex attribute to a shader attribute. The shader source and the alias of the attribute must match exactly for this to work.
| Modifier and Type | Class and Description |
|---|---|
| public static enum |
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | |
| protected final IndexData | |
| protected InstanceData | |
| protected boolean | |
| protected final boolean | |
| pack-priv static final Map | meshes
list of all meshes |
| private final Vector3 | |
| protected final VertexData |
| Access | Constructor and Description |
|---|---|
| protected | |
| public | Mesh(boolean
whether this mesh is static or not. Allows for internal optimizations. isStatic, int the maximum number of vertices this mesh can hold maxVertices, int the maximum number of indices this mesh can hold maxIndices, VertexAttribute... the attributes)VertexAttributes. Each vertex attribute defines one property of a vertex such as position,
normal or texture coordinateCreates a new Mesh with the given attributes. |
| public | Mesh(boolean
whether this mesh is static or not. Allows for internal optimizations. isStatic, int the maximum number of vertices this mesh can hold maxVertices, int the maximum number of indices this mesh can hold maxIndices, VertexAttributes the attributes)VertexAttributes. Each vertex attribute defines one property of a vertex such as position,
normal or texture coordinateCreates a new Mesh with the given attributes. |
| public | Mesh(boolean
whether vertices of this mesh are static or not. Allows for internal optimizations. staticVertices, boolean whether indices of this mesh are static or not. Allows for internal optimizations. staticIndices, int the maximum number of vertices this mesh can hold maxVertices, int the maximum number of indices this mesh can hold maxIndices, VertexAttributes the attributes)VertexAttributes. Each vertex attribute defines one property of a vertex such as position,
normal or texture coordinateCreates a new Mesh with the given attributes. |
| public | Mesh(Mesh.
the type,VertexDataType to be used, VBO or VA.whether this mesh is static or not. Allows for internal optimizations. isStatic, int the maximum number of vertices this mesh can hold maxVertices, int the maximum number of indices this mesh can hold maxIndices, VertexAttribute... the attributes)VertexAttributes. Each vertex attribute defines one property of a vertex such as position,
normal or texture coordinateCreates a new Mesh with the given attributes. |
| public | Mesh(Mesh.
the type,VertexDataType to be used, VBO or VA.whether this mesh is static or not. Allows for internal optimizations. isStatic, int the maximum number of vertices this mesh can hold maxVertices, int the maximum number of indices this mesh can hold maxIndices, VertexAttributes the attributes)VertexAttributes.Creates a new Mesh with the given attributes. |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| public void | bind(final ShaderProgram
the shader (does not bind the shader) shader)Binds the underlying |
| public void | bind(final ShaderProgram
the shader (does not bind the shader) shader, final int[] array containing the vertex attribute locations. locations, final int[] array containing the instance attribute locations. instanceLocations)Binds the underlying |
| public BoundingBox | Returns: the bounding box.Calculates the |
| public void | calculateBoundingBox(BoundingBox
the bounding box to store the result in. bbox)Calculates the |
| public BoundingBox | Returns: the value specified by out.the bounding box to store the result in. out, int the start index of the part. offset, int the amount of indices the part contains. count)Calculate the |
| public BoundingBox | Returns: the value specified by out.the bounding box to store the result in. out, int the start index of the part. offset, int the amount of indices the part contains. count, final Matrix4 transform)Calculate the |
| public float | Returns: the radius of the bounding sphere.The X coordinate of the center of the bounding sphere centerX, final float The Y coordinate of the center of the bounding sphere centerY, final float The Z coordinate of the center of the bounding sphere centerZ, int the start index of the part. offset, int the amount of indices the part contains. count, final Matrix4 transform)Calculates the radius of the bounding sphere around the specified center for the specified part. |
| public float | Returns: the squared radius of the bounding sphere.The center of the bounding sphere center, int the start index of the part. offset, int the amount of indices the part contains. count, final Matrix4 transform)Calculates the squared radius of the bounding sphere around the specified center for the specified part. |
| public float | Returns: the squared radius of the bounding sphere.The X coordinate of the center of the bounding sphere centerX, final float The Y coordinate of the center of the bounding sphere centerY, final float The Z coordinate of the center of the bounding sphere centerZ, int the start index of the part. offset, int the amount of indices the part contains. count)Calculates the squared radius of the bounding sphere around the specified center for the specified part. |
| public float | Returns: the squared radius of the bounding sphere.The center of the bounding sphere center, int the start index of the part. offset, int the amount of indices the part contains. count)Calculates the squared radius of the bounding sphere around the specified center for the specified part. |
| public float | Returns: the squared radius of the bounding sphere.The X coordinate of the center of the bounding sphere centerX, final float The Y coordinate of the center of the bounding sphere centerY, final float The Z coordinate of the center of the bounding sphere centerZ)Calculates the squared radius of the bounding sphere around the specified center for the specified part. |
| public float | Returns: the squared radius of the bounding sphere.The center of the bounding sphere center)Calculates the squared radius of the bounding sphere around the specified center for the specified part. |
| public float | Returns: the squared radius of the bounding sphere.The X coordinate of the center of the bounding sphere centerX, final float The Y coordinate of the center of the bounding sphere centerY, final float The Z coordinate of the center of the bounding sphere centerZ, int the start index of the part. offset, int the amount of indices the part contains. count, final Matrix4 transform)Calculates the squared radius of the bounding sphere around the specified center for the specified part. |
| public static void | |
| public Mesh | Returns: the copy of this meshwhether the new mesh is static or not. Allows for internal optimizations. isStatic, boolean whether to remove duplicate vertices if possible. Only the vertices specified by usage are checked. removeDuplicates, final int[] which attributes (if available) to copy usage)Copies this mesh optionally removing duplicate vertices and/or reducing the amount of attributes. |
| public Mesh | Returns: the copy of this meshwhether the new mesh is static or not. Allows for internal optimizations. isStatic)Copies this mesh. |
| public Mesh | |
| public void | dispose()
Implements com. Frees all resources associated with this Mesh |
| public Mesh | |
| public BoundingBox | Returns: the value specified by out.the bounding box to store the result in. out, int the start index of the part. offset, int the amount of indices the part contains. count)Extends the specified |
| public BoundingBox | Returns: the value specified by out.the bounding box to store the result in. out, int the start of the part. offset, int the size of the part. count, final Matrix4 transform)Extends the specified |
| public IndexData | |
| public void | getIndices(short[]
the array to copy the indices to indices)Copies the indices from the Mesh to the short array. |
| public void | getIndices(short[]
the array to copy the indices to indices, int the offset in the indices array to start copying destOffset)Copies the indices from the Mesh to the short array. |
| public void | getIndices(int
the zero-based offset of the first index to fetch srcOffset, short[] the array to copy the indices to indices, int the offset in the indices array to start copying destOffset)Copies the remaining indices from the Mesh to the short array. |
| public void | getIndices(int
the zero-based offset of the first index to fetch srcOffset, int the total amount of indices to copy count, short[] the array to copy the indices to indices, int the offset in the indices array to start copying destOffset)Copies the indices from the Mesh to the short array. |
| public ShortBuffer | getIndicesBuffer()
Deprecated
use
getIndicesBuffer(boolean) instead
Returns: the backing shortbuffer holding the indices. |
| public ShortBuffer | |
| public VertexAttributes | |
| public static String | |
| public int | |
| public int | |
| public int | |
| public int | |
| public VertexAttribute | Returns: the VertexAttribute or null if no attribute with that usage was found.the Usage. usage)Returns the first |
| public VertexAttributes | |
| public int | |
| public float[] | getVertices(float[]
the array to copy the vertices to vertices)Copies the vertices from the Mesh to the float array. |
| public float[] | getVertices(int
the offset (in number of floats) of the vertices in the mesh to copy srcOffset, float[] the array to copy the vertices to vertices)Copies the the remaining vertices from the Mesh to the float array. |
| public float[] | getVertices(int
the offset (in number of floats) of the vertices in the mesh to copy srcOffset, int the amount of floats to copy count, float[] the array to copy the vertices to vertices)Copies the specified vertices from the Mesh to the float array. |
| public float[] | getVertices(int
the offset (in number of floats) of the vertices in the mesh to copy srcOffset, int the amount of floats to copy count, float[] the array to copy the vertices to vertices, int the offset (in floats) in the vertices array to start copying destOffset)Copies the specified vertices from the Mesh to the float array. |
| public FloatBuffer | getVerticesBuffer()
Deprecated
use
getVerticesBuffer(boolean) instead
Returns: the backing FloatBuffer holding the vertices. |
| public FloatBuffer | |
| public static void | invalidateAllMeshes(Application app)
Invalidates all meshes so the next time they are rendered new VBO handles are generated. |
| public boolean | |
| private VertexData | |
| public void | render(ShaderProgram shader, int
the primitive type primitiveType)Renders the mesh using the given primitive type. |
| public void | render(ShaderProgram
the shader to be used shader, int the primitive type primitiveType, int the offset into the vertex or index buffer offset, int number of vertices or indices to use count)Renders the mesh using the given primitive type. |
| public void | render(ShaderProgram
the shader to be used shader, int the primitive type primitiveType, int the offset into the vertex or index buffer offset, int number of vertices or indices to use count, boolean overrides the autoBind member of this Mesh autoBind)Renders the mesh using the given primitive type. |
| public void | scale(float
scale on x scaleX, float scale on y scaleY, float scale on z scaleZ)Method to scale the positions in the mesh. |
| public void | setAutoBind(boolean
whether to autobind meshes. autoBind)Sets whether to bind the underlying |
| public Mesh | Returns: the mesh for invocation chaining.the indices indices)Sets the indices of this Mesh |
| public Mesh | Returns: the mesh for invocation chaining.the indices indices, int the offset into the indices array offset, int the number of indices to copy count)Sets the indices of this Mesh. |
| public Mesh | Returns: the mesh for invocation chaining.the instance data. instanceData, int the offset into the vertices array offset, int the number of floats to use count)Sets the instance data of this Mesh. |
| public Mesh | Returns: the mesh for invocation chaining.the instance data. instanceData)Sets the instance data of this Mesh. |
| public Mesh | Returns: the mesh for invocation chaining.the instance data. instanceData, int the number of floats to use count)Sets the instance data of this Mesh. |
| public Mesh | Returns: the mesh for invocation chaining.the instance data. instanceData)Sets the instance data of this Mesh. |
| public Mesh | Returns: the mesh for invocation chaining.the vertices. vertices)Sets the vertices of this Mesh. |
| public Mesh | Returns: the mesh for invocation chaining.the vertices. vertices, int the offset into the vertices array offset, int the number of floats to use count)Sets the vertices of this Mesh. |
| public void | |
| public void | |
| public static void | transform(final Matrix4
the transformation matrix matrix, final float[] the float array vertices, int the number of floats in each vertex vertexSize, int the offset within a vertex to the position offset, int the size of the position dimensions, int the vertex to start with start, int the amount of vertices to transform count)Method to transform the positions in the float array. |
| public void | transformUV(final Matrix3
the transformation matrix matrix)Method to transform the texture coordinates in the mesh. |
| protected void | |
| public static void | transformUV(final Matrix3
the transformation matrix matrix, final float[] the float array vertices, int the number of floats in each vertex vertexSize, int the offset within a vertex to the texture location offset, int the vertex to start with start, int the amount of vertices to transform count)Method to transform the texture coordinates (UV) in the float array. |
| public void | unbind(final ShaderProgram
the shader (does not unbind the shader) shader)Unbinds the underlying |
| public void | unbind(final ShaderProgram
the shader (does not unbind the shader) shader, final int[] array containing the vertex attribute locations. locations, final int[] array containing the instance attribute locations. instanceLocations)Unbinds the underlying |
| public Mesh | updateInstanceData(int
the offset in number of floats of the mesh part. targetOffset, float[] the instance data to update the mesh part with source)Update (a portion of) the instance data. |
| public Mesh | updateInstanceData(int
the offset in number of floats of the mesh part. targetOffset, float[] the instance data to update the mesh part with source, int the offset in number of floats within the source array sourceOffset, int the number of floats to update count)Update (a portion of) the instance data. |
| public Mesh | updateInstanceData(int
the offset in number of floats of the mesh part. targetOffset, FloatBuffer the instance data to update the mesh part with source)Update (a portion of) the instance data. |
| public Mesh | updateInstanceData(int
the offset in number of floats of the mesh part. targetOffset, FloatBuffer the instance data to update the mesh part with source, int the offset in number of floats within the source array sourceOffset, int the number of floats to update count)Update (a portion of) the instance data. |
| public Mesh | updateVertices(int
the offset in number of floats of the mesh part. targetOffset, float[] the vertex data to update the mesh part with source)Update (a portion of) the vertices. |
| public Mesh | updateVertices(int
the offset in number of floats of the mesh part. targetOffset, float[] the vertex data to update the mesh part with source, int the offset in number of floats within the source array sourceOffset, int the number of floats to update count)Update (a portion of) the vertices. |