.obj/.mtl loader, written in native GML, for GameMaker LTS 2022 by Juju Adams
See also BBMOD by Patrik Kraif
Lightweight .obj/.mtl 3D model loader written in native GML. Can load from external files or from buffers. This example does not show off complex renderering or PBR, it only demonstrates the loading capabilities of the library.
Details on the .obj format can be found here: http://paulbourke.net/dataformats/obj/
Look! It's Sponza! In GameMaker!
dotobj currently supports:
-
Per vertex position, texture coordinates, and normals
-
Materials and material libraries
-
Groups and objects
-
Vertex colours - (not in the official .obj spec, but some editors can export them)
-
UV flipping and winding-order reversal to handle engine quirks
-
N-gon faces
How do I import dotobj into my game?
GameMaker allows you to import assets, including scripts and shaders, directly into your project via the "Local Package" system. From the Releases tab for this repo, download the .yymps file for the latest version. In the GMS2 IDE, load up your project and click on "Tools" on the main window toolbar. Select "Import Local Package" from the drop-down menu then import all scripts from the package.
Please note that dotobj doesn't support the following features:
- Smoothing groups
Not a priority since you can usually bake normals on export, but it'd be useful to have regardless.
- Separate in-file LOD
Not sure how often this gets used. Probably possible to implement if requested.
- Line primitives
Line primitives are mostly used for visualisation in editors rather than for actual game rendering. It's possible to parse line primitives and output that, but it's not a priority.
- Freeform curve/surface geometry (NURBs/Bezier curves etc.)
Rare to see this in gamedev and getting GameMaker to generate surfaces is not going to be a pleasant process. This will probably never be implemented.