Package com.google.android.filament
Class RenderableManager
- java.lang.Object
-
- com.google.android.filament.RenderableManager
-
public class RenderableManager extends java.lang.ObjectFactory and manager for renderables, which are entities that can be drawn.Renderables are bundles of primitives, each of which has its own geometry and material. All primitives in a particular renderable share a set of rendering attributes, such as whether they cast shadows or use vertex skinning. Kotlin usage example:
val entity = EntityManager.get().create() RenderableManager.Builder(1) .boundingBox(Box(0.0f, 0.0f, 0.0f, 9000.0f, 9000.0f, 9000.0f)) .geometry(0, RenderableManager.PrimitiveType.TRIANGLES, vb, ib) .material(0, material) .build(engine, entity) scene.addEntity(renderable)To modify the state of an existing renderable, clients should first use RenderableManager to get a temporary handle called an instance. The instance can then be used to get or set the renderable's state. Please note that instances are ephemeral; clients should store entities, not instances.
- For details about constructing renderables, see
RenderableManager.Builder. - To associate a 4x4 transform with an entity, see
TransformManager.
- For details about constructing renderables, see
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRenderableManager.BuilderAdds renderable components to entities using a builder pattern.static classRenderableManager.PrimitiveType
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy(int entity)Destroys the renderable component in the given entity.BoxgetAxisAlignedBoundingBox(int i, Box out)Gets the bounding box used for frustum culling.java.util.Set<VertexBuffer.VertexAttribute>getEnabledAttributesAt(int i, int primitiveIndex)Retrieves the set of enabled attribute slots in the given primitive's VertexBuffer.intgetInstance(int entity)Gets a temporary handle that can be used to access the renderable state.booleangetLightChannel(int i, int channel)Returns whether a light channel is enabled on a specified renderable.MaterialInstancegetMaterialInstanceAt(int i, int primitiveIndex)Creates a MaterialInstance Java wrapper object for a particular material instance.intgetMorphTargetCount(int i)Gets the morph target count on a renderable.longgetNativeObject()intgetPrimitiveCount(int i)Gets the immutable number of primitives in the given renderable.booleanhasComponent(int entity)Checks if the given entity already has a renderable component.booleanisShadowCaster(int i)Checks if the renderable can cast shadows.booleanisShadowReceiver(int i)Checks if the renderable can receive shadows.voidsetAxisAlignedBoundingBox(int i, Box aabb)Changes the bounding box used for frustum culling.voidsetBlendOrderAt(int instance, int primitiveIndex, int blendOrder)Changes the ordering index for blended primitives that all live at the same Z value.voidsetBonesAsMatrices(int i, java.nio.Buffer matrices, int boneCount, int offset)Sets the transforms associated with each bone of a Renderable.voidsetBonesAsQuaternions(int i, java.nio.Buffer quaternions, int boneCount, int offset)Sets the transforms associated with each bone of a Renderable.voidsetCastShadows(int i, boolean enabled)Changes whether or not the renderable casts shadows.voidsetCulling(int i, boolean enabled)Changes whether or not frustum culling is on.voidsetGeometryAt(int i, int primitiveIndex, RenderableManager.PrimitiveType type, int offset, int count)Changes the geometry for the given primitive.voidsetGeometryAt(int i, int primitiveIndex, RenderableManager.PrimitiveType type, VertexBuffer vertices, IndexBuffer indices)Changes the geometry for the given primitive.voidsetGeometryAt(int i, int primitiveIndex, RenderableManager.PrimitiveType type, VertexBuffer vertices, IndexBuffer indices, int offset, int count)Changes the geometry for the given primitive.voidsetLayerMask(int i, int select, int value)Changes the visibility bits.voidsetLightChannel(int i, int channel, boolean enable)Enables or disables a light channel.voidsetMaterialInstanceAt(int i, int primitiveIndex, MaterialInstance materialInstance)Changes the material instance binding for the given primitive.voidsetMorphTargetBufferAt(int i, int level, int primitiveIndex, MorphTargetBuffer morphTargetBuffer)Utility method to change morph target buffer for the given primitive.voidsetMorphTargetBufferAt(int i, int level, int primitiveIndex, MorphTargetBuffer morphTargetBuffer, int offset, int count)Changes the morph target buffer for the given primitive.voidsetMorphWeights(int i, float[] weights, int offset)Updates the vertex morphing weights on a renderable, all zeroes by default.voidsetPriority(int i, int priority)Changes the coarse-level draw ordering.voidsetReceiveShadows(int i, boolean enabled)Changes whether or not the renderable can receive shadows.voidsetScreenSpaceContactShadows(int i, boolean enabled)Changes whether or not the renderable can use screen-space contact shadows.voidsetSkinningBuffer(int i, SkinningBuffer skinningBuffer, int count, int offset)Associates aSkinningBufferto a renderable instance
-
-
-
Method Detail
-
hasComponent
public boolean hasComponent(int entity)
Checks if the given entity already has a renderable component.
-
getInstance
public int getInstance(int entity)
Gets a temporary handle that can be used to access the renderable state.
-
destroy
public void destroy(int entity)
Destroys the renderable component in the given entity.
-
setSkinningBuffer
public void setSkinningBuffer(int i, @NonNull SkinningBuffer skinningBuffer, int count, int offset)Associates aSkinningBufferto a renderable instance- Parameters:
i- Instance of the RenderableskinningBuffer-SkinningBufferto usecount- Numbers of bones to setoffset- Offset in theSkinningBuffer
-
setBonesAsMatrices
public void setBonesAsMatrices(int i, @NonNull java.nio.Buffer matrices, @IntRange(from=0L,to=255L) int boneCount, @IntRange(from=0L) int offset)Sets the transforms associated with each bone of a Renderable.- Parameters:
i- Instance of the Renderablematrices- A FloatBuffer containing boneCount 4x4 packed matrices (i.e. 16 floats each matrix and no gap between matrices)boneCount- Number of bones to setoffset- Index of the first bone to set
-
setBonesAsQuaternions
public void setBonesAsQuaternions(int i, @NonNull java.nio.Buffer quaternions, @IntRange(from=0L,to=255L) int boneCount, @IntRange(from=0L) int offset)Sets the transforms associated with each bone of a Renderable.- Parameters:
i- Instance of the Renderablequaternions- A FloatBuffer containing boneCount transforms. Each transform consists of 8 float. float 0 to 3 encode a unit quaternion w+ix+jy+kz stored as x,y,z,w. float 4 to 7 encode a translation stored as x,y,z,1boneCount- Number of bones to setoffset- Index of the first bone to set
-
setMorphWeights
public void setMorphWeights(int i, @NonNull float[] weights, @IntRange(from=0L) int offset)Updates the vertex morphing weights on a renderable, all zeroes by default.The renderable must be built with morphing enabled. In legacy morphing mode, only the first 4 weights are considered.
- See Also:
RenderableManager.Builder.morphing(int)
-
setMorphTargetBufferAt
public void setMorphTargetBufferAt(int i, @IntRange(from=0L) int level, @IntRange(from=0L) int primitiveIndex, @NonNull MorphTargetBuffer morphTargetBuffer, @IntRange(from=0L) int offset, @IntRange(from=0L) int count)Changes the morph target buffer for the given primitive.The renderable must be built with morphing enabled.
- See Also:
RenderableManager.Builder.morphing(int)
-
setMorphTargetBufferAt
public void setMorphTargetBufferAt(int i, @IntRange(from=0L) int level, @IntRange(from=0L) int primitiveIndex, @NonNull MorphTargetBuffer morphTargetBuffer)Utility method to change morph target buffer for the given primitive. For details, see thesetMorphTargetBufferAt(int, int, int, com.google.android.filament.MorphTargetBuffer, int, int).
-
getMorphTargetCount
@IntRange(from=0L) public int getMorphTargetCount(int i)
Gets the morph target count on a renderable.
-
setAxisAlignedBoundingBox
public void setAxisAlignedBoundingBox(int i, @NonNull Box aabb)Changes the bounding box used for frustum culling.
-
setLayerMask
public void setLayerMask(int i, @IntRange(from=0L,to=255L) int select, @IntRange(from=0L,to=255L) int value)Changes the visibility bits.
-
setPriority
public void setPriority(int i, @IntRange(from=0L,to=7L) int priority)Changes the coarse-level draw ordering.- See Also:
RenderableManager.Builder.priority(int)
-
setCulling
public void setCulling(int i, boolean enabled)Changes whether or not frustum culling is on.
-
setLightChannel
public void setLightChannel(int i, @IntRange(from=0L,to=7L) int channel, boolean enable)Enables or disables a light channel. Light channel 0 is enabled by default.- Parameters:
i- Instance of the component obtained from getInstance().channel- Light channel to setenable- true to enable, false to disable- See Also:
RenderableManager.Builder.lightChannel(int, boolean)
-
getLightChannel
public boolean getLightChannel(int i, @IntRange(from=0L,to=7L) int channel)Returns whether a light channel is enabled on a specified renderable.- Parameters:
i- Instance of the component obtained from getInstance().channel- Light channel to query- Returns:
- true if the light channel is enabled, false otherwise
-
setCastShadows
public void setCastShadows(int i, boolean enabled)Changes whether or not the renderable casts shadows.
-
setReceiveShadows
public void setReceiveShadows(int i, boolean enabled)Changes whether or not the renderable can receive shadows.
-
setScreenSpaceContactShadows
public void setScreenSpaceContactShadows(int i, boolean enabled)Changes whether or not the renderable can use screen-space contact shadows.
-
isShadowCaster
public boolean isShadowCaster(int i)
Checks if the renderable can cast shadows.
-
isShadowReceiver
public boolean isShadowReceiver(int i)
Checks if the renderable can receive shadows.
-
getAxisAlignedBoundingBox
@NonNull public Box getAxisAlignedBoundingBox(int i, @Nullable Box out)
Gets the bounding box used for frustum culling.
-
getPrimitiveCount
@IntRange(from=0L) public int getPrimitiveCount(int i)
Gets the immutable number of primitives in the given renderable.
-
setMaterialInstanceAt
public void setMaterialInstanceAt(int i, @IntRange(from=0L) int primitiveIndex, @NonNull MaterialInstance materialInstance)Changes the material instance binding for the given primitive.
-
getMaterialInstanceAt
@NonNull public MaterialInstance getMaterialInstanceAt(int i, @IntRange(from=0L) int primitiveIndex)
Creates a MaterialInstance Java wrapper object for a particular material instance.
-
setGeometryAt
public void setGeometryAt(int i, @IntRange(from=0L) int primitiveIndex, @NonNull RenderableManager.PrimitiveType type, @NonNull VertexBuffer vertices, @NonNull IndexBuffer indices, @IntRange(from=0L) int offset, @IntRange(from=0L) int count)Changes the geometry for the given primitive.- See Also:
Builder.geometry
-
setGeometryAt
public void setGeometryAt(int i, @IntRange(from=0L) int primitiveIndex, @NonNull RenderableManager.PrimitiveType type, @NonNull VertexBuffer vertices, @NonNull IndexBuffer indices)Changes the geometry for the given primitive.- See Also:
Builder.geometry
-
setGeometryAt
public void setGeometryAt(int i, @IntRange(from=0L) int primitiveIndex, @NonNull RenderableManager.PrimitiveType type, @IntRange(from=0L) int offset, @IntRange(from=0L) int count)Changes the geometry for the given primitive.- See Also:
Builder.geometry
-
setBlendOrderAt
public void setBlendOrderAt(int instance, @IntRange(from=0L) int primitiveIndex, @IntRange(from=0L,to=65535L) int blendOrder)Changes the ordering index for blended primitives that all live at the same Z value.- Parameters:
instance- the renderable of interestprimitiveIndex- the primitive of interestblendOrder- draw order number (0 by default). Only the lowest 15 bits are used.- See Also:
RenderableManager.Builder.blendOrder(int, int)
-
getEnabledAttributesAt
public java.util.Set<VertexBuffer.VertexAttribute> getEnabledAttributesAt(int i, @IntRange(from=0L) int primitiveIndex)
Retrieves the set of enabled attribute slots in the given primitive's VertexBuffer.
-
getNativeObject
public long getNativeObject()
-
-