Login  Register

Re: how to load a .obj with mtl?

Posted by jf Pauly on Dec 06, 2017; 4:24pm
URL: https://forum.jogamp.org/how-to-load-a-obj-with-mtl-tp4038099p4038385.html

I have also been  struggling (as you say) to get textures with WaveFront models.
So I have copied the objectfile package into my own stuff to be able to look at the code (and may be change it ).
I have coded several changes :
1- when an unknown token is encountered in ObjectFileMaterials.java, do not just crash, ignore the token (line 340)
2- sometimes (often??) the models I got do not include group tokens as they would do. So ObjectFile.java does not see the groups token and does not build shap3D's to assign appearances with textures. I have added code to generate groups.
Changed code apply this simple rule to find material and textures:

 * The folder which contains .obj also contains .mtl
 * It also contains a folder named textures with texture pictures.

To verify I suggest the following :

goto https://sourceforge.net/projects/cliper/ 
You could download the project and include the objectfile package it contains to test.
You can also download the dist file,  run the JAR and load models.
I am afraid that my late response is not usefull for you, but I hope that these corrections could help other people.
Regards
jf Pauly