Class RenderableInstance
- java.lang.Object
-
- com.google.ar.sceneform.rendering.RenderableInstance
-
- All Implemented Interfaces:
AnimatableModel
public class RenderableInstance extends java.lang.Object implements AnimatableModel
Controls how aRenderable
is displayed. There can be multiple RenderableInstances displaying a single Renderable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RenderableInstance.SkinningModifier
Interface for modifying the bone transforms for this specific RenderableInstance.
-
Constructor Summary
Constructors Constructor Description RenderableInstance(TransformProvider transformProvider, Renderable renderable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
applyAnimationChange(ModelAnimation animation)
Occurs when aModelAnimation
has received any property changed.void
attachToRenderer(Renderer renderer)
void
destroy()
Detach and destroy the instancevoid
detachFromRenderer()
ModelAnimation
getAnimation(int animationIndex)
Get the associatedModelAnimation
at the given index or throw anIndexOutOfBoundsException
.int
getAnimationCount()
Returns the number ofModelAnimation
definitions in the model.int
getEntity()
com.google.android.filament.gltfio.FilamentAsset
getFilamentAsset()
Material
getMaterial()
Returns the material bound to the first submesh.Material
getMaterial(int index)
Returns the material bound to the specified index.Material
getMaterial(java.lang.String name)
Returns the material bound to the specified name.java.lang.String
getMaterialName(int index)
Returns the name associated with the specified index.int
getMaterialsCount()
Returns the number of materials.Matrix
getRelativeTransform()
Returns the transform of this renderable relative to it's node.Matrix
getRelativeTransformInverse()
Returns the inverse transform of this renderable relative to it's node.Renderable
getRenderable()
Get theRenderable
to display for thisRenderableInstance
.int
getRenderedEntity()
int
getRenderPriority()
Get the render priority that controls the order of rendering.Matrix
getWorldModelMatrix()
boolean
isShadowCaster()
Returns true if configured to cast shadows on other renderables.boolean
isShadowReceiver()
Returns true if configured to receive shadows cast by other renderables.void
prepareForDraw()
void
setMaterial(int entityIndex, int primitiveIndex, Material material)
Sets the material bound to the specified index and entityIndexvoid
setMaterial(int primitiveIndex, Material material)
Sets the material bound to the specified index.void
setMaterial(Material material)
Sets the material bound to the first index.void
setRenderPriority(int renderPriority)
Set the render priority to control the order of rendering.void
setShadowCaster(boolean isShadowCaster)
Sets whether the renderable casts shadow on other renderables in the scene.void
setShadowReceiver(boolean isShadowReceiver)
Sets whether the renderable receives shadows cast by other renderables in the scene.void
setSkinningModifier(RenderableInstance.SkinningModifier skinningModifier)
boolean
updateAnimations(boolean force)
Apply animations changesif fore==true
or the animation has dirty values.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.ar.sceneform.animation.AnimatableModel
animate, animate, animate, animate, getAnimation, getAnimationIndex, getAnimationName, getAnimationNames, getAnimationOrThrow, hasAnimations, onModelAnimationChanged, setAnimationsFramePosition, setAnimationsTimePosition
-
-
-
-
Constructor Detail
-
RenderableInstance
public RenderableInstance(TransformProvider transformProvider, Renderable renderable)
-
-
Method Detail
-
getFilamentAsset
@Nullable public com.google.android.filament.gltfio.FilamentAsset getFilamentAsset()
-
getRenderable
public Renderable getRenderable()
Get theRenderable
to display for thisRenderableInstance
.- Returns:
Renderable
asset, usually a 3D model.
-
getEntity
public int getEntity()
-
getRenderedEntity
public int getRenderedEntity()
-
getRenderPriority
public int getRenderPriority()
Get the render priority that controls the order of rendering. The priority is between a range of 0 (rendered first) and 7 (rendered last). The default value is 4.
-
setRenderPriority
public void setRenderPriority(@IntRange(from=0L,to=7L) int renderPriority)
Set the render priority to control the order of rendering. The priority is between a range of 0 (rendered first) and 7 (rendered last). The default value is 4.
-
isShadowCaster
public boolean isShadowCaster()
Returns true if configured to cast shadows on other renderables.
-
setShadowCaster
public void setShadowCaster(boolean isShadowCaster)
Sets whether the renderable casts shadow on other renderables in the scene.
-
isShadowReceiver
public boolean isShadowReceiver()
Returns true if configured to receive shadows cast by other renderables.
-
setShadowReceiver
public void setShadowReceiver(boolean isShadowReceiver)
Sets whether the renderable receives shadows cast by other renderables in the scene.
-
getMaterial
public Material getMaterial()
Returns the material bound to the first submesh.
-
getMaterialsCount
public int getMaterialsCount()
Returns the number of materials.
-
getMaterial
public Material getMaterial(int index)
Returns the material bound to the specified index.
-
getMaterial
public Material getMaterial(java.lang.String name)
Returns the material bound to the specified name.
-
setMaterial
public void setMaterial(Material material)
Sets the material bound to the first index.
-
setMaterial
public void setMaterial(@IntRange(from=0L) int primitiveIndex, Material material)
Sets the material bound to the specified index.
-
setMaterial
public void setMaterial(int entityIndex, @IntRange(from=0L) int primitiveIndex, Material material)
Sets the material bound to the specified index and entityIndex
-
getMaterialName
public java.lang.String getMaterialName(int index)
Returns the name associated with the specified index.
-
getWorldModelMatrix
public Matrix getWorldModelMatrix()
-
setSkinningModifier
public void setSkinningModifier(@Nullable RenderableInstance.SkinningModifier skinningModifier)
-
getAnimation
public ModelAnimation getAnimation(int animationIndex)
Get the associatedModelAnimation
at the given index or throw anIndexOutOfBoundsException
.- Specified by:
getAnimation
in interfaceAnimatableModel
- Parameters:
animationIndex
- Zero-based index for the animation of interest.
-
getAnimationCount
public int getAnimationCount()
Returns the number ofModelAnimation
definitions in the model.- Specified by:
getAnimationCount
in interfaceAnimatableModel
-
applyAnimationChange
public boolean applyAnimationChange(ModelAnimation animation)
Description copied from interface:AnimatableModel
Occurs when aModelAnimation
has received any property changed.
Depending on the returned value, theModelAnimation
will set his isDirty to false or not.
You can choose between applying changes on theObjectAnimator
Choreographer.FrameCallback
or use your ownChoreographer
to handle an update/render update hierarchy.
Time position should be applied inside a globalChoreographer
frame callback to ensure that the transformations are applied in a hierarchical order.- Specified by:
applyAnimationChange
in interfaceAnimatableModel
- Returns:
- true is the changes have been applied/handled
-
prepareForDraw
public void prepareForDraw()
-
attachToRenderer
public void attachToRenderer(Renderer renderer)
-
detachFromRenderer
public void detachFromRenderer()
-
destroy
public void destroy()
Detach and destroy the instance
-
getRelativeTransform
@Nullable public Matrix getRelativeTransform()
Returns the transform of this renderable relative to it's node. This will be non-null if the .sfa file includes a scale other than 1 or has recentering turned on.
-
getRelativeTransformInverse
@Nullable public Matrix getRelativeTransformInverse()
Returns the inverse transform of this renderable relative to it's node. This will be non-null if the .sfa file includes a scale other than 1 or has recentering turned on.
-
updateAnimations
public boolean updateAnimations(boolean force)
Apply animations changesif fore==true
or the animation has dirty values.- Parameters:
force
- Update even if the animation time position didn't changed.- Returns:
- true if any animation update has been made.
-
-