Bam files generated from egg files get invalid texture paths when distributing game

I have an egg file which contains:

<Texture> target_indicator {
  target_indicator.png
}

The target_indicator.png file lies next to the egg file (in $MAIN_DIR/textures/ui/hud) and is loaded correctly when I run the game.

When building the game with python3 setup.py bdist_apps the egg file gets converted into a bam file. When I run the build, everything works fine, but as soon as I move the build folder, I get:

gobj(error): Texture::read() - couldn't read: ../../../../../textures/ui/hud/target_indicator.png
:gobj(error): Unable to find texture "../../../../../textures/ui/hud/target_indicator.png" on model-path /tmp/wbwb_build:/../../:/../..//models

The path inside the bam file seems to be pointing back to the original texture in the source folder, not the one copied into the build folder.

I’ve already tried adding a file_handler to add “-ps rel” to the arguments of egg2bam when it’s called in the bdist_app process, but this results in the same paths:
egg2bam -ps rel textures/ui/hud/target_indicator.egg /home/micha/Projects/WBWB/Source/build/manylinux2014_x86_64/textures/ui/hud/target_indicator.egg.bam

I’m wondering how it happened that the required folder is copied by the build system. By default, you place your textures in advance in the game folder, not outside it.

I’m not sure I understand what you mean?
This is the game folder structure during development (note that everything is inside this folder, as you mention?):

  • main.py
  • textures
    • ui
      • hud
        • target_indicator.png
        • target_indicator.egg

When building, the build process creates a folder build/manylinux inside the source folder and moves everything to the correct places, i.e. there is now a build/manylinux/textures/ui/hud/target_indicator.png and a build/manylinux/textures/ui/hud/target_indicator.egg.bam, but the latter seems to reference ../../../../../textures/ui/hud/target_indicator.png (which is the one in the source folder) instead of the target_indicator.png that lies right next to it.

1 Like

I thought you were using it.
https://docs.panda3d.org/1.10/python/distribution/building-binaries#including-assets

It looks like the build system is not working correctly…

Which version of Panda? A bug was fixed recently regarding this matter.