Class ObjLoader
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 the Material
(Attributes
), e.g. the color or
texture applied, might not or not correctly be loaded.
This ModelLoader
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 use G3dModelLoader
.
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 the
logWarning
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.
20171024 - Added support for emissive textures and colors
-
Nested Class Summary
Nested classes/interfaces inherited from class gaiasky.util.gdx.loader.IntModelLoader
IntModelLoader.IntModelParameters
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Set to false to prevent a warning from being logged when this class is used.Fields inherited from class gaiasky.util.gdx.loader.IntModelLoader
defaultParameters, items
-
Constructor Summary
ConstructorDescriptionObjLoader(InputStreamProvider isp, com.badlogic.gdx.assets.loaders.FileHandleResolver resolver)
-
Method Summary
Modifier and TypeMethodDescriptionloadModel(com.badlogic.gdx.files.FileHandle fileHandle, boolean flipV)
Directly load the model on the calling thread.protected IntModelData
loadModelData(com.badlogic.gdx.files.FileHandle file, boolean flipV)
loadModelData(com.badlogic.gdx.files.FileHandle file, ObjLoader.ObjLoaderParameters parameters)
Directly load the raw model data on the calling thread.Methods inherited from class gaiasky.util.gdx.loader.IntModelLoader
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
-
Field Details
-
logWarning
public static boolean logWarningSet to false to prevent a warning from being logged when this class is used. Do not change this value, unless you are absolutely sure what you are doing. Consult the documentation for more information.
-
-
Constructor Details
-
ObjLoader
public ObjLoader() -
ObjLoader
public ObjLoader(InputStreamProvider isp, com.badlogic.gdx.assets.loaders.FileHandleResolver resolver)
-
-
Method Details
-
loadModel
Directly load the model on the calling thread. The model with not be managed by anAssetManager
. -
loadModelData
public IntModelData loadModelData(com.badlogic.gdx.files.FileHandle file, ObjLoader.ObjLoaderParameters parameters)Description copied from class:IntModelLoader
Directly load the raw model data on the calling thread.- Specified by:
loadModelData
in classIntModelLoader<ObjLoader.ObjLoaderParameters>
-
loadModelData
-