`setuptools` not working with .obj files

I’m able to load a .obj file into my program and it runs fine.

But when I use setuptools to bundle it into an app, the app doesn’t run and I get the error(s):

:audio(error):   load_dso(libp3fmod_audio.so) failed, will use NullAudioManager
:audio(error):     No error.
:loader(warning): Unable to load libp3assimp.dylib: No error.
:loader(error): Extension of file models_and_textures/mars.obj is unrecognized; cannot load.
Currently known scene file types are:
  Bam                             .bam
:loader(error): Couldn't load file models_and_textures/mars.obj: all matching files on model path invalid (the model path is currently: "/Volumes/iMac and MBP Files/CAMBRIDGE/ENGINEERING – 1A/Mars_Lander/Python Version/Project Files/build/macosx_10_6_x86_64/Mars Lander – 2019.app/Contents/MacOS/../Resources:/..:/../models")
Traceback (most recent call last):
  File "lander_graphics.py", line 23, in <module>
    lander = Lander()
  File "lander_graphics.py", line 17, in __init__
    self.mars = self.loader.loadModel("models_and_textures/mars.obj")
  File "/Volumes/iMac and MBP Files/CAMBRIDGE/ENGINEERING – 1A/Mars_Lander/Python Version/Project Files/build/__whl_cache__/panda3d-1.10.4.1+opt-cp37-cp37m-macosx_10_6_x86_64.whl/direct/showbase/Loader.py", line 286, in loadModel
OSError: Could not load model file(s): ['models_and_textures/mars.obj']

I’m aware that a bundled app uses .bam files which are usually converted from .egg files. However, the obj2egg program does not work with textures, so the model ends up white if I convert it to .egg.

Are there any other things I can try?

The simple option is to just include ‘p3assimp’ in the list of plugins. In fact, you probably should have gotten a warning that this plugin was missing. The more involved answer is to make a file handler for obj that converts to BAM using Assimp. A file handler for all types supported by Panda is being planned.

2 Likes

Wow! It worked, thank you so much!

I just added the p3assimp plugin.

I wonder why the conversion to bam is imposed? Concern about formats is up to users, but not as a build script. And yes, why do we need Assimp if the panda supported .OBJ without it.

Users can use whatever model they want in deployed applications, but the non-BAM loaders are not included by default. So, to keep file size down and reduce load times, BAM is recommended for deployed applications.

As for why to use Assimp, it has a better OBJ loader than Panda’s builtin loader.

Also, in case anyone is wondering, to get the non-Assimp, non-BAM loading code, include the p3ptloader plugin.

2 Likes

Thank you for the insight!

Do you know where one can find a list of all Panda3D loaders for reference?

The only list I know of is as part of the list of plugins that build_apps recognizes. p3ptloader and p3assimp are the only additional loaders on top of BAM, which is builtin and not part of a plugin.

If assimp is not enabled, Panda3D will load via .obj files via libp3ptloader, which will invoke obj2egg. This tool is very rudimentary and does not even support materials or textures.