Interface CloneableSmartAsset

All Superinterfaces:
Cloneable
All Known Implementing Classes:
ArmatureDebugger, ArmatureNode, AssetLinkNode, AudioNode, BatchNode, BitmapText, CameraNode, Geometry, GeometryGroupNode, InstancedGeometry, InstancedNode, LightNode, Material, Node, ParticleEmitter, Picture, SimpleBatchNode, SkeletonDebugger, Spatial, StatsView, TerrainGrid, TerrainPatch, TerrainQuad, Texture, Texture2D, Texture3D, TextureArray, TextureCubeMap

public interface CloneableSmartAsset extends Cloneable
Implementing the CloneableSmartAsset interface allows use of cloneable smart asset management.

Smart asset management requires cooperation from the AssetKey. In particular, the AssetKey should return WeakRefCloneAssetCache in its AssetKey.getCacheType() method. Also smart assets MUST create a clone of the asset and cannot return the same reference, e.g. createClone(someAsset) != someAsset.

If the AssetManager.loadAsset(com.jme3.asset.AssetKey) method is called twice with the same asset key (equals() wise, not necessarily reference wise) then both assets will have the same asset key set (reference wise) via AssetKey(), then this asset key is used to track all instances of that asset. Once all clones of the asset are garbage collected, the shared asset key becomes unreachable and at that point it is removed from the smart asset cache.

  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a clone of the asset.
    Returns the asset key that is used to track this asset for garbage collection.
    void
    Assigns the specified AssetKey to the asset.
  • Method Details

    • clone

      Creates a clone of the asset. Please see Object.clone() for more info on how this method should be implemented.
      Returns:
      A clone of this asset. The cloned asset cannot reference equal this asset.
    • setKey

      void setKey(AssetKey key)
      Assigns the specified AssetKey to the asset. This is invoked by the AssetManager. Only clones of the asset have non-null keys. The original copy that was loaded has no key assigned. Only the clones are tracked for garbage collection.
      Parameters:
      key - The AssetKey to assign
    • getKey

      AssetKey getKey()
      Returns the asset key that is used to track this asset for garbage collection.
      Returns:
      the asset key that is used to track this asset for garbage collection.