Class SpriteMesh
- Direct Known Subclasses:
TexturedMesh
A mesh is a collection of vertices and indices to pass to an OpenGL/ES 3.0 shader. It also includes a drawing command to interpret those indices. For example if the drawing command is GL_TRIANGLES, the indices are in groups of three, defining triangles. If GL_LINES, they are segment pairs.
This representation is entirely separate from OpenGL. One of the problems with most game engines (LibGDX included) is that they make geometric data tightly coupled with the OpenGL pipeline. The result is heavyweight and difficult to combine with computational geometry algorithms (LibGDX's greatest failing is its horrible computational geometry tools).
This mesh is designed to support a vertex type with four attributes: position, color, texture coordinate, and gradiant coordinate (though gradient coordinate is only supported if GL30 is used). Color is represented as a single float, encoding the RGB bits.The others are each two floats representing an x and a y. This class provides methods to make it easier to access these values.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty sprite mesh.SpriteMesh(float[] vertices) Sets the sprite mesh to have the given verticesSpriteMesh(float[] vertices, int voffset, int vlength) Sets the sprite mesh to have the given verticesSpriteMesh(float[] vertices, short[] indices) Sets the sprite mesh to have the given vertices and indices.SpriteMesh(float x, float y, float width, float height) Creates a rectangular sprite mesh.SpriteMesh(com.badlogic.gdx.math.Rectangle rect) Creates a rectangular sprite mesh.SpriteMesh(SpriteMesh mesh) Creates a copy of the given sprite mesh.SpriteMesh(Path2 path) Creates a sprite mesh from the given path.SpriteMesh(Path2 path, float width, float height) Creates a sprite mesh from the given path and boundsSpriteMesh(Path2 path, float x, float y, float width, float height) Creates a sprite mesh from the given path and boundsSpriteMesh(Path2 path, com.badlogic.gdx.math.Rectangle rect) Creates a sprite mesh from the given path and boundsSpriteMesh(Poly2 poly) Creates a sprite mesh from the given polygon.SpriteMesh(Poly2 poly, float width, float height) Creates a sprite mesh from the given polygon and boundsSpriteMesh(Poly2 poly, float x, float y, float width, float height) Creates a sprite mesh from the given polygon and boundsSpriteMesh(Poly2 poly, com.badlogic.gdx.math.Rectangle rect) Creates a sprite mesh from the given polygon and bounds -
Method Summary
Modifier and TypeMethodDescriptionadd(float offset) Uniformly translates all of the vertices of this mesh.add(float x, float y) Non-uniformly translates all of the vertices of this mesh.add(com.badlogic.gdx.math.Vector2 offset) Non-uniformly translates all of the vertices of this mesh.voidclear()Clears the contents of this sprite mesh (both vertices and indices)com.badlogic.gdx.math.RectangleReturns the minimal rectangle bounding this mesh.com.badlogic.gdx.math.RectanglecomputeBounds(com.badlogic.gdx.math.Rectangle rect) Returns the minimal rectangle bounding this mesh.div(float scale) Uniformly scales all of the vertices of this mesh.div(com.badlogic.gdx.math.Vector2 scale) Nonuniformly scales all of the vertices of this mesh.com.badlogic.gdx.graphics.ColorgetColor(int idx) Returns the vertex color for index idxcom.badlogic.gdx.graphics.ColorgetColor(int idx, com.badlogic.gdx.graphics.Color c) Returns the vertex color for index idxcom.badlogic.gdx.math.Vector2getGradientCoord(int idx) Returns the vertex gradient coordinate for index idxcom.badlogic.gdx.math.Vector2getGradientCoord(int idx, com.badlogic.gdx.math.Vector2 v) Returns the vertex gradient coordinate for index idxfloatgetGradientX(int idx) Returns the x-coordinate of the gradient for index idxfloatgetGradientY(int idx) Returns the y-coordinate of the gradient for index idxfloatgetPackedColor(int idx) Returns the packed color representation for index idxcom.badlogic.gdx.math.Vector2getPosition(int idx) Returns the vertex position for index idxcom.badlogic.gdx.math.Vector2getPosition(int idx, com.badlogic.gdx.math.Vector2 v) Returns the vertex position for index idxfloatgetPositionX(int idx) Returns the x-coordinate of the position for index idxfloatgetPositionY(int idx) Returns the y-coordinate of the position for index idxintReturns the float stride for vertices in this meshcom.badlogic.gdx.math.Vector2getTextureCoord(int idx) Returns the vertex texture coordinate for index idxcom.badlogic.gdx.math.Vector2getTextureCoord(int idx, com.badlogic.gdx.math.Vector2 v) Returns the vertex texture coordinate for index idxfloatgetTextureX(int idx) Returns the x-coordinate of the texture for index idxfloatgetTextureY(int idx) Returns the y-coordinate of the texture for index idxintReturns the number of indices in this meshbooleanReturns true if this mesh can be composed in aSpriteBatch.mul(com.badlogic.gdx.math.Matrix4 transform) Transforms all of the vertices of this mesh.voidpush(float x, float y) Adds a vertex to the end of this meshvoidpush(float x, float y, float tx, float ty) Adds a vertex to the end of this meshvoidpush(float x, float y, com.badlogic.gdx.graphics.Color color) Adds a vertex to the end of this meshvoidpush(float x, float y, com.badlogic.gdx.graphics.Color color, float tx, float ty) Adds a vertex to the end of this meshvoidpush(float x, float y, com.badlogic.gdx.graphics.Color color, float tx, float ty, float gx, float gy) Adds a vertex to the end of this mesh This method does not update the indices.voidpush(com.badlogic.gdx.math.Vector2 position) Adds a vertex to the end of this meshvoidpush(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Color color) Adds a vertex to the end of this meshvoidpush(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Color color, com.badlogic.gdx.math.Vector2 texcoord) Adds a vertex to the end of this meshvoidpush(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Color color, com.badlogic.gdx.math.Vector2 texcoord, com.badlogic.gdx.math.Vector2 gradcoord) Adds a vertex to the end of this meshvoidpush(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.math.Vector2 texcoord) Adds a vertex to the end of this meshscl(float scale) Uniformly scales all of the vertices of this mesh.scl(com.badlogic.gdx.math.Vector2 scale) Nonuniformly scales all of the vertices of this mesh.set(float[] vertices) Sets the sprite mesh to have the given verticesset(float[] vertices, int voffset, int vlength) Sets the sprite mesh to have the given vertices.set(float x, float y, float width, float height) Sets the sprite mesh to represent the given rectangle.set(com.badlogic.gdx.math.Rectangle rect) Sets the mesh to represent the given rectangle.set(SpriteMesh mesh) Sets this sprite mesh to be a copy of the given one.Sets this sprite mesh using the given path.Sets this sprite mesh using the given path and boundsSets this sprite mesh using the given path and boundsSets this sprite mesh using the given path and boundsSets this sprite mesh using the given polygon.Sets this sprite mesh using the given polygon and boundsSets this sprite mesh using the given polygon and boundsSets this sprite mesh using the given polygon and boundsvoidsetColor(int idx, com.badlogic.gdx.graphics.Color c) Sets the vertex color for index idxvoidsetGradientCoord(int idx, float x, float y) Sets the vertex gradient coordinate for index idxvoidsetGradientCoord(int idx, com.badlogic.gdx.math.Vector2 v) Sets the vertex gradient coordinate for index idx.setIndices(short[] indices) Sets the indices for this sprite mesh to the ones given.setIndices(short[] indices, int ioffset, int ilength) Sets the indices for this sprite mesh to the ones given.voidsetPackedColor(int idx, float c) Sets the packed color representation for index idxvoidsetPosition(int idx, float x, float y) Sets the vertex position for index idxvoidsetPosition(int idx, com.badlogic.gdx.math.Vector2 v) Sets the vertex position for index idxvoidsetTextureCoord(int idx, float x, float y) Sets the vertex texture coordinate for index idxvoidsetTextureCoord(int idx, com.badlogic.gdx.math.Vector2 v) Sets the vertex texture coordinate for index idxsub(float offset) Uniformly translates all of the vertices of this mesh.sub(float x, float y) Non-uniformly translates all of the vertices of this mesh.sub(com.badlogic.gdx.math.Vector2 offset) Non-uniformly translates all of the vertices of this mesh.transform(com.badlogic.gdx.math.Affine2 matrix) Transforms all of the positional data in this mesh.transform(com.badlogic.gdx.math.Affine2 matrix, int offset, int count) Transforms all of the positional data in this mesh.intReturns the number of vertices in this mesh
-
Field Details
-
command
public int commandThe drawing command -
vertices
public com.badlogic.gdx.utils.FloatArray verticesThe vertices for this mesh -
indices
public com.badlogic.gdx.utils.ShortArray indicesThe indices for this mesh
-
-
Constructor Details
-
SpriteMesh
public SpriteMesh()Creates an empty sprite mesh.The created mesh has no vertices and no triangulation. The drawing command is also invalid.
-
SpriteMesh
public SpriteMesh(float[] vertices) Sets the sprite mesh to have the given verticesThe resulting mesh has no indices triangulating the vertices. The drawing command is also invalid.
- Parameters:
vertices- The vector of vertices (as float in pairs) in this mesh.
-
SpriteMesh
public SpriteMesh(float[] vertices, int voffset, int vlength) Sets the sprite mesh to have the given verticesThe resulting mesh has no indices triangulating the vertices. The drawing command is also invalid.
- Parameters:
vertices- The vector of vertices (as float in pairs) in this polygonvoffset- The offset of the first array vertexvlength- The array size to use
-
SpriteMesh
public SpriteMesh(float[] vertices, short[] indices) Sets the sprite mesh to have the given vertices and indices.The drawing command is inferred from the size of the indices. If the length of the indices is a multiple of 3, it uses GL_TRIANGLES. If it is a multiple of 2, it uses GL_LINES. Otherwise it is invalid.
- Parameters:
vertices- The float array of vertices (as float in pairs) in this meshindices- The array of indices in this polygon
-
SpriteMesh
Creates a sprite mesh from the given polygon.The color will be white. All texture and gradient coordinates are 0.
- Parameters:
poly- The defining polygon
-
SpriteMesh
Creates a sprite mesh from the given polygon and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the rectangle (0,0,width,height), and the polygon vertices are superimposed onto this texture layout. So if the polygon fits inside of this rectangle, it will cut out the parts of the image in its interior, like a cookie cutter.
Note that if the rectangle is smaller than the polygon, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
- Parameters:
poly- The defining polygonwidth- The texture widthheight- The texture height
-
SpriteMesh
Creates a sprite mesh from the given polygon and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the polygon vertices are superimposed onto this texture layout. So if the polygon fits inside of this rectangle, it will cut out the parts of the image in its interior, like a cookie cutter.
Note that if the rectangle is smaller than the polygon, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
- Parameters:
poly- The defining polygonx- The left edge of the texture boundsy- The bottom edge of the texture boundswidth- The texture widthheight- The texture height
-
SpriteMesh
Creates a sprite mesh from the given polygon and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the polygon vertices are superimposed onto this texture layout. So if the polygon fits inside of this rectangle, it will cut out the parts of the image in its interior, like a cookie cutter.
Note that if the rectangle is smaller than the polygon, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
- Parameters:
poly- The defining polygonrect- The texture bounds
-
SpriteMesh
Creates a sprite mesh from the given path.The color will be white. All texture and gradient coordinates are 0.
- Parameters:
path- The defining path
-
SpriteMesh
Creates a sprite mesh from the given path and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the rectangle (0,0,width,height), and the path vertices are superimposed onto this texture layout. So any for any part of the path that fits inside the bounds, the path will pick up the appropriate part of the image, like a cookie cutter.
Note that if the rectangle is smaller than the path, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
- Parameters:
path- The defining pathwidth- The texture widthheight- The texture height
-
SpriteMesh
Creates a sprite mesh from the given path and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the path vertices are superimposed onto this texture layout. So any for any part of the path that fits inside the bounds, the path will pick up the appropriate part of the image, like a cookie cutter.
Note that if the rectangle is smaller than the path, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
- Parameters:
path- The defining pathx- The left edge of the texture boundsy- The bottom edge of the texture boundswidth- The texture widthheight- The texture height
-
SpriteMesh
Creates a sprite mesh from the given path and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the path vertices are superimposed onto this texture layout. So any for any part of the path that fits inside the bounds, the path will pick up the appropriate part of the image, like a cookie cutter.
Note that if the rectangle is smaller than the path, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
- Parameters:
path- The defining pathrect- The texture bounds
-
SpriteMesh
Creates a copy of the given sprite mesh.All of the contents are copied, so that this mesh does not hold any references to elements of the other mesh.
- Parameters:
mesh- The mesh to copy
-
SpriteMesh
public SpriteMesh(com.badlogic.gdx.math.Rectangle rect) Creates a rectangular sprite mesh.The polygon will have four vertices, one for each corner of the rectangle. The indices will define two triangles on these vertices. This method is faster than using one of the more heavy-weight triangulators.
The color will be white. The texture and gradient coordinates will align with the rectangle so that any texture is sized to fit
- Parameters:
rect- The rectangle to copy
-
SpriteMesh
public SpriteMesh(float x, float y, float width, float height) Creates a rectangular sprite mesh.The polygon will have four vertices, one for each corner of the rectangle. The indices will define two triangles on these vertices. This method is faster than using one of the more heavy-weight triangulators.
The color will be white. The texture and gradient coordinates will align with the rectangle so that any texture is sized to fit
- Parameters:
x- The rectangle left edgey- The rectangle bottom edgewidth- The rectangle widthheight- The rectangle height
-
-
Method Details
-
mul
Transforms all of the vertices of this mesh.Since meshes can have arbitrary dimensions, the only guaranteed safe transforms are 4x4 matrices like
Matrix4.- Parameters:
transform- The transformation matrix- Returns:
- This mesh with transformed vertices
-
getStride
public int getStride()Returns the float stride for vertices in this mesh- Returns:
- the float stride for vertices in this mesh
-
set
Sets the sprite mesh to have the given verticesThe method will invalid the indices. The resulting mesh has no indices triangulating the vertices. The drawing command is also invalid.
This method returns a reference to this mesh for chaining.
- Parameters:
vertices- The vertices in this mesh- Returns:
- This mesh, returned for chaining
-
set
Sets the sprite mesh to have the given vertices.The method will invalid the indices. The resulting mesh has no indices triangulating the vertices. The drawing command is also invalid.
This method returns a reference to this mesh for chaining.
- Parameters:
vertices- The array of vertices in this meshvoffset- The offset of the first array vertexvlength- The array size to use- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given polygon.The color will be white. All texture and gradient coordinates are 0.
This method returns a reference to this mesh for chaining.
- Parameters:
poly- The defining polygon- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given polygon and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the rectangle (0,0,width,height), and the polygon vertices are superimposed onto this texture layout. So if the polygon fits inside of this rectangle, it will cut out the parts of the image in its interior, like a cookie cutter.
Note that if the rectangle is smaller than the polygon, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
This method returns a reference to this mesh for chaining.
- Parameters:
poly- The defining polygonwidth- The texture widthheight- The texture height- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given polygon and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the polygon vertices are superimposed onto this texture layout. So if the polygon fits inside of this rectangle, it will cut out the parts of the image in its interior, like a cookie cutter.
Note that if the rectangle is smaller than the polygon, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
This method returns a reference to this mesh for chaining.
- Parameters:
poly- The defining polygonx- The left edge of the texture boundsy- The bottom edge of the texture boundswidth- The texture widthheight- The texture height- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given polygon and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the polygon vertices are superimposed onto this texture layout. So if the polygon fits inside of this rectangle, it will cut out the parts of the image in its interior, like a cookie cutter.
Note that if the rectangle is smaller than the polygon, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
This method returns a reference to this mesh for chaining.
- Parameters:
poly- The defining polygonrect- The texture bounds- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given path.The color will be white. All texture and gradient coordinates are 0.
This method returns a reference to this mesh for chaining.
- Parameters:
path- The defining path- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given path and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the rectangle (0,0,width,height), and the path vertices are superimposed onto this texture layout. So any for any part of the path that fits inside the bounds, the path will pick up the appropriate part of the image, like a cookie cutter.
Note that if the rectangle is smaller than the path, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
This method returns a reference to this mesh for chaining.
- Parameters:
path- The defining pathwidth- The texture widthheight- The texture height- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given path and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the path vertices are superimposed onto this texture layout. So any for any part of the path that fits inside the bounds, the path will pick up the appropriate part of the image, like a cookie cutter.
Note that if the rectangle is smaller than the path, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
This method returns a reference to this mesh for chaining.
- Parameters:
path- The defining pathx- The left edge of the texture boundsy- The bottom edge of the texture boundswidth- The texture widthheight- The texture height- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh using the given path and boundsThe color will be white. The texture and gradient coordinates are each inferred from the provided bounds, using a "cookie-cutter" interpretation. That is, the texture is assumed to be sized to fit in the given rectangle, and the path vertices are superimposed onto this texture layout. So any for any part of the path that fits inside the bounds, the path will pick up the appropriate part of the image, like a cookie cutter.
Note that if the rectangle is smaller than the path, then this has the effect of tiling the image across the polygon. In such cases, the texture associated with this sprite mesh should be set to REPEAT.
This method returns a reference to this mesh for chaining.
- Parameters:
path- The defining pathrect- The texture bounds- Returns:
- This mesh, returned for chaining
-
set
Sets this sprite mesh to be a copy of the given one.All of the contents are copied, so that this mesh does not hold any references to elements of the other mesh.
This method returns a reference to this mesh for chaining.
- Parameters:
mesh- The mesh to copy- Returns:
- This mesh, returned for chaining
-
set
Sets the mesh to represent the given rectangle.The polygon will have four vertices, one for each corner of the rectangle. The indices will define two triangles on these vertices. This method is faster than using one of the more heavy-weight triangulators.
The color will be white. The texture and gradient coordinates will align with the rectangle.
This method returns a reference to this mesh for chaining.
- Parameters:
rect- The rectangle to copy- Returns:
- This mesh, returned for chaining
-
set
Sets the sprite mesh to represent the given rectangle.The polygon will have four vertices, one for each corner of the rectangle. The indices will define two triangles on these vertices. This method is faster than using one of the more heavy-weight triangulators.
The color will be white. The texture and gradient coordinates will align with the rectangle so that any texture is sized to fit
This method returns a reference to this mesh for chaining.
- Parameters:
x- The rectangle left edgey- The rectangle bottom edgewidth- The rectangle widthheight- The rectangle height- Returns:
- This mesh, returned for chaining
-
setIndices
Sets the indices for this sprite mesh to the ones given.A valid list of indices must only refer to vertices in the vertex array. That is, the indices should all be non-negative, and each value should be less than the number of vertices. In addition, the number of indices should be a consistent the the current command (GL_TRIANGLES) or (GL_LINES). However, this method does not currently enforce either of these preconditions.
The provided indices are copied. The mesh does not retain a reference.
- Parameters:
indices- The vector of indices for the shape- Returns:
- This mesh, returned for chaining
-
setIndices
Sets the indices for this sprite mesh to the ones given.A valid list of indices must only refer to vertices in the vertex array. That is, the indices should all be non-negative, and each value should be less than the number of vertices. In addition, the number of indices should be a consistent the the current command (GL_TRIANGLES) or (GL_LINES). However, this method does not currently enforce either of these preconditions.
The provided indices are copied. The mesh does not retain a reference.
- Parameters:
indices- The array of indices for the renderingioffset- The offset of the first array vertexilength- The array size to use- Returns:
- This mesh, returned for chaining
-
clear
public void clear()Clears the contents of this sprite mesh (both vertices and indices) -
isComposable
public boolean isComposable()Returns true if this mesh can be composed in aSpriteBatch.Composable meshes can be drawn together in a single pass. Only the commands `GL_TRIANGLES`, `GL_LINES`, and `GL_POINTS` are composable.
- Returns:
- true if this mesh can be composed in a
SpriteBatch.
-
vertexCount
public int vertexCount()Returns the number of vertices in this mesh- Returns:
- the number of vertices in this mesh
-
indexCount
public int indexCount()Returns the number of indices in this mesh- Returns:
- the number of indices in this mesh
-
getPositionX
public float getPositionX(int idx) Returns the x-coordinate of the position for index idx- Parameters:
idx- The vertex index- Returns:
- the x-coordinate of the position for index idx
-
getPositionY
public float getPositionY(int idx) Returns the y-coordinate of the position for index idx- Parameters:
idx- The vertex index- Returns:
- the y-coordinate of the position for index idx
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition(int idx) Returns the vertex position for index idxNote that this method creates a new Vector2 object. You can prevent this memory allocation by using the alternate getter.
- Parameters:
idx- The vertex index- Returns:
- the vertex position for index idx
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition(int idx, com.badlogic.gdx.math.Vector2 v) Returns the vertex position for index idxNote that this method places the data into the provided Vector2 object, preventing an object allocation. It will return this vector for chaining.
- Parameters:
idx- The vertex indexv- The vector to store the results;- Returns:
- the vertex position for index idx
-
setPosition
public void setPosition(int idx, com.badlogic.gdx.math.Vector2 v) Sets the vertex position for index idx- Parameters:
idx- The vertex indexv- The vertex position
-
setPosition
public void setPosition(int idx, float x, float y) Sets the vertex position for index idx- Parameters:
idx- The vertex indexx- The vertex x-coordinatey- The vertex y-coordinate
-
getPackedColor
public float getPackedColor(int idx) Returns the packed color representation for index idx- Parameters:
idx- The vertex index- Returns:
- the packed color representation for index idx
-
setPackedColor
public void setPackedColor(int idx, float c) Sets the packed color representation for index idx- Parameters:
idx- The vertex indexc- The packed color representation
-
getColor
public com.badlogic.gdx.graphics.Color getColor(int idx) Returns the vertex color for index idxNote that this method creates a new Color object. You can prevent this memory allocation by using the alternate getter.
- Parameters:
idx- The vertex index- Returns:
- the vertex color for index idx
-
getColor
public com.badlogic.gdx.graphics.Color getColor(int idx, com.badlogic.gdx.graphics.Color c) Returns the vertex color for index idxNote that this method places the data into the provided Color object, preventing an object allocation. It will return this vector for chaining.
- Parameters:
idx- The vertex indexc- The color to store the results;- Returns:
- the vertex color for index idx
-
setColor
public void setColor(int idx, com.badlogic.gdx.graphics.Color c) Sets the vertex color for index idx- Parameters:
idx- The vertex indexc- The vertex color
-
getTextureX
public float getTextureX(int idx) Returns the x-coordinate of the texture for index idx- Parameters:
idx- The vertex index- Returns:
- the x-coordinate of the texture for index idx
-
getTextureY
public float getTextureY(int idx) Returns the y-coordinate of the texture for index idx- Parameters:
idx- The vertex index- Returns:
- the y-coordinate of the texture for index idx
-
getTextureCoord
public com.badlogic.gdx.math.Vector2 getTextureCoord(int idx) Returns the vertex texture coordinate for index idxNote that this method creates a new Vector2 object. You can prevent this memory allocation by using the alternate getter.
- Parameters:
idx- The vertex index- Returns:
- the vertex texture coordinate for index idx
-
getTextureCoord
public com.badlogic.gdx.math.Vector2 getTextureCoord(int idx, com.badlogic.gdx.math.Vector2 v) Returns the vertex texture coordinate for index idxNote that this method places the data into the provided Vector2 object, preventing an object allocation. It will return this vector for chaining.
- Parameters:
idx- The vertex indexv- The vector to store the results;- Returns:
- the vertex texture coordinate for index idx
-
setTextureCoord
public void setTextureCoord(int idx, com.badlogic.gdx.math.Vector2 v) Sets the vertex texture coordinate for index idx- Parameters:
idx- The vertex indexv- The vertex texture coordinate
-
setTextureCoord
public void setTextureCoord(int idx, float x, float y) Sets the vertex texture coordinate for index idx- Parameters:
idx- The vertex indexx- The texture x-coordinatey- The texture y-coordinate
-
getGradientX
public float getGradientX(int idx) Returns the x-coordinate of the gradient for index idxThis method returns 0 if gradient coordinates are not supported.
- Parameters:
idx- The vertex index- Returns:
- the x-coordinate of the gradient for index idx
-
getGradientY
public float getGradientY(int idx) Returns the y-coordinate of the gradient for index idxThis method returns 0 if gradient coordinates are not supported.
- Parameters:
idx- The vertex index- Returns:
- the y-coordinate of the gradient for index idx
-
getGradientCoord
public com.badlogic.gdx.math.Vector2 getGradientCoord(int idx) Returns the vertex gradient coordinate for index idxNote that this method creates a new Vector2 object. You can prevent this memory allocation by using the alternate getter.
This method returns the zero vector if gradient coordinates are not supported.
- Parameters:
idx- The vertex index- Returns:
- the vertex gradient coordinate for index idx
-
getGradientCoord
public com.badlogic.gdx.math.Vector2 getGradientCoord(int idx, com.badlogic.gdx.math.Vector2 v) Returns the vertex gradient coordinate for index idxNote that this method places the data into the provided Vector2 object, preventing an object allocation. It will return this vector for chaining.
This method returns the zero vector if gradient coordinates are not supported.
- Parameters:
idx- The vertex indexv- The vector to store the results;- Returns:
- the vertex gradient coordinate for index idx
-
setGradientCoord
public void setGradientCoord(int idx, com.badlogic.gdx.math.Vector2 v) Sets the vertex gradient coordinate for index idx.This method does nothing if gradient coordinates are not supported.
- Parameters:
idx- The vertex indexv- The vertex gradient coordinate
-
setGradientCoord
public void setGradientCoord(int idx, float x, float y) Sets the vertex gradient coordinate for index idxThis method does nothing if gradient coordinates are not supported.
- Parameters:
idx- The vertex indexx- The gradient x-coordinatey- The gradient y-coordinate
-
scl
Uniformly scales all of the vertices of this mesh.The vertices are scaled from the origin of the coordinate space. This means that if the origin is not in the interior of this mesh, the mesh will be effectively translated by the scaling.
- Parameters:
scale- The uniform scaling factor- Returns:
- This mesh, scaled uniformly.
-
scl
Nonuniformly scales all of the vertices of this mesh.The vertices are scaled from the origin of the coordinate space. This means that if the origin is not in the interior of this mesh, the mesh will be effectively translated by the scaling.
- Parameters:
scale- The non-uniform scaling factor- Returns:
- This mesh, scaled non-uniformly.
-
div
Uniformly scales all of the vertices of this mesh.The vertices are scaled from the origin of the coordinate space. This means that if the origin is not in the interior of this mesh, the mesh will be effectively translated by the scaling.
- Parameters:
scale- The inverse of the uniform scaling factor- Returns:
- This mesh, scaled uniformly.
-
div
Nonuniformly scales all of the vertices of this mesh.The vertices are scaled from the origin of the coordinate space. This means that if the origin is not in the interior of this mesh, the mesh will be effectively translated by the scaling.
- Parameters:
scale- The inverse of the non-uniform scaling factor- Returns:
- This mesh, scaled non-uniformly.
-
add
Uniformly translates all of the vertices of this mesh.- Parameters:
offset- The uniform translation amount- Returns:
- This mesh, translated uniformly.
-
add
Non-uniformly translates all of the vertices of this mesh.- Parameters:
offset- The non-uniform translation amount- Returns:
- This mesh, translated non-uniformly.
-
add
Non-uniformly translates all of the vertices of this mesh.- Parameters:
x- The x-coordinate translation amounty- The y-coordinate translation amount- Returns:
- This mesh, translated non-uniformly.
-
sub
Uniformly translates all of the vertices of this mesh.- Parameters:
offset- The inverse of the uniform translation amount- Returns:
- This mesh, translated uniformly.
-
sub
Non-uniformly translates all of the vertices of this mesh.- Parameters:
offset- The inverse of the non-uniform translation amount- Returns:
- This mesh, translated non-uniformly.
-
sub
Non-uniformly translates all of the vertices of this mesh.- Parameters:
x- The inverse of the x-coordinate translation amounty- The inverse of the y-coordinate translation amount- Returns:
- This mesh, translated non-uniformly.
-
transform
Transforms all of the positional data in this mesh.- Parameters:
matrix- The transform matrix- Returns:
- This mesh with the vertices transformed
-
transform
Transforms all of the positional data in this mesh.The value offset is a vertex position, not a float array position.
- Parameters:
matrix- The transform matrixoffset- The first vertex to transformcount- The number of vertices to transform- Returns:
- This mesh with the vertices transformed
-
push
public void push(com.badlogic.gdx.math.Vector2 position) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The colors and texture/gradient coordinates will be set to the defaults.
- Parameters:
position- The vertex position
-
push
public void push(float x, float y) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The colors and texture/gradient coordinates will be set to the defaults.
- Parameters:
x- The vertex x-coordinatey- The vertex y-coordinate
-
push
public void push(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Color color) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The colors and texture/gradient coordinates will be set to the defaults.
- Parameters:
position- The vertex positioncolor- The vertex color
-
push
public void push(float x, float y, com.badlogic.gdx.graphics.Color color) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The colors and texture/gradient coordinates will be set to the defaults.
- Parameters:
x- The vertex x-coordinatey- The vertex y-coordinatecolor- The vertex color
-
push
public void push(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.math.Vector2 texcoord) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The color will be the default white. The gradient coordinates will agree with the texture coordinates.
- Parameters:
position- The vertex positiontexcoord- The vertex texture coordinates
-
push
public void push(float x, float y, float tx, float ty) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The color will be the default white. The gradient coordinates will agree with the texture coordinates.
- Parameters:
x- The vertex x-coordinatey- The vertex y-coordinatetx- The texture x-coordinatety- The texture y-coordinate
-
push
public void push(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Color color, com.badlogic.gdx.math.Vector2 texcoord) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. Gradient coordinates will be ignored if they are not supported.
- Parameters:
position- The vertex positioncolor- The vertex colortexcoord- The vertex texture coordinates
-
push
public void push(float x, float y, com.badlogic.gdx.graphics.Color color, float tx, float ty) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. The color will be the default white. The gradient coordinates will agree with the texture coordinates.
- Parameters:
x- The vertex x-coordinatey- The vertex y-coordinatecolor- The vertex colortx- The texture x-coordinatety- The texture y-coordinate
-
push
public void push(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Color color, com.badlogic.gdx.math.Vector2 texcoord, com.badlogic.gdx.math.Vector2 gradcoord) Adds a vertex to the end of this meshThis method does not update the indices. It is simply a convenience method for adding vertices. Gradient coordinates will be ignored if they are not supported.
- Parameters:
position- The vertex positioncolor- The vertex colortexcoord- The vertex texture coordinatesgradcoord- The vertex gradient coordinates
-
push
public void push(float x, float y, com.badlogic.gdx.graphics.Color color, float tx, float ty, float gx, float gy) Adds a vertex to the end of this mesh This method does not update the indices. It is simply a convenience method for adding vertices. Gradient coordinates will be ignored if they are not supported.- Parameters:
x- The vertex x-coordinatey- The vertex y-coordinatecolor- The vertex colortx- The texture x-coordinatety- The texture y-coordinategx- The gradient x-coordinategy- The gradient y-coordinate
-
computeBounds
public com.badlogic.gdx.math.Rectangle computeBounds()Returns the minimal rectangle bounding this mesh.- Returns:
- the minimal rectangle bounding this mesh.
-
computeBounds
public com.badlogic.gdx.math.Rectangle computeBounds(com.badlogic.gdx.math.Rectangle rect) Returns the minimal rectangle bounding this mesh.Note that this method places the data into the provided Rectangle object, preventing an object allocation. It will return this vector for chaining.
- Parameters:
rect- The rectangle to store the results;- Returns:
- the minimal rectangle bounding this mesh.
-