Class ObjLoader

  • public class ObjLoader
    extends IntModelLoader<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 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

    • Field Detail

      • logWarning

        public static boolean logWarning
        Set 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 Detail

      • ObjLoader

        public ObjLoader()
      • ObjLoader

        public ObjLoader​(InputStreamProvider isp,
                         com.badlogic.gdx.assets.loaders.FileHandleResolver resolver)