public static class

Mesh.TriangleMeshBuilder

extends Object
java.lang.Object
   ↳ android.renderscript.Mesh.TriangleMeshBuilder

Class Overview

Builder that allows creation of a mesh object point by point and triangle by triangle

Summary

Constants
int COLOR
int NORMAL
int TEXTURE_0
Public Constructors
Mesh.TriangleMeshBuilder(RenderScript rs, int vtxSize, int flags)
Public Methods
Mesh.TriangleMeshBuilder addTriangle(int idx1, int idx2, int idx3)
Adds a new triangle to the mesh builder
Mesh.TriangleMeshBuilder addVertex(float x, float y, float z)
Adds a float3 vertex to the mesh
Mesh.TriangleMeshBuilder addVertex(float x, float y)
Adds a float2 vertex to the mesh
Mesh create(boolean uploadToBufferObject)
Creates the mesh object from the current state of the builder
Mesh.TriangleMeshBuilder setColor(float r, float g, float b, float a)
Sets the color for the last added vertex
Mesh.TriangleMeshBuilder setNormal(float x, float y, float z)
Sets the normal vector for the last added vertex
Mesh.TriangleMeshBuilder setTexture(float s, float t)
Sets the texture coordinate for the last added vertex
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int COLOR

Since: API Level 11

Constant Value: 1 (0x00000001)

public static final int NORMAL

Since: API Level 11

Constant Value: 2 (0x00000002)

public static final int TEXTURE_0

Since: API Level 11

Constant Value: 256 (0x00000100)

Public Constructors

public Mesh.TriangleMeshBuilder (RenderScript rs, int vtxSize, int flags)

Since: API Level 11

Parameters
rs Context to which the mesh will belong.
vtxSize specifies whether the vertex is a float2 or float3
flags bitfield that is a combination of COLOR, NORMAL, and TEXTURE_0 that specifies what vertex data channels are present in the mesh

Public Methods

public Mesh.TriangleMeshBuilder addTriangle (int idx1, int idx2, int idx3)

Since: API Level 11

Adds a new triangle to the mesh builder

Parameters
idx1 index of the first vertex in the triangle
idx2 index of the second vertex in the triangle
idx3 index of the third vertex in the triangle
Returns
  • this

public Mesh.TriangleMeshBuilder addVertex (float x, float y, float z)

Since: API Level 11

Adds a float3 vertex to the mesh

Parameters
x position x
y position y
z position z
Returns
  • this

public Mesh.TriangleMeshBuilder addVertex (float x, float y)

Since: API Level 11

Adds a float2 vertex to the mesh

Parameters
x position x
y position y
Returns
  • this

public Mesh create (boolean uploadToBufferObject)

Since: API Level 11

Creates the mesh object from the current state of the builder

Parameters
uploadToBufferObject specifies whether the vertex data is to be uploaded into the buffer object indicating that it's likely not going to be modified and rendered many times. Alternatively, it indicates the mesh data will be updated frequently and remain in script accessible memory

public Mesh.TriangleMeshBuilder setColor (float r, float g, float b, float a)

Since: API Level 11

Sets the color for the last added vertex

Parameters
r red component
g green component
b blue component
a alpha component
Returns
  • this

public Mesh.TriangleMeshBuilder setNormal (float x, float y, float z)

Since: API Level 11

Sets the normal vector for the last added vertex

Parameters
x normal vector x
y normal vector y
z normal vector z
Returns
  • this

public Mesh.TriangleMeshBuilder setTexture (float s, float t)

Since: API Level 11

Sets the texture coordinate for the last added vertex

Parameters
s texture coordinate s
t texture coordinate t
Returns
  • this