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
    Modifier and Type
    Class
    Description
    static class 
    The definable parameters for an Model.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ObjParser
    A parser for reading the OBJ file
    protected com.badlogic.gdx.assets.loaders.FileHandleResolver
    A reference to the file handle resolver (inaccessible in parent class)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new ObjModelLoader with an internal file resolver
    ObjModelLoader(com.badlogic.gdx.assets.loaders.FileHandleResolver resolver)
    Creates a new ObjModelLoader with the given file resolver
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    protected Model
    Returns the Model 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • resolver

      protected com.badlogic.gdx.assets.loaders.FileHandleResolver resolver
      A reference to the file handle resolver (inaccessible in parent class)
    • parser

      protected ObjParser 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 class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,ObjModelLoader.ModelParameters>
      Parameters:
      manager - The asset manager
      fileName - The name of the asset to load
      file - The resolved file to load
      params - The parameters to use for loading the asset
    • getLoadedLibrary

      protected Model getLoadedLibrary()
      Returns the Model 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 class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,ObjModelLoader.ModelParameters>
      Parameters:
      manager - The asset manager
      fileName - The name of the asset to load
      file - The resolved file to load
      params - 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 class com.badlogic.gdx.assets.loaders.AssetLoader<Model,ObjModelLoader.ModelParameters>
      Parameters:
      fileName - The name of the asset to load
      file - The resolved file to load
      params - parameters for loading the asset
      Returns:
      the other assets this asset requires to be loaded first.