public class ShapeCache extends Object implements Disposable, RenderableProvider
Material
and transformation Matrix4
within the world. Use ModelBatch
to render the `ShapeCache`. Must be disposed when no longer needed to release native
resources.
How to use it :
// Create cache ShapeCache cache = new ShapeCache(); // Build the cache, for dynamic shapes, this would be in the render method. MeshPartBuilder builder = cache.begin(); FrustumShapeBuilder.build(builder, camera); BoxShapeBuilder.build(builder, box); cache.end() // Render modelBatch.render(cache); // After using it cache.dispose();
Constructor and Description |
---|
ShapeCache()
Create a ShapeCache with default values
|
ShapeCache(int maxVertices,
int maxIndices,
VertexAttributes attributes,
int primitiveType)
Create a ShapeCache with parameters
|
Modifier and Type | Method and Description |
---|---|
MeshPartBuilder |
begin()
Initialize ShapeCache for mesh generation with GL_LINES primitive type
|
MeshPartBuilder |
begin(int primitiveType)
Initialize ShapeCache for mesh generation
|
void |
dispose()
Releases all resources of this object.
|
void |
end()
Generate mesh and renderable
|
Material |
getMaterial()
Allows to customize the material.
|
void |
getRenderables(Array<Renderable> renderables,
Pool<Renderable> pool)
Returns
Renderable instances. |
Matrix4 |
getWorldTransform()
Allows to customize the world transform matrix.
|
public ShapeCache()
public ShapeCache(int maxVertices, int maxIndices, VertexAttributes attributes, int primitiveType)
maxVertices
- max vertices in meshmaxIndices
- max indices in meshattributes
- vertex attributesprimitiveType
- public MeshPartBuilder begin()
public MeshPartBuilder begin(int primitiveType)
primitiveType
- OpenGL primitive typepublic void end()
public void getRenderables(Array<Renderable> renderables, Pool<Renderable> pool)
RenderableProvider
Renderable
instances. Renderables are obtained from the provided Pool
and added to the provided
array. The Renderables obtained using Pool.obtain()
will later be put back into the pool, do not store them
internally. The resulting array can be rendered via a ModelBatch
.getRenderables
in interface RenderableProvider
renderables
- the output arraypool
- the pool to obtain Renderables frompublic Material getMaterial()
public Matrix4 getWorldTransform()
public void dispose()
Disposable
dispose
in interface Disposable
Copyright © 2016. All rights reserved.