Class IntMesh

java.lang.Object
gaiasky.util.gdx.mesh.IntMesh
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class IntMesh extends Object implements com.badlogic.gdx.utils.Disposable

This implementation uses 32-bit integer indices instead of 16-bit shorts used in Mesh

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.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntMesh(boolean staticVertices, boolean staticIndices, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttributes attributes)
    Creates a new Mesh with the given attributes.
    IntMesh(boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttribute[] attributes)
    Creates a new Mesh with the given attributes.
    IntMesh(boolean isStatic, int maxGlobal, int maxInstanced, com.badlogic.gdx.graphics.VertexAttribute[] attributes, com.badlogic.gdx.graphics.VertexAttribute[] attributesInstanced)
    Creates a new Mesh with the given attributes.
    IntMesh(boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttributes attributes)
    Creates a new Mesh with the given attributes.
    IntMesh(IntMesh.VertexDataType type, boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttribute[] attributes)
    Creates a new Mesh with the given attributes.
    IntMesh(IntMesh.VertexDataType type, boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttributes attributes)
    Creates a new Mesh with the given attributes.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Binds the underlying VertexBufferObject and IntIndexBufferObject if indices where given.
    void
    bind(ExtShaderProgram shader, int[] locations)
    Binds the underlying VertexBufferObject and IntIndexBufferObject if indices where given.
    com.badlogic.gdx.math.collision.BoundingBox
    Calculates the BoundingBox of the vertices contained in this mesh.
    void
    calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox bbox)
    Calculates the BoundingBox of the vertices contained in this mesh.
    com.badlogic.gdx.math.collision.BoundingBox
    calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count)
    Calculate the BoundingBox of the specified part.
    com.badlogic.gdx.math.collision.BoundingBox
    calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
    Calculate the BoundingBox of the specified part.
    float
    calculateRadius(float centerX, float centerY, float centerZ)
    Calculates the squared radius of the bounding sphere around the specified center for the specified part.
    float
    calculateRadius(float centerX, float centerY, float centerZ, int offset, int count)
    Calculates the squared radius of the bounding sphere around the specified center for the specified part.
    float
    calculateRadius(float centerX, float centerY, float centerZ, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
    Calculates the radius of the bounding sphere around the specified center for the specified part.
    float
    calculateRadius(com.badlogic.gdx.math.Vector3 center)
    Calculates the squared radius of the bounding sphere around the specified center for the specified part.
    float
    calculateRadius(com.badlogic.gdx.math.Vector3 center, int offset, int count)
    Calculates the squared radius of the bounding sphere around the specified center for the specified part.
    float
    calculateRadius(com.badlogic.gdx.math.Vector3 center, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
    Calculates the squared radius of the bounding sphere around the specified center for the specified part.
    float
    calculateRadiusSquared(float centerX, float centerY, float centerZ, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
    Calculates the squared radius of the bounding sphere around the specified center for the specified part.
    static void
    clearAllMeshes(com.badlogic.gdx.Application app)
    Will clear the managed mesh cache.
    copy(boolean isStatic)
    Copies this mesh.
    copy(boolean isStatic, boolean removeDuplicates, int[] usage)
    Copies this mesh optionally removing duplicate vertices and/or reducing the amount of attributes.
    void
    Frees all resources associated with this Mesh
    com.badlogic.gdx.math.collision.BoundingBox
    extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count)
    Extends the specified BoundingBox with the specified part.
    com.badlogic.gdx.math.collision.BoundingBox
    extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
    Extends the specified BoundingBox with the specified part.
    void
    getIndices(int[] indices)
    Copies the indices from the Mesh to the int array.
    void
    getIndices(int[] indices, int destOffset)
    Copies the indices from the Mesh to the int array.
    void
    getIndices(int srcOffset, int[] indices, int destOffset)
    Copies the remaining indices from the Mesh to the int array.
    void
    getIndices(int srcOffset, int count, int[] indices, int destOffset)
    Copies the indices from the Mesh to the int array.
     
    com.badlogic.gdx.graphics.VertexAttributes
     
    com.badlogic.gdx.graphics.VertexAttribute
     
    static String
     
    int
     
    int
     
    int
     
    int
     
    com.badlogic.gdx.graphics.VertexAttribute
    getVertexAttribute(int usage)
    Returns the first VertexAttribute having the given VertexAttributes.Usage.
    com.badlogic.gdx.graphics.VertexAttributes
     
    int
     
    float[]
    getVertices(float[] vertices)
    Copies the vertices from the Mesh to the float array.
    float[]
    getVertices(int srcOffset, float[] vertices)
    Copies the the remaining vertices from the Mesh to the float array.
    float[]
    getVertices(int srcOffset, int count, float[] vertices)
    Copies the specified vertices from the Mesh to the float array.
    float[]
    getVertices(int srcOffset, int count, float[] vertices, int destOffset)
    Copies the specified vertices from the Mesh to the float array.
     
    static void
    invalidateAllMeshes(com.badlogic.gdx.Application app)
    Invalidates all meshes so the next time they are rendered new VBO handles are generated.
    void
    render(ExtShaderProgram shader, int primitiveType)
    Renders the mesh using the given primitive type.
    void
    render(ExtShaderProgram shader, int primitiveType, int offset, int count)
    Renders the mesh using the given primitive type.
    void
    render(ExtShaderProgram shader, int primitiveType, int offset, int count, boolean autoBind)
    Renders the mesh using the given primitive type.
    void
    render(ExtShaderProgram shader, int primitiveType, int offset, int count, int instanceCount)
    Renders the mesh with instanced rendering using the given primitive type.
    void
    render(ExtShaderProgram shader, int primitiveType, int offset, int count, int instanceCount, boolean autoBind)
    Renders the mesh using the given primitive type using instanced rendering.
    void
    scale(float scaleX, float scaleY, float scaleZ)
    Method to scale the positions in the mesh.
    void
    setAutoBind(boolean autoBind)
    Sets whether to bind the underlying VertexArray or VertexBufferObject automatically on a call to one of the render methods.
    setIndices(int[] indices)
    Sets the indices of this Mesh
    setIndices(int[] indices, int offset, int count)
    Sets the indices of this Mesh.
    setInstance(float[] instance)
    Sets the per-instance attributes of this Mesh.
    setInstanceAttribs(float[] instance, int offset, int count)
    Sets the per-instance attributes of this Mesh.
    setVertices(float[] vertices)
    Sets the vertices of this Mesh.
    setVertices(float[] vertices, int offset, int count)
    Sets the vertices of this Mesh.
    void
    transform(com.badlogic.gdx.math.Matrix4 matrix)
    Method to transform the positions in the mesh.
    static void
    transform(com.badlogic.gdx.math.Matrix4 matrix, float[] vertices, int vertexSize, int offset, int dimensions, int start, int count)
    Method to transform the positions in the float array.
    void
    transform(com.badlogic.gdx.math.Matrix4 matrix, int start, int count)
     
    void
    transformUV(com.badlogic.gdx.math.Matrix3 matrix)
    Method to transform the texture coordinates in the mesh.
    static void
    transformUV(com.badlogic.gdx.math.Matrix3 matrix, float[] vertices, int vertexSize, int offset, int start, int count)
    Method to transform the texture coordinates (UV) in the float array.
    protected void
    transformUV(com.badlogic.gdx.math.Matrix3 matrix, int start, int count)
     
    void
    Unbinds the underlying VertexBufferObject and IntIndexBufferObject is indices were given.
    void
    unbind(ExtShaderProgram shader, int[] locations)
    Unbinds the underlying VertexBufferObject and IntIndexBufferObject is indices were given.
    updateVertices(int targetOffset, float[] source)
    Update (a portion of) the vertices.
    updateVertices(int targetOffset, float[] source, int sourceOffset, int count)
    Update (a portion of) the vertices.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IntMesh

      public IntMesh(boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttribute[] attributes)
      Creates a new Mesh with the given attributes.
      Parameters:
      isStatic - whether this mesh is static or not. Allows for internal optimizations.
      maxVertices - the maximum number of vertices this mesh can hold
      maxIndices - the maximum number of indices this mesh can hold
      attributes - the VertexAttributes. Each vertex attribute defines one property of a vertex such as position, normal or texture coordinate. In instanced mode, these are the common attributes (divisor=1)
    • IntMesh

      public IntMesh(boolean isStatic, int maxGlobal, int maxInstanced, com.badlogic.gdx.graphics.VertexAttribute[] attributes, com.badlogic.gdx.graphics.VertexAttribute[] attributesInstanced)
      Creates a new Mesh with the given attributes.
      Parameters:
      isStatic - whether this mesh is static or not. Allows for internal optimizations.
      maxGlobal - the maximum number of global vertices this mesh can hold
      maxInstanced - the maximum number of instance vertices this mesh can hold
      attributes - the VertexAttributes. Each vertex attribute defines one property of a vertex such as position, normal or texture coordinate. In instanced mode, these are the common attributes (divisor=1)
      attributesInstanced - vertex attributes for instanced mode. These have a divisor of 1
    • IntMesh

      public IntMesh(boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttributes attributes)
      Creates a new Mesh with the given attributes.
      Parameters:
      isStatic - whether this mesh is static or not. Allows for internal optimizations.
      maxVertices - the maximum number of vertices this mesh can hold
      maxIndices - the maximum number of indices this mesh can hold
      attributes - the VertexAttributes. Each vertex attribute defines one property of a vertex such as position, normal or texture coordinate
    • IntMesh

      public IntMesh(boolean staticVertices, boolean staticIndices, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttributes attributes)
      Creates a new Mesh with the given attributes. Adds extra optimizations for dynamic (frequently modified) meshes.
      Parameters:
      staticVertices - whether vertices of this mesh are static or not. Allows for internal optimizations.
      staticIndices - whether indices of this mesh are static or not. Allows for internal optimizations.
      maxVertices - the maximum number of vertices this mesh can hold
      maxIndices - the maximum number of indices this mesh can hold
      attributes - the VertexAttributes. Each vertex attribute defines one property of a vertex such as position, normal or texture coordinate
    • IntMesh

      public IntMesh(IntMesh.VertexDataType type, boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttribute[] attributes)
      Creates a new Mesh with the given attributes. This is an expert method with no error checking. Use at your own risk.
      Parameters:
      type - the IntMesh.VertexDataType to be used, VBO or VA.
      isStatic - whether this mesh is static or not. Allows for internal optimizations.
      maxVertices - the maximum number of vertices this mesh can hold
      maxIndices - the maximum number of indices this mesh can hold
      attributes - the VertexAttributes. Each vertex attribute defines one property of a vertex such as position, normal or texture coordinate
    • IntMesh

      public IntMesh(IntMesh.VertexDataType type, boolean isStatic, int maxVertices, int maxIndices, com.badlogic.gdx.graphics.VertexAttributes attributes)
      Creates a new Mesh with the given attributes. This is an expert method with no error checking. Use at your own risk.
      Parameters:
      type - the IntMesh.VertexDataType to be used, VBO or VA.
      isStatic - whether this mesh is static or not. Allows for internal optimizations.
      maxVertices - the maximum number of vertices this mesh can hold
      maxIndices - the maximum number of indices this mesh can hold
      attributes - the VertexAttributes.
  • Method Details

    • setVertices

      public IntMesh setVertices(float[] vertices)
      Sets the vertices of this Mesh. The attributes are assumed to be given in float format.
      Parameters:
      vertices - the vertices.
      Returns:
      the mesh for invocation chaining.
    • setVertices

      public IntMesh setVertices(float[] vertices, int offset, int count)
      Sets the vertices of this Mesh. The attributes are assumed to be given in float format.
      Parameters:
      vertices - the vertices.
      offset - the offset into the vertices array
      count - the number of floats to use
      Returns:
      the mesh for invocation chaining.
    • updateVertices

      public IntMesh updateVertices(int targetOffset, float[] source)
      Update (a portion of) the vertices. Does not resize the backing buffer.
      Parameters:
      targetOffset - the offset in number of floats of the mesh part.
      source - the vertex data to update the mesh part with
    • updateVertices

      public IntMesh updateVertices(int targetOffset, float[] source, int sourceOffset, int count)
      Update (a portion of) the vertices. Does not resize the backing buffer.
      Parameters:
      targetOffset - the offset in number of floats of the mesh part.
      source - the vertex data to update the mesh part with
      sourceOffset - the offset in number of floats within the source array
      count - the number of floats to update
    • getVertices

      public float[] getVertices(float[] vertices)
      Copies the vertices from the Mesh to the float array. The float array must be large enough to hold all the Mesh's vertices.
      Parameters:
      vertices - the array to copy the vertices to
    • getVertices

      public float[] getVertices(int srcOffset, float[] vertices)
      Copies the the remaining vertices from the Mesh to the float array. The float array must be large enough to hold the remaining vertices.
      Parameters:
      srcOffset - the offset (in number of floats) of the vertices in the mesh to copy
      vertices - the array to copy the vertices to
    • getVertices

      public float[] getVertices(int srcOffset, int count, float[] vertices)
      Copies the specified vertices from the Mesh to the float array. The float array must be large enough to hold count vertices.
      Parameters:
      srcOffset - the offset (in number of floats) of the vertices in the mesh to copy
      count - the amount of floats to copy
      vertices - the array to copy the vertices to
    • getVertices

      public float[] getVertices(int srcOffset, int count, float[] vertices, int destOffset)
      Copies the specified vertices from the Mesh to the float array. The float array must be large enough to hold destOffset+count vertices.
      Parameters:
      srcOffset - the offset (in number of floats) of the vertices in the mesh to copy
      count - the amount of floats to copy
      vertices - the array to copy the vertices to
      destOffset - the offset (in floats) in the vertices array to start copying
    • setInstance

      public IntMesh setInstance(float[] instance)
      Sets the per-instance attributes of this Mesh. The attributes are assumed to be given in float format.
      Parameters:
      instance - the vertices.
      Returns:
      the mesh for invocation chaining.
    • setInstanceAttribs

      public IntMesh setInstanceAttribs(float[] instance, int offset, int count)
      Sets the per-instance attributes of this Mesh. The attributes are assumed to be given in float format.
      Parameters:
      instance - the vertices.
      Returns:
      the mesh for invocation chaining.
    • setIndices

      public IntMesh setIndices(int[] indices)
      Sets the indices of this Mesh
      Parameters:
      indices - the indices
      Returns:
      the mesh for invocation chaining.
    • setIndices

      public IntMesh setIndices(int[] indices, int offset, int count)
      Sets the indices of this Mesh.
      Parameters:
      indices - the indices
      offset - the offset into the indices array
      count - the number of indices to copy
      Returns:
      the mesh for invocation chaining.
    • getIndices

      public void getIndices(int[] indices)
      Copies the indices from the Mesh to the int array. The int array must be large enough to hold all the Mesh's indices.
      Parameters:
      indices - the array to copy the indices to
    • getIndices

      public void getIndices(int[] indices, int destOffset)
      Copies the indices from the Mesh to the int array. The int array must be large enough to hold destOffset + all the Mesh's indices.
      Parameters:
      indices - the array to copy the indices to
      destOffset - the offset in the indices array to start copying
    • getIndices

      public void getIndices(int srcOffset, int[] indices, int destOffset)
      Copies the remaining indices from the Mesh to the int array. The int array must be large enough to hold destOffset + all the remaining indices.
      Parameters:
      srcOffset - the zero-based offset of the first index to fetch
      indices - the array to copy the indices to
      destOffset - the offset in the indices array to start copying
    • getIndices

      public void getIndices(int srcOffset, int count, int[] indices, int destOffset)
      Copies the indices from the Mesh to the int array. The int array must be large enough to hold destOffset + count indices.
      Parameters:
      srcOffset - the zero-based offset of the first index to fetch
      count - the total amount of indices to copy
      indices - the array to copy the indices to
      destOffset - the offset in the indices array to start copying
    • getNumIndices

      public int getNumIndices()
      Returns:
      the number of defined indices
    • getNumVertices

      public int getNumVertices()
      Returns:
      the number of defined vertices
    • getMaxVertices

      public int getMaxVertices()
      Returns:
      the maximum number of vertices this mesh can hold
    • getMaxIndices

      public int getMaxIndices()
      Returns:
      the maximum number of indices this mesh can hold
    • getVertexSize

      public int getVertexSize()
      Returns:
      the size of a single vertex in bytes
    • setAutoBind

      public void setAutoBind(boolean autoBind)
      Sets whether to bind the underlying VertexArray or VertexBufferObject automatically on a call to one of the render methods. Usually you want to use autobind. Manual binding is an expert functionality. There is a driver bug on the MSM720xa chips that will fuck up memory if you manipulate the vertices and indices of a Mesh multiple times while it is bound. Keep this in mind.
      Parameters:
      autoBind - whether to autobind meshes.
    • bind

      public void bind(ExtShaderProgram shader)
      Binds the underlying VertexBufferObject and IntIndexBufferObject if indices where given. Use this with OpenGL ES 2.0 and when auto-bind is disabled.
      Parameters:
      shader - the shader (does not bind the shader)
    • bind

      public void bind(ExtShaderProgram shader, int[] locations)
      Binds the underlying VertexBufferObject and IntIndexBufferObject if indices where given. Use this with OpenGL ES 2.0 and when auto-bind is disabled.
      Parameters:
      shader - the shader (does not bind the shader)
      locations - array containing the attribute locations.
    • unbind

      public void unbind(ExtShaderProgram shader)
      Unbinds the underlying VertexBufferObject and IntIndexBufferObject is indices were given. Use this with OpenGL ES 1.x and when auto-bind is disabled.
      Parameters:
      shader - the shader (does not unbind the shader)
    • unbind

      public void unbind(ExtShaderProgram shader, int[] locations)
      Unbinds the underlying VertexBufferObject and IntIndexBufferObject is indices were given. Use this with OpenGL ES 1.x and when auto-bind is disabled.
      Parameters:
      shader - the shader (does not unbind the shader)
      locations - array containing the attribute locations.
    • render

      public void render(ExtShaderProgram shader, int primitiveType)

      Renders the mesh using the given primitive type. If indices are set for this mesh then getNumIndices() / #vertices per primitive primitives are rendered. If no indices are set then getNumVertices() / #vertices per primitive are rendered.

      This method will automatically bind each vertex attribute as specified at construction time via VertexAttributes to the respective shader attributes. The binding is based on the alias defined for each VertexAttribute.

      This method must only be called after the ExtShaderProgram.begin() method has been called!

      This method is intended for use with OpenGL ES 2.0 and will throw an IllegalStateException when OpenGL ES 1.x is used.

      Parameters:
      primitiveType - the primitive type
    • render

      public void render(ExtShaderProgram shader, int primitiveType, int offset, int count)

      Renders the mesh using the given primitive type. offset specifies the offset into either the vertex buffer or the index buffer depending on whether indices are defined. count specifies the number of vertices or indices to use thus count / #vertices per primitive primitives are rendered.

      This method will automatically bind each vertex attribute as specified at construction time via VertexAttributes to the respective shader attributes. The binding is based on the alias defined for each VertexAttribute.

      This method must only be called after the ExtShaderProgram.begin() method has been called!

      This method is intended for use with OpenGL ES 2.0 and will throw an IllegalStateException when OpenGL ES 1.x is used.

      Parameters:
      shader - the shader to be used
      primitiveType - the primitive type
      offset - the offset into the vertex or index buffer
      count - number of vertices or indices to use
    • render

      public void render(ExtShaderProgram shader, int primitiveType, int offset, int count, int instanceCount)

      Renders the mesh with instanced rendering using the given primitive type. offset specifies the offset into either the vertex buffer or the index buffer depending on whether indices are defined. count specifies the number of vertices or indices to use thus count / #vertices per primitive primitives are rendered.

      Parameters:
      shader - the shader to be used
      primitiveType - the primitive type
      offset - the offset into the vertex or index buffer
      count - number of vertices or indices to use
      instanceCount - number of instances
    • render

      public void render(ExtShaderProgram shader, int primitiveType, int offset, int count, boolean autoBind)

      Renders the mesh using the given primitive type. offset specifies the offset into either the vertex buffer or the index buffer depending on whether indices are defined. count specifies the number of vertices or indices to use thus count / #vertices per primitive primitives are rendered.

      This method will automatically bind each vertex attribute as specified at construction time via VertexAttributes to the respective shader attributes. The binding is based on the alias defined for each VertexAttribute.

      This method must only be called after the ExtShaderProgram.begin() method has been called!

      This method is intended for use with OpenGL ES 2.0 and will throw an IllegalStateException when OpenGL ES 1.x is used.

      Parameters:
      shader - the shader to be used
      primitiveType - the primitive type
      offset - the offset into the vertex or index buffer
      count - number of vertices or indices to use
      autoBind - overrides the autoBind member of this Mesh
    • render

      public void render(ExtShaderProgram shader, int primitiveType, int offset, int count, int instanceCount, boolean autoBind)

      Renders the mesh using the given primitive type using instanced rendering. offset specifies the offset into either the vertex buffer or the index buffer depending on whether indices are defined. count specifies the number of vertices or indices to use thus count / #vertices per primitive primitives are rendered.

      Parameters:
      shader - the shader to be used
      primitiveType - the primitive type
      offset - the offset into the vertex or index buffer
      count - number of vertices or indices to use
      instanceCount - number of instances
      autoBind - overrides the autoBind member of this Mesh
    • dispose

      public void dispose()
      Frees all resources associated with this Mesh
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • getVertexAttribute

      public com.badlogic.gdx.graphics.VertexAttribute getVertexAttribute(int usage)
      Returns the first VertexAttribute having the given VertexAttributes.Usage.
      Parameters:
      usage - the Usage.
      Returns:
      the VertexAttribute or null if no attribute with that usage was found.
    • getInstancedAttribute

      public com.badlogic.gdx.graphics.VertexAttribute getInstancedAttribute(int usage)
    • getVertexAttributes

      public com.badlogic.gdx.graphics.VertexAttributes getVertexAttributes()
      Returns:
      the vertex attributes of this Mesh
    • getInstanceAttributes

      public com.badlogic.gdx.graphics.VertexAttributes getInstanceAttributes()
      Returns:
      the vertex attributes of this Mesh
    • getVerticesBuffer

      public FloatBuffer getVerticesBuffer()
      Returns:
      the backing FloatBuffer holding the vertices. Does not have to be a direct buffer on Android!
    • calculateBoundingBox

      public com.badlogic.gdx.math.collision.BoundingBox calculateBoundingBox()
      Calculates the BoundingBox of the vertices contained in this mesh. In case no vertices are defined yet a GdxRuntimeException is thrown. This method creates a new BoundingBox instance.
      Returns:
      the bounding box.
    • calculateBoundingBox

      public void calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox bbox)
      Calculates the BoundingBox of the vertices contained in this mesh. In case no vertices are defined yet a GdxRuntimeException is thrown.
      Parameters:
      bbox - the bounding box to store the result in.
    • calculateBoundingBox

      public com.badlogic.gdx.math.collision.BoundingBox calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count)
      Calculate the BoundingBox of the specified part.
      Parameters:
      out - the bounding box to store the result in.
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the value specified by out.
    • calculateBoundingBox

      public com.badlogic.gdx.math.collision.BoundingBox calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
      Calculate the BoundingBox of the specified part.
      Parameters:
      out - the bounding box to store the result in.
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the value specified by out.
    • extendBoundingBox

      public com.badlogic.gdx.math.collision.BoundingBox extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count)
      Extends the specified BoundingBox with the specified part.
      Parameters:
      out - the bounding box to store the result in.
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the value specified by out.
    • extendBoundingBox

      public com.badlogic.gdx.math.collision.BoundingBox extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
      Extends the specified BoundingBox with the specified part.
      Parameters:
      out - the bounding box to store the result in.
      offset - the start of the part.
      count - the size of the part.
      Returns:
      the value specified by out.
    • calculateRadiusSquared

      public float calculateRadiusSquared(float centerX, float centerY, float centerZ, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
      Calculates the squared radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      centerX - The X coordinate of the center of the bounding sphere
      centerY - The Y coordinate of the center of the bounding sphere
      centerZ - The Z coordinate of the center of the bounding sphere
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the squared radius of the bounding sphere.
    • calculateRadius

      public float calculateRadius(float centerX, float centerY, float centerZ, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
      Calculates the radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      centerX - The X coordinate of the center of the bounding sphere
      centerY - The Y coordinate of the center of the bounding sphere
      centerZ - The Z coordinate of the center of the bounding sphere
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the radius of the bounding sphere.
    • calculateRadius

      public float calculateRadius(com.badlogic.gdx.math.Vector3 center, int offset, int count, com.badlogic.gdx.math.Matrix4 transform)
      Calculates the squared radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      center - The center of the bounding sphere
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the squared radius of the bounding sphere.
    • calculateRadius

      public float calculateRadius(float centerX, float centerY, float centerZ, int offset, int count)
      Calculates the squared radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      centerX - The X coordinate of the center of the bounding sphere
      centerY - The Y coordinate of the center of the bounding sphere
      centerZ - The Z coordinate of the center of the bounding sphere
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the squared radius of the bounding sphere.
    • calculateRadius

      public float calculateRadius(com.badlogic.gdx.math.Vector3 center, int offset, int count)
      Calculates the squared radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      center - The center of the bounding sphere
      offset - the start index of the part.
      count - the amount of indices the part contains.
      Returns:
      the squared radius of the bounding sphere.
    • calculateRadius

      public float calculateRadius(float centerX, float centerY, float centerZ)
      Calculates the squared radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      centerX - The X coordinate of the center of the bounding sphere
      centerY - The Y coordinate of the center of the bounding sphere
      centerZ - The Z coordinate of the center of the bounding sphere
      Returns:
      the squared radius of the bounding sphere.
    • calculateRadius

      public float calculateRadius(com.badlogic.gdx.math.Vector3 center)
      Calculates the squared radius of the bounding sphere around the specified center for the specified part.
      Parameters:
      center - The center of the bounding sphere
      Returns:
      the squared radius of the bounding sphere.
    • getIndicesBuffer

      public IntBuffer getIndicesBuffer()
      Returns:
      the backing intbuffer holding the indices. Does not have to be a direct buffer on Android!
    • invalidateAllMeshes

      public static void invalidateAllMeshes(com.badlogic.gdx.Application app)
      Invalidates all meshes so the next time they are rendered new VBO handles are generated.
      Parameters:
      app -
    • clearAllMeshes

      public static void clearAllMeshes(com.badlogic.gdx.Application app)
      Will clear the managed mesh cache. I wouldn't use this if i was you :)
    • getManagedStatus

      public static String getManagedStatus()
    • scale

      public void scale(float scaleX, float scaleY, float scaleZ)
      Method to scale the positions in the mesh. Normals will be kept as is. This is a potentially slow operation, use with care. It will also create a temporary float[] which will be garbage collected.
      Parameters:
      scaleX - scale on x
      scaleY - scale on y
      scaleZ - scale on z
    • transform

      public void transform(com.badlogic.gdx.math.Matrix4 matrix)
      Method to transform the positions in the mesh. Normals will be kept as is. This is a potentially slow operation, use with care. It will also create a temporary float[] which will be garbage collected.
      Parameters:
      matrix - the transformation matrix
    • transform

      public void transform(com.badlogic.gdx.math.Matrix4 matrix, int start, int count)
    • transform

      public static void transform(com.badlogic.gdx.math.Matrix4 matrix, float[] vertices, int vertexSize, int offset, int dimensions, int start, int count)
      Method to transform the positions in the float array. Normals will be kept as is. This is a potentially slow operation, use with care.
      Parameters:
      matrix - the transformation matrix
      vertices - the float array
      vertexSize - the number of floats in each vertex
      offset - the offset within a vertex to the position
      dimensions - the size of the position
      start - the vertex to start with
      count - the amount of vertices to transform
    • transformUV

      public void transformUV(com.badlogic.gdx.math.Matrix3 matrix)
      Method to transform the texture coordinates in the mesh. This is a potentially slow operation, use with care. It will also create a temporary float[] which will be garbage collected.
      Parameters:
      matrix - the transformation matrix
    • transformUV

      protected void transformUV(com.badlogic.gdx.math.Matrix3 matrix, int start, int count)
    • transformUV

      public static void transformUV(com.badlogic.gdx.math.Matrix3 matrix, float[] vertices, int vertexSize, int offset, int start, int count)
      Method to transform the texture coordinates (UV) in the float array. This is a potentially slow operation, use with care.
      Parameters:
      matrix - the transformation matrix
      vertices - the float array
      vertexSize - the number of floats in each vertex
      offset - the offset within a vertex to the texture location
      start - the vertex to start with
      count - the amount of vertices to transform
    • copy

      public IntMesh copy(boolean isStatic, boolean removeDuplicates, int[] usage)
      Copies this mesh optionally removing duplicate vertices and/or reducing the amount of attributes.
      Parameters:
      isStatic - whether the new mesh is static or not. Allows for internal optimizations.
      removeDuplicates - whether to remove duplicate vertices if possible. Only the vertices specified by usage are checked.
      usage - which attributes (if available) to copy
      Returns:
      the copy of this mesh
    • copy

      public IntMesh copy(boolean isStatic)
      Copies this mesh.
      Parameters:
      isStatic - whether the new mesh is static or not. Allows for internal optimizations.
      Returns:
      the copy of this mesh