Class ObjLoader
- java.lang.Object
-
- com.badlogic.gdx.assets.loaders.AssetLoader<T,P>
-
- com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<Model,P>
-
- com.badlogic.gdx.assets.loaders.ModelLoader<ObjLoader.ObjLoaderParameters>
-
- com.badlogic.gdx.graphics.g3d.loader.ObjLoader
-
public class ObjLoader extends ModelLoader<ObjLoader.ObjLoaderParameters>
ModelLoader
to load Wavefront OBJ files. Only intended for testing basic models/meshes and educational usage. The Wavefront specification is NOT fully implemented, only a subset of the specification is supported. Especially theMaterial
(Attributes
), e.g. the color or texture applied, might not or not correctly be loaded. ThisModelLoader
can be used to load very basic models without having to convert them to a more suitable format. Therefore it can be used for educational purposes and to quickly test a basic model, but should not be used in production. Instead useG3dModelLoader
. Because of above reasons, when an OBJ file is loaded using this loader, it will log and error. To prevent this error from being logged, set thelogWarning
flag to false. However, it is advised not to do so. An OBJ file only contains the mesh (shape). It may link to a separate MTL file, which is used to describe one or more materials. In that case the MTL filename (might be case-sensitive) is expected to be located relative to the OBJ file. The MTL file might reference one or more texture files, in which case those filename(s) are expected to be located relative to the MTL file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ObjLoader.ObjLoaderParameters
-
Nested classes/interfaces inherited from class com.badlogic.gdx.assets.loaders.ModelLoader
ModelLoader.ModelParameters
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
logWarning
Set to false to prevent a warning from being logged when this class is used.-
Fields inherited from class com.badlogic.gdx.assets.loaders.ModelLoader
defaultParameters, items
-
-
Constructor Summary
Constructors Constructor Description ObjLoader()
ObjLoader(FileHandleResolver resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Model
loadModel(FileHandle fileHandle, boolean flipV)
Directly load the model on the calling thread.protected ModelData
loadModelData(FileHandle file, boolean flipV)
ModelData
loadModelData(FileHandle file, ObjLoader.ObjLoaderParameters parameters)
Directly load the raw model data on the calling thread.-
Methods inherited from class com.badlogic.gdx.assets.loaders.ModelLoader
getDependencies, loadAsync, loadModel, loadModel, loadModel, loadModel, loadModelData, loadSync
-
Methods inherited from class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader
unloadAsync
-
Methods inherited from class com.badlogic.gdx.assets.loaders.AssetLoader
resolve
-
-
-
-
Constructor Detail
-
ObjLoader
public ObjLoader()
-
ObjLoader
public ObjLoader(FileHandleResolver resolver)
-
-
Method Detail
-
loadModel
public Model loadModel(FileHandle fileHandle, boolean flipV)
Directly load the model on the calling thread. The model with not be managed by anAssetManager
.
-
loadModelData
public ModelData loadModelData(FileHandle file, ObjLoader.ObjLoaderParameters parameters)
Description copied from class:ModelLoader
Directly load the raw model data on the calling thread.- Specified by:
loadModelData
in classModelLoader<ObjLoader.ObjLoaderParameters>
-
loadModelData
protected ModelData loadModelData(FileHandle file, boolean flipV)
-
-