Class FilamentAsset
- java.lang.Object
-
- com.google.android.filament.gltfio.FilamentAsset
-
public class FilamentAsset extends java.lang.ObjectOwns a bundle of Filament objects that have been created byAssetLoader.For usage instructions, see the documentation for
AssetLoader.This class owns a hierarchy of entities that have been loaded from a glTF asset. Every entity has a
TransformManagercomponent, and some entities also haveNameComponentManagerand/orRenderableManagercomponents.In addition to the aforementioned entities, an asset has strong ownership over a list of
VertexBuffer,IndexBuffer,MaterialInstance, andTexture.Clients can use
ResourceLoaderto create textures, compute tangent quaternions, and upload data into vertex buffers and index buffers.- See Also:
ResourceLoader,Animator,AssetLoader
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyMaterialVariant(int variantIndex)Applies the given material variant to all primitives that it affects.AnimatorgetAnimator()Retrieves theAnimatorinterface for this asset.com.google.android.filament.BoxgetBoundingBox()Gets the bounding box computed from the supplied min / max values in glTF accessors.int[]getCameraEntities()Gets only the entities that have camera components.int[]getEntities()Gets the list of entities, one for each glTF node.int[]getEntitiesByName(java.lang.String name)Gets a list of entities with the given name.int[]getEntitiesByPrefix(java.lang.String prefix)Gets a list of entities whose names start with the given prefix.java.lang.StringgetExtras(int entity)Gets the glTF extras string for the asset or a specific node.intgetFirstEntityByName(java.lang.String name)Returns the first entity with the given name, or 0 if none exist.int[]getLightEntities()Gets only the entities that have light components.com.google.android.filament.MaterialInstance[]getMaterialInstances()java.lang.String[]getMaterialVariantNames()Returns the names of all material variants.java.lang.String[]getMorphTargetNames(int entity)Gets the names of all morph targets in the given entity.java.lang.StringgetName(int entity)Gets theNameComponentManagerlabel for the given entity, if it exists.java.lang.String[]getResourceUris()Gets resource URIs for all externally-referenced buffers.intgetRoot()Gets the transform root for the asset, which has no matching glTF node.intpopRenderable()Pops a ready renderable off the queue, or returns 0 if no renderables have become ready.intpopRenderables(int[] entities)Pops one or more renderables off the queue, or returns the available number.voidreleaseSourceData()Reclaims CPU-side memory for URI strings, binding lists, and raw animation data.
-
-
-
Method Detail
-
getRoot
public int getRoot()
Gets the transform root for the asset, which has no matching glTF node.
-
popRenderable
public int popRenderable()
Pops a ready renderable off the queue, or returns 0 if no renderables have become ready. NOTE: To determine the progress percentage or completion status, please use ResourceLoader#asyncGetLoadProgress. This helper method allows clients to progressively add renderables to the scene as textures gradually become ready through asynchronous loading. See also ResourceLoader#asyncBeginLoad.
-
popRenderables
public int popRenderables(@Nullable int[] entities)Pops one or more renderables off the queue, or returns the available number. Returns the number of entities written into the given array. If the given array is null, returns the number of available renderables.
-
getEntities
@NonNull public int[] getEntities()
Gets the list of entities, one for each glTF node.All of these have a transform component. Some of the returned entities may also have a renderable or light component.
-
getLightEntities
@NonNull public int[] getLightEntities()
Gets only the entities that have light components.
-
getCameraEntities
@NonNull public int[] getCameraEntities()
Gets only the entities that have camera components.Note about aspect ratios:
gltfio always uses an aspect ratio of 1.0 when setting the projection matrix for perspective cameras. gltfio then sets the camera's scaling matrix with the aspect ratio specified in the glTF file (if present).
The camera's scaling matrix allows clients to adjust the aspect ratio independently from the camera's projection.- See Also:
Camera.setScaling(double, double)
-
getFirstEntityByName
public int getFirstEntityByName(java.lang.String name)
Returns the first entity with the given name, or 0 if none exist.
-
getEntitiesByName
@NonNull public int[] getEntitiesByName(java.lang.String name)
Gets a list of entities with the given name.
-
getEntitiesByPrefix
@NonNull public int[] getEntitiesByPrefix(java.lang.String prefix)
Gets a list of entities whose names start with the given prefix.
-
getMaterialInstances
@NonNull public com.google.android.filament.MaterialInstance[] getMaterialInstances()
-
getBoundingBox
@NonNull public com.google.android.filament.Box getBoundingBox()
Gets the bounding box computed from the supplied min / max values in glTF accessors.
-
getName
public java.lang.String getName(int entity)
Gets theNameComponentManagerlabel for the given entity, if it exists.
-
getExtras
@Nullable public java.lang.String getExtras(int entity)
Gets the glTF extras string for the asset or a specific node.- Parameters:
entity- the entity corresponding to the glTF node, or 0 to get the asset-level string.- Returns:
- the requested extras string, or null if it does not exist.
-
getAnimator
@NonNull public Animator getAnimator()
Retrieves theAnimatorinterface for this asset.When calling this for the first time, this must be called after
ResourceLoader.loadResources(com.google.android.filament.gltfio.FilamentAsset)orResourceLoader.asyncBeginLoad(com.google.android.filament.gltfio.FilamentAsset). When the asset is destroyed, its animator becomes invalid.
-
getMorphTargetNames
@NonNull public java.lang.String[] getMorphTargetNames(int entity)
Gets the names of all morph targets in the given entity.
-
getResourceUris
@NonNull public java.lang.String[] getResourceUris()
Gets resource URIs for all externally-referenced buffers.
-
getMaterialVariantNames
@NonNull public java.lang.String[] getMaterialVariantNames()
Returns the names of all material variants.
-
applyMaterialVariant
public void applyMaterialVariant(@IntRange(from=0L) int variantIndex)Applies the given material variant to all primitives that it affects. This is efficient because it merely swaps around persistent MaterialInstances. If you change a material parameter while a certain variant is active, the updated value will be remembered after you re-apply that variant. If the asset is instanced, this affects all instances in the same way. To set the variant on an individual instance, use FilamentInstance#applyMaterialVariant. Ignored if variantIndex is out of bounds.
-
releaseSourceData
public void releaseSourceData()
Reclaims CPU-side memory for URI strings, binding lists, and raw animation data. This should only be called after ResourceLoader#loadResources() or ResourceLoader#asyncBeginLoad(). If this is an instanced asset, this prevents creation of new instances.
-
-