Loading Wavefront obj files with materials

(Mart Roosmaa) #1

Disclaimer: I’m new to game development. Occasionally experimenting with it during my free time to learn some new concepts. I’m quite comfortable using Rust.

I wanted to get something rendering in 3D. I took some nature models from Kenney’s asset pack. The models are Wavefront obj files (exported from SketchUp) with associated material mtl files. The ObjFormat loader bundled with Amethyst only loads the Mesh from the obj files, the materials are ignored.

From what I understand, then if I want to import the models in full glory (with the materials attached), then I should write a custom importer that creates a separate entity for each Geometry that the wavefrom_obj library provides with the appropriate mesh and material attached. These entities can be grouped together by attaching an appropriate Parent.

I’ve been eyeing the PrefabLoader as an easy way to facilitate the loading process. That would allow me to get away by only implementing a custom Format that parses the obj and mtl files and converts the parsed data into PrefabData enabled structs. The PrefabLoader would handle rest of the magic (injecting the entities when ready).

Since I’m new to this game development thing, I would like to get some thoughts from more experienced people. Is the process of creating a bunch of entities for different part of the model is the proper way to load models? (Is this what actual games do?) And is my plan to exploit the PrefabLoader to load the whole model in one go the best option or maybe there’s some other mechanism in Amethyst I should be considering?

1 Like
(Mart Roosmaa) #2

Just discovered that when downloading the nature models via the link above, the archive contains some more formats for the models. Before I was using the Kenney’s asset pack bundle which only included .obj files.

That in turn led me to discover the amethyst_gltf package. Based on that package, it seems to me that my plan of using PrefabLoader was spot on.

(Erlend Sogge Heggen) #3

Is this pretty much resolved then or are you still running into some issues?

(Mart Roosmaa) #4

Yup, it’s resolved. Ended up using the glTF models all together for my experimentation. Had some issues using the wrong render pass (interleaved vs separate), but Fusha on discord was kind enough to point that out, so things get rendered now :slight_smile:

1 Like