Mesh

public class Mesh
extends Object

java.lang.Object
   ↳ android.graphics.Mesh


Class representing a mesh object. This class represents a Mesh object that can optionally be indexed. A MeshSpecification is required along with various attributes for detailing the mesh object, including a mode, vertex buffer, optional index buffer, and bounds for the mesh. Once generated, a mesh object can be drawn through Canvas#drawMesh(Mesh, BlendMode, Paint)

Summary

Constants

int TRIANGLES

The mesh will be drawn with triangles without utilizing shared vertices.

int TRIANGLE_STRIP

The mesh will be drawn with triangles utilizing shared vertices.

Public constructors

Mesh(MeshSpecification meshSpec, int mode, Buffer vertexBuffer, int vertexCount, RectF bounds)

Constructor for a non-indexed Mesh.

Mesh(MeshSpecification meshSpec, int mode, Buffer vertexBuffer, int vertexCount, ShortBuffer indexBuffer, RectF bounds)

Constructor for an indexed Mesh.

Public methods

void setColorUniform(String uniformName, int color)

Sets the uniform color value corresponding to the shader assigned to the mesh.

void setColorUniform(String uniformName, long color)

Sets the uniform color value corresponding to the shader assigned to the mesh.

void setColorUniform(String uniformName, Color color)

Sets the uniform color value corresponding to the shader assigned to the mesh.

void setFloatUniform(String uniformName, float[] values)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setFloatUniform(String uniformName, float value)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setFloatUniform(String uniformName, float value1, float value2, float value3, float value4)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setFloatUniform(String uniformName, float value1, float value2)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setFloatUniform(String uniformName, float value1, float value2, float value3)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setIntUniform(String uniformName, int value)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setIntUniform(String uniformName, int value1, int value2, int value3)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setIntUniform(String uniformName, int value1, int value2, int value3, int value4)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setIntUniform(String uniformName, int[] values)

Sets the uniform value corresponding to the shader assigned to the mesh.

void setIntUniform(String uniformName, int value1, int value2)

Sets the uniform value corresponding to the shader assigned to the mesh.

Inherited methods

Constants

TRIANGLES

Added in API level 34
public static final int TRIANGLES

The mesh will be drawn with triangles without utilizing shared vertices.

Constant Value: 0 (0x00000000)

TRIANGLE_STRIP

Added in API level 34
public static final int TRIANGLE_STRIP

The mesh will be drawn with triangles utilizing shared vertices.

Constant Value: 1 (0x00000001)

Public constructors

Mesh

Added in API level 34
public Mesh (MeshSpecification meshSpec, 
                int mode, 
                Buffer vertexBuffer, 
                int vertexCount, 
                RectF bounds)

Constructor for a non-indexed Mesh.

Parameters
meshSpec MeshSpecification: MeshSpecification used when generating the mesh. This value cannot be null.

mode int: Determines what mode to draw the mesh in. Must be one of Mesh#TRIANGLES or Mesh#TRIANGLE_STRIP Value is TRIANGLES, or TRIANGLE_STRIP

vertexBuffer Buffer: vertex buffer representing through Buffer. This provides the data for all attributes provided within the meshSpec for every vertex. That is, a vertex buffer should be (attributes size * number of vertices) in length to be valid. Note that currently implementation will have a CPU backed buffer generated. This value cannot be null.

vertexCount int: the number of vertices represented in the vertexBuffer and mesh.

bounds RectF: bounds of the mesh object. This value cannot be null.

Mesh

Added in API level 34
public Mesh (MeshSpecification meshSpec, 
                int mode, 
                Buffer vertexBuffer, 
                int vertexCount, 
                ShortBuffer indexBuffer, 
                RectF bounds)

Constructor for an indexed Mesh.

Parameters
meshSpec MeshSpecification: MeshSpecification used when generating the mesh. This value cannot be null.

mode int: Determines what mode to draw the mesh in. Must be one of Mesh#TRIANGLES or Mesh#TRIANGLE_STRIP Value is TRIANGLES, or TRIANGLE_STRIP

vertexBuffer Buffer: vertex buffer representing through Buffer. This provides the data for all attributes provided within the meshSpec for every vertex. That is, a vertex buffer should be (attributes size * number of vertices) in length to be valid. Note that currently implementation will have a CPU backed buffer generated. This value cannot be null.

vertexCount int: the number of vertices represented in the vertexBuffer and mesh.

indexBuffer ShortBuffer: index buffer representing through ShortBuffer. Indices are required to be 16 bits, so ShortBuffer is necessary. Note that currently implementation will have a CPU backed buffer generated. This value cannot be null.

bounds RectF: bounds of the mesh object. This value cannot be null.

Public methods

setColorUniform

Added in API level 34
public void setColorUniform (String uniformName, 
                int color)

Sets the uniform color value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than vec3 or vec4 and corresponding layout(color) annotation then an IllegalArgumentExcepton is thrown.

Parameters
uniformName String: name matching the color uniform declared in the shader program. This value cannot be null.

color int: the provided sRGB color will be converted into the shader program's output colorspace and be available as a vec4 uniform in the program.

setColorUniform

Added in API level 34
public void setColorUniform (String uniformName, 
                long color)

Sets the uniform color value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than vec3 or vec4 and corresponding layout(color) annotation then an IllegalArgumentExcepton is thrown.

Parameters
uniformName String: name matching the color uniform declared in the shader program. This value cannot be null.

color long: the provided sRGB color will be converted into the shader program's output colorspace and be available as a vec4 uniform in the program.

setColorUniform

Added in API level 34
public void setColorUniform (String uniformName, 
                Color color)

Sets the uniform color value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than vec3 or vec4 and corresponding layout(color) annotation then an IllegalArgumentExcepton is thrown.

Parameters
uniformName String: name matching the color uniform declared in the shader program. This value cannot be null.

color Color: the provided sRGB color will be converted into the shader program's output colorspace and will be made available as a vec4 uniform in the program. This value cannot be null.

setFloatUniform

Added in API level 34
public void setFloatUniform (String uniformName, 
                float[] values)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a float (for N=1), vecN, or float[N], where N is the length of the values param, then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.

values float: float value corresponding to the vec4 float uniform with the given name. This value cannot be null.

setFloatUniform

Added in API level 34
public void setFloatUniform (String uniformName, 
                float value)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a float or float[1] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.

value float: float value corresponding to the float uniform with the given name.

setFloatUniform

Added in API level 34
public void setFloatUniform (String uniformName, 
                float value1, 
                float value2, 
                float value3, 
                float value4)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a vec4 or float[4] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.

value1 float: first float value corresponding to the float uniform with the given name.

value2 float: second float value corresponding to the float uniform with the given name.

value3 float: third float value corresponding to the float uniform with the given name.

value4 float: fourth float value corresponding to the float uniform with the given name.

setFloatUniform

Added in API level 34
public void setFloatUniform (String uniformName, 
                float value1, 
                float value2)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a vec2 or float[2] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.

value1 float: first float value corresponding to the float uniform with the given name.

value2 float: second float value corresponding to the float uniform with the given name.

setFloatUniform

Added in API level 34
public void setFloatUniform (String uniformName, 
                float value1, 
                float value2, 
                float value3)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a vec3 or float[3] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.

value1 float: first float value corresponding to the float uniform with the given name.

value2 float: second float value corresponding to the float uniform with the given name.

value3 float: third float value corresponding to the float unifiform with the given name.

setIntUniform

Added in API level 34
public void setIntUniform (String uniformName, 
                int value)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than int or int[1] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform delcared in the shader program. This value cannot be null.

value int: value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
public void setIntUniform (String uniformName, 
                int value1, 
                int value2, 
                int value3)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than ivec3 or int[3] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform delcared in the shader program. This value cannot be null.

value1 int: first value corresponding to the int uniform with the given name.

value2 int: second value corresponding to the int uniform with the given name.

value3 int: third value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
public void setIntUniform (String uniformName, 
                int value1, 
                int value2, 
                int value3, 
                int value4)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than ivec4 or int[4] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform delcared in the shader program. This value cannot be null.

value1 int: first value corresponding to the int uniform with the given name.

value2 int: second value corresponding to the int uniform with the given name.

value3 int: third value corresponding to the int uniform with the given name.

value4 int: fourth value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
public void setIntUniform (String uniformName, 
                int[] values)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than an int (for N=1), ivecN, or int[N], where N is the length of the values param, then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform delcared in the shader program. This value cannot be null.

values int: int values corresponding to the vec4 int uniform with the given name. This value cannot be null.

setIntUniform

Added in API level 34
public void setIntUniform (String uniformName, 
                int value1, 
                int value2)

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than ivec2 or int[2] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform delcared in the shader program. This value cannot be null.

value1 int: first value corresponding to the int uniform with the given name.

value2 int: second value corresponding to the int uniform with the given name.