Package com.jme3.asset
Class DesktopAssetManager
java.lang.Object
com.jme3.asset.DesktopAssetManager
- All Implemented Interfaces:
- AssetManager
AssetManager is the primary method for managing and loading
 assets inside jME.- 
Constructor SummaryConstructorsConstructorDescriptionDesktopAssetManager(boolean usePlatformConfig) DesktopAssetManager(URL configFile) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAssetEventListener(AssetEventListener listener) Add anAssetEventListenerto receive events from thisAssetManager.voidaddClassLoader(ClassLoader loader) Adds aClassLoaderthat is used to loadclassesthat are needed for finding and loading Assets.<T> voidaddToCache(AssetKey<T> key, T asset) Inject an asset into the asset cache.voidRemoves all asset event listeners.voidClears the asset cache.<T> booleandeleteFromCache(AssetKey<T> key) Delete an asset from the asset cache.Retrieve the list of registered ClassLoaders that are used for loadingclassesfrom asset files.<T> TgetFromCache(AssetKey<T> key) Retrieve an asset from the asset cache.getShaderGenerator(EnumSet<Caps> caps) Returns the shaderGenerator responsible for generating the shaders<T> TLoad an asset from a key, the asset will be located by one of theAssetLocatorimplementations provided in theAssetManager.registerLocator(java.lang.String, java.lang.Class)call.Load an asset by name, calling this method is the same as callingloadAsset(new AssetKey(name)).<T> TloadAssetFromStream(AssetKey<T> key, InputStream inputStream) Load an asset from anInputStream.Load audio file, supported types are WAV or OGG.Load audio file, supported types are WAV or OGG.loadFilter(FilterKey key) Loads a filter *.j3f file with a FilterKey.loadFilter(String name) Loads a filter *.j3f file with a FilterKey.Load a font file.protected <T> TloadLocatedAsset(AssetKey<T> key, AssetInfo info, AssetProcessor proc, AssetCache cache) Loads an asset that has already been located.loadMaterial(String name) Load a material instance (J3M) file.Loads a 3D model with a ModelKey.Loads a 3D model.loadTexture(TextureKey key) Loads texture file, supported types are BMP, JPG, PNG, GIF, TGA, DDS, PFM, and HDR.loadTexture(String name) Loads texture file, supported types are BMP, JPG, PNG, GIF, TGA, DDS, PFM, and HDR.locateAsset(AssetKey<?> key) Manually locates an asset with the givenAssetKey.protected <T> TregisterAndCloneSmartAsset(AssetKey<T> key, T obj, AssetProcessor proc, AssetCache cache) Clones the asset using the given processor and registers the clone with the cache.voidregisterLoader(Class<? extends AssetLoader> loader, String... extensions) Register anAssetLoaderby using a class object.voidregisterLoader(String clsName, String... extensions) voidregisterLocator(String rootPath, Class<? extends AssetLocator> locatorClass) Registers the given locator class for locating assets with thisAssetManager.voidregisterLocator(String rootPath, String clsName) voidremoveAssetEventListener(AssetEventListener listener) Remove anAssetEventListenerfrom receiving events from thisAssetManagervoidremoveClassLoader(ClassLoader loader) Remove aClassLoaderfrom the list of registered ClassLoadersvoidsetAssetEventListener(AssetEventListener listener) voidsetShaderGenerator(ShaderGenerator shaderGenerator) Sets the shaderGenerator to generate shaders based on shaderNodes.voidunregisterLoader(Class<? extends AssetLoader> loaderClass) Unregister aAssetLoaderfrom loading its assigned extensions.voidunregisterLocator(String rootPath, Class<? extends AssetLocator> clazz) Unregisters the given locator class.
- 
Constructor Details- 
DesktopAssetManagerpublic DesktopAssetManager()
- 
DesktopAssetManagerpublic DesktopAssetManager(boolean usePlatformConfig) 
- 
DesktopAssetManager
 
- 
- 
Method Details- 
addClassLoaderDescription copied from interface:AssetManagerAdds aClassLoaderthat is used to loadclassesthat are needed for finding and loading Assets. This does not allow loading assets from that classpath, use registerLocator for that.- Specified by:
- addClassLoaderin interface- AssetManager
- Parameters:
- loader- A ClassLoader that Classes in asset files can be loaded from.
 
- 
removeClassLoaderDescription copied from interface:AssetManagerRemove aClassLoaderfrom the list of registered ClassLoaders- Specified by:
- removeClassLoaderin interface- AssetManager
- Parameters:
- loader- the ClassLoader to be removed
 
- 
getClassLoadersDescription copied from interface:AssetManagerRetrieve the list of registered ClassLoaders that are used for loadingclassesfrom asset files.- Specified by:
- getClassLoadersin interface- AssetManager
- Returns:
- an unmodifiable list
 
- 
addAssetEventListenerDescription copied from interface:AssetManagerAdd anAssetEventListenerto receive events from thisAssetManager.- Specified by:
- addAssetEventListenerin interface- AssetManager
- Parameters:
- listener- The asset event listener to add
 
- 
removeAssetEventListenerDescription copied from interface:AssetManagerRemove anAssetEventListenerfrom receiving events from thisAssetManager- Specified by:
- removeAssetEventListenerin interface- AssetManager
- Parameters:
- listener- The asset event listener to remove
 
- 
clearAssetEventListenerspublic void clearAssetEventListeners()Description copied from interface:AssetManagerRemoves all asset event listeners.- Specified by:
- clearAssetEventListenersin interface- AssetManager
- See Also:
 
- 
setAssetEventListener
- 
registerLoaderDescription copied from interface:AssetManagerRegister anAssetLoaderby using a class object.- Specified by:
- registerLoaderin interface- AssetManager
- Parameters:
- loader- The loader class to register.
- extensions- Which extensions this loader is responsible for loading, if there are already other loaders registered for that extension, they will be overridden - there should only be one loader for each extension.
 
- 
registerLoader
- 
unregisterLoaderDescription copied from interface:AssetManagerUnregister aAssetLoaderfrom loading its assigned extensions. This undoes the effect of callingAssetManager.registerLoader(java.lang.Class, java.lang.String[]).- Specified by:
- unregisterLoaderin interface- AssetManager
- Parameters:
- loaderClass- The loader class to unregister.
- See Also:
 
- 
registerLocatorDescription copied from interface:AssetManagerRegisters the given locator class for locating assets with thisAssetManager.AssetLocators are invoked in the order they were registered, to locate the asset by theAssetKey. Once anAssetLocatorreturns a non-null AssetInfo, it is sent to theAssetLoaderto load the asset. Once a locator is registered, it can be removed viaAssetManager.unregisterLocator(java.lang.String, java.lang.Class).- Specified by:
- registerLocatorin interface- AssetManager
- Parameters:
- rootPath- Specifies the root path from which to locate assets for the given- AssetLocator. The purpose of this parameter depends on the type of the- AssetLocator.
- locatorClass- The class type of the- AssetLocatorto register.
- See Also:
 
- 
registerLocator
- 
unregisterLocatorDescription copied from interface:AssetManagerUnregisters the given locator class. This essentially undoes the operation done byAssetManager.registerLocator(java.lang.String, java.lang.Class).- Specified by:
- unregisterLocatorin interface- AssetManager
- Parameters:
- rootPath- Should be the same as the root path specified in- AssetManager.registerLocator(java.lang.String, java.lang.Class).
- clazz- The locator class to unregister
- See Also:
 
- 
locateAssetDescription copied from interface:AssetManagerManually locates an asset with the givenAssetKey. This method should be used for debugging or internal uses.
 The call will attempt to locate the asset by invoking theAssetLocatorthat are registered with thisAssetManager, in the same way that theAssetManager.loadAsset(com.jme3.asset.AssetKey)method locates assets.- Specified by:
- locateAssetin interface- AssetManager
- Parameters:
- key- The- AssetKeyto locate.
- Returns:
- The AssetInfoobject returned from theAssetLocatorthat located the asset, or null if the asset cannot be located.
 
- 
getFromCacheDescription copied from interface:AssetManagerRetrieve an asset from the asset cache. NOTE: Do not modify the returned asset! It is the same reference as what is stored in the cache, therefore any modifications to it will leak onto assets loaded from the same key in the future.- Specified by:
- getFromCachein interface- AssetManager
- Type Parameters:
- T- The object type that will be retrieved from the AssetKey instance.
- Parameters:
- key- The AssetKey to get from the cache.
- Returns:
- The cached asset, if found. Otherwise, null.
 
- 
addToCacheDescription copied from interface:AssetManagerInject an asset into the asset cache. NOTE: Do not modify the cached asset after storing! It is the same reference as what is stored in the cache, therefore any modifications to it will leak onto assets loaded from the same key in the future.- Specified by:
- addToCachein interface- AssetManager
- Type Parameters:
- T- The object type of the asset.
- Parameters:
- key- The key where the asset shall be stored.
- asset- The asset to inject into the cache.
 
- 
deleteFromCacheDescription copied from interface:AssetManagerDelete an asset from the asset cache.- Specified by:
- deleteFromCachein interface- AssetManager
- Type Parameters:
- T- The object type of the AssetKey instance.
- Parameters:
- key- The asset key to remove from the cache.
- Returns:
- True if the asset key was found in the cache and was removed successfully. False if the asset key was not present in the cache.
 
- 
clearCachepublic void clearCache()Description copied from interface:AssetManagerClears the asset cache.- Specified by:
- clearCachein interface- AssetManager
 
- 
loadLocatedAssetprotected <T> T loadLocatedAsset(AssetKey<T> key, AssetInfo info, AssetProcessor proc, AssetCache cache) Loads an asset that has already been located.- Type Parameters:
- T- The asset type
- Parameters:
- key- The asset key
- info- The AssetInfo from the locator
- proc- AssetProcessor to use, or null to disable processing
- cache- The cache to store the asset in, or null to disable caching
- Returns:
- The loaded asset
- Throws:
- AssetLoadException- If failed to load asset due to exception or other error.
 
- 
registerAndCloneSmartAssetprotected <T> T registerAndCloneSmartAsset(AssetKey<T> key, T obj, AssetProcessor proc, AssetCache cache) Clones the asset using the given processor and registers the clone with the cache.- Type Parameters:
- T- The asset type
- Parameters:
- key- The asset key
- obj- The asset to clone / register, must implement- CloneableSmartAsset.
- proc- The processor which will generate the clone, cannot be null
- cache- The cache to register the clone with, cannot be null.
- Returns:
- The cloned asset, cannot be the same as the given asset since it is a clone.
- Throws:
- IllegalStateException- If asset does not implement- CloneableSmartAsset, if the cache is null, or if the processor did not clone the asset.
 
- 
loadAssetFromStreamDescription copied from interface:AssetManagerLoad an asset from anInputStream. In some cases it may be required to load an asset from memory or arbitrary streams so that registering a custom locator and key type is not necessary.- Specified by:
- loadAssetFromStreamin interface- AssetManager
- Type Parameters:
- T- The object type that will be loaded from the AssetKey instance.
- Parameters:
- key- The AssetKey. Note that the asset will not be cached - following the same behavior as if- AssetKey.getCacheType()returned null.
- inputStream- The input stream from which the asset shall be loaded.
- Returns:
- The loaded asset.
 
- 
loadAssetDescription copied from interface:AssetManagerLoad an asset from a key, the asset will be located by one of theAssetLocatorimplementations provided in theAssetManager.registerLocator(java.lang.String, java.lang.Class)call. If located successfully, it will be loaded via the appropriateAssetLoaderimplementation based on the file's extension, as specified in the callAssetManager.registerLoader(java.lang.Class, java.lang.String[]).- Specified by:
- loadAssetin interface- AssetManager
- Type Parameters:
- T- The object type that will be loaded from the AssetKey instance.
- Parameters:
- key- The AssetKey
- Returns:
- The loaded asset.
 
- 
loadAssetDescription copied from interface:AssetManagerLoad an asset by name, calling this method is the same as callingloadAsset(new AssetKey(name)).- Specified by:
- loadAssetin interface- AssetManager
- Parameters:
- name- The name of the asset to load.
- Returns:
- The loaded asset, or null if failed to be loaded.
- See Also:
 
- 
loadTextureDescription copied from interface:AssetManagerLoads texture file, supported types are BMP, JPG, PNG, GIF, TGA, DDS, PFM, and HDR.- Specified by:
- loadTexturein interface- AssetManager
- Parameters:
- key- The- TextureKeyto use for loading.
- Returns:
- The loaded texture, or null if failed to be loaded.
- See Also:
 
- 
loadMaterialDescription copied from interface:AssetManagerLoad a material instance (J3M) file.- Specified by:
- loadMaterialin interface- AssetManager
- Parameters:
- name- Asset name of the material to load
- Returns:
- The material that was loaded
- See Also:
 
- 
loadTextureDescription copied from interface:AssetManagerLoads texture file, supported types are BMP, JPG, PNG, GIF, TGA, DDS, PFM, and HDR. The texture will be loaded with mip-mapping enabled.- Specified by:
- loadTexturein interface- AssetManager
- Parameters:
- name- The name of the texture to load.
- Returns:
- The texture that was loaded
- See Also:
 
- 
loadAudioDescription copied from interface:AssetManagerLoad audio file, supported types are WAV or OGG.- Specified by:
- loadAudioin interface- AssetManager
- Parameters:
- key- Asset key of the audio file to load
- Returns:
- The audio data loaded
- See Also:
 
- 
loadAudioDescription copied from interface:AssetManagerLoad audio file, supported types are WAV or OGG. The file is loaded without stream-mode.- Specified by:
- loadAudioin interface- AssetManager
- Parameters:
- name- Asset name of the audio file to load
- Returns:
- The audio data loaded
- See Also:
 
- 
loadFontDescription copied from interface:AssetManagerLoad a font file. Font files are in AngelCode text format, and are with the extension "fnt".- Specified by:
- loadFontin interface- AssetManager
- Parameters:
- name- Asset name of the font to load
- Returns:
- The font loaded
- See Also:
 
- 
loadModelDescription copied from interface:AssetManagerLoads a 3D model with a ModelKey. Models can be jME3 object files (J3O), OgreXML (mesh.xml), BLEND, FBX and OBJ files.- Specified by:
- loadModelin interface- AssetManager
- Parameters:
- key- Asset key of the model to load
- Returns:
- The model that was loaded
- See Also:
 
- 
loadModelDescription copied from interface:AssetManagerLoads a 3D model. Models can be jME3 object files (J3O), OgreXML (mesh.xml), BLEND, FBX and OBJ files.- Specified by:
- loadModelin interface- AssetManager
- Parameters:
- name- Asset name of the model to load
- Returns:
- The model that was loaded
- See Also:
 
- 
loadFilterDescription copied from interface:AssetManagerLoads a filter *.j3f file with a FilterKey.- Specified by:
- loadFilterin interface- AssetManager
- Parameters:
- key- Asset key of the filter file to load
- Returns:
- The filter that was loaded
- See Also:
 
- 
loadFilterDescription copied from interface:AssetManagerLoads a filter *.j3f file with a FilterKey.- Specified by:
- loadFilterin interface- AssetManager
- Parameters:
- name- Asset name of the filter file to load
- Returns:
- The filter that was loaded
- See Also:
 
- 
getShaderGeneratorReturns the shaderGenerator responsible for generating the shaders- Specified by:
- getShaderGeneratorin interface- AssetManager
- Parameters:
- caps- a set of required capabilities
- Returns:
- the shaderGenerator
 
- 
setShaderGeneratorSets the shaderGenerator to generate shaders based on shaderNodes.- Specified by:
- setShaderGeneratorin interface- AssetManager
- Parameters:
- shaderGenerator- the shaderGenerator
 
 
-