Package edu.cornell.gdiac.assets
Class ObjModelLoader
java.lang.Object
com.badlogic.gdx.assets.loaders.AssetLoader<T,P>
com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,ObjModelLoader.ModelParameters>
edu.cornell.gdiac.assets.ObjModelLoader
public class ObjModelLoader
extends com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,ObjModelLoader.ModelParameters>
This class is an
AssetLoader
to load Model
assets.
Model assets often have associated materials (MTL files) or textures. Those assets will be loaded implicitly if they are not already loaded via the asset directory. This is handled through the LibGDX dependency API.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ObjModelLoader with an internal file resolverObjModelLoader
(com.badlogic.gdx.assets.loaders.FileHandleResolver resolver) Creates a new ObjModelLoader with the given file resolver -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.utils.Array<com.badlogic.gdx.assets.AssetDescriptor>
getDependencies
(String fileName, com.badlogic.gdx.files.FileHandle file, ObjModelLoader.ModelParameters params) Returns the other assets this asset requires to be loaded first.protected Model
Returns theModel
instance currently loaded by this loader.void
loadAsync
(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, ObjModelLoader.ModelParameters params) Loads the thread-safe part of the asset and injects any dependencies into the AssetManager.loadSync
(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, ObjModelLoader.ModelParameters params) Loads the main thread part of the asset.Methods inherited from class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader
unloadAsync
Methods inherited from class com.badlogic.gdx.assets.loaders.AssetLoader
resolve
-
Field Details
-
resolver
protected com.badlogic.gdx.assets.loaders.FileHandleResolver resolverA reference to the file handle resolver (inaccessible in parent class) -
parser
A parser for reading the OBJ file
-
-
Constructor Details
-
ObjModelLoader
public ObjModelLoader()Creates a new ObjModelLoader with an internal file resolver -
ObjModelLoader
public ObjModelLoader(com.badlogic.gdx.assets.loaders.FileHandleResolver resolver) Creates a new ObjModelLoader with the given file resolver- Parameters:
resolver
- The file resolver
-
-
Method Details
-
loadAsync
public void loadAsync(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, ObjModelLoader.ModelParameters params) Loads the thread-safe part of the asset and injects any dependencies into the AssetManager.This is used to load non-OpenGL parts of the asset that do not require the context of the main thread.
- Specified by:
loadAsync
in classcom.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,
ObjModelLoader.ModelParameters> - Parameters:
manager
- The asset managerfileName
- The name of the asset to loadfile
- The resolved file to loadparams
- The parameters to use for loading the asset
-
getLoadedLibrary
Returns theModel
instance currently loaded by this loader.If nothing has been loaded, this returns
null
.- Returns:
- the
Model
instance currently loaded by this loader.
-
loadSync
public Model loadSync(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, ObjModelLoader.ModelParameters params) Loads the main thread part of the asset.This is used to load OpenGL parts of the asset that require the context of the main thread.
- Specified by:
loadSync
in classcom.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,
ObjModelLoader.ModelParameters> - Parameters:
manager
- The asset managerfileName
- The name of the asset to loadfile
- The resolved file to loadparams
- The parameters to use for loading the asset
-
getDependencies
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.assets.AssetDescriptor> getDependencies(String fileName, com.badlogic.gdx.files.FileHandle file, ObjModelLoader.ModelParameters params) Returns the other assets this asset requires to be loaded first.This method may be called on a thread other than the GL thread. It may return null if there are no dependencies.
- Specified by:
getDependencies
in classcom.badlogic.gdx.assets.loaders.AssetLoader<Model,
ObjModelLoader.ModelParameters> - Parameters:
fileName
- The name of the asset to loadfile
- The resolved file to loadparams
- parameters for loading the asset- Returns:
- the other assets this asset requires to be loaded first.
-