public class Renderable extends Object
mesh
, meshPartOffset
, meshPartSize
and primitiveType
members. This matches the members of the MeshPart
class. The meshPartOffset
is used to specify the offset
within the mesh and the meshPartSize
is used to specify the part (in total number of vertices) to render. If the mesh
is indexed (which is when Mesh.getNumIndices()
> 0) then both values are in number of indices within the indices array
of the mesh, otherwise they are in number of vertices within the vertices array of the mesh. Note that some classes might
require the mesh to be indexed.
The material
and (optional) environment
values are combined to specify how the shape should look like.
Typically these are used to specify uniform values or other OpenGL state changes. When a value is present in both the
material
and environment
, then the value of the material
will be used.
Renderables can be rendered directly using a Shader
(in which case the shader
member is ignored). Though more
typically Renderables are rendered via a ModelBatch
, either directly, or by passing a RenderableProvider
like
ModelInstance
to the RenderBatch.
A ModelInstance returns all Renderables via its ModelInstance.getRenderables(Array, Pool)
method. In which case the
value of ModelInstance.userData
will be set to the userData
member. The userData
member can be used
to pass additional data to the shader. However, in most scenario's it is advised to use the material
or
environment
member with custom Attribute
s to pass data to the shader.
In some cases, (for example for non-hierarchical basic game objects requiring only a single draw call) it is possible to extend
the Renderable class and add additional fields to pass to the shader. While extending the Renderable class can be useful, the
shader should not rely on it. Similar to the userData
member it is advised to use the material
and
environment
members to pass data to the shader.
When using a ModelBatch to render a Renderable, The Renderable and all its values must not be changed in between the call to
ModelBatch.begin(com.badlogic.gdx.graphics.Camera)
and ModelBatch.end()
. Therefor Renderable instances cannot
be reused for multiple render calls.
When the shader
member of the Renderable is set, the ShaderProvider
of the ModelBatch
may decide to
use that shader instead of the default shader. Therefor, to assure the default shader is used, the shader
member must
be set to null.Modifier and Type | Field and Description |
---|---|
Matrix4[] |
bones
The bone transformations used for skinning, or null if not applicable.
|
Environment |
environment
The
Environment to be used to render this Renderable, may be null. |
Material |
material
The
Material to be applied to the shape (part of the mesh), must not be null. |
Mesh |
mesh
The
Mesh which contains the part to render |
int |
meshPartOffset
The offset in the
mesh to the part to render. |
int |
meshPartSize
The size (in total number of vertices) of the part in the
mesh to render. |
int |
primitiveType
The primitive type, OpenGL constant e.g:
GL20.GL_TRIANGLES , GL20.GL_POINTS , GL20.GL_LINES ,
GL20.GL_LINE_STRIP , GL20.GL_TRIANGLE_STRIP |
Shader |
shader
The
Shader to be used to render this Renderable using a ModelBatch , may be null. |
Object |
userData
User definable value, may be null.
|
Matrix4 |
worldTransform
Used to specify the transformations (like translation, scale and rotation) to apply to the shape.
|
Constructor and Description |
---|
Renderable() |
public final Matrix4 worldTransform
public int meshPartOffset
mesh
to the part to render. If the mesh is indexed (Mesh.getNumIndices()
> 0), this is
the offset in the indices array, otherwise it is the offset in the vertices array.public int meshPartSize
mesh
to render. When the mesh is indexed (
Mesh.getNumIndices()
> 0), this is the number of indices, otherwise it is the number of vertices.public int primitiveType
GL20.GL_TRIANGLES
, GL20.GL_POINTS
, GL20.GL_LINES
,
GL20.GL_LINE_STRIP
, GL20.GL_TRIANGLE_STRIP
public Material material
Material
to be applied to the shape (part of the mesh), must not be null.environment
public Environment environment
Environment
to be used to render this Renderable, may be null. When specified it will be combined by the shader
with the material
. When both the material and environment contain an attribute of the same type, the attribute of
the material will be used.public Matrix4[] bones
VertexAttributes.Usage.BoneWeight
vertex attributes, then the BoneWeight index is used as
index in the array. If the array isn't large enough then the identity matrix is used. Each BoneWeight weight is used to
combine multiple bones into a single transformation matrix, which is used to transform the vertex to model space. In other
words: the bone transformation is applied prior to the worldTransform
.public Shader shader
Shader
to be used to render this Renderable using a ModelBatch
, may be null.
It is not guaranteed that the shader will be used, the used ShaderProvider
is responsible
for actually choosing the correct shader to use.public Object userData
public Renderable set(Renderable renderable)
Copyright © 2015. All rights reserved.