Export blender 3d model and convert it in .bam or .egg

Hello !
I am a begginer and It has been few days that i’m struggling with a problem and i feel like i can’t resolve it by myself or by searching on internet so i ask for some help here :slight_smile:
In fact it is a simple problem ; how to export a 3d model from blender and load it in Panda3d.
I use blender 2.83.4 and I just don’t know how to export a 3d model from blender to a file .bam or .egg. I tried to use Yabee but blender tells me “unexpected error during export See console for traceback!”. When i check the console i see :

“Read prefs: C:\Users\ziiir\AppData\Roaming\Blender Foundation\Blender\2.83\config\userpref.blend
AL lib: (EE) UpdateDeviceParams: Failed to set 48000hz, got 44100hz instead
found bundled python: C:\Program Files\Blender Foundation\Blender 2.83\2.83\python
Read blend: C:\Users\ziiir\Downloads\background.blend
Objects for export: [‘Cube’]
WRITE main EGG to C:\Users\ziiir\Downloads\back.egg
INFO: Used materials: {‘Material’}
Traceback (most recent call last):
File “C:\Users\ziiir\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\YABEE-devel\yabee_libs\egg_writer.py”, line 1600, in write_out
materials_str, USED_MATERIALS, USED_TEXTURES = get_egg_materials_str(selected_obj)
File “C:\Users\ziiir\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\YABEE-devel\yabee_libs\egg_writer.py”, line 1174, in get_egg_materials_str
for node in bpy.data.materials[0].node_tree.nodes:
AttributeError: ‘NoneType’ object has no attribute ‘nodes’
ERROR (bke.lib_id): C:\b\buildbot-worker-windows\windows_lts_283\blender.git\source\blender\blenkernel\intern\lib_id.c:342 id_us_min: ID user decrement error: MAMaterial.001 (from ‘[Main]’): 0 <= 0
ERROR (bke.lib_id): C:\b\buildbot-worker-windows\windows_lts_283\blender.git\source\blender\blenkernel\intern\lib_id.c:342 id_us_min: ID user decrement error: OBCube.001 (from ‘[Main]’): 0 <= 0”

(i don’t know what that means)
The .bam file that results is just filled with a " { Z-up } "
i saw several CLI that could convert .blend to bam or things like that but i don’t know how to use them so… ^^
Please help me, i just want a .egg or .bam file with my 3dmodel inside, no matter the software, CLI or others things used !

Unfortunately, the 2.8 version of Blender made some changes that broke YABEE’s support for it. :/

There are a few options available, I believe:

  1. Downgrade Blender to 2.78, which should worth with YABEE.
  2. Get the version of YABEE updated for Blender 2.8 by another user.
  3. Use “blend2bam” to convert the Blender file to a BAM file.
  4. Export to glTF, and use Panda’s glTF importer to load the resultant file

(And there may be options that I’m missing.)

Each option may have a different set of features available (even the Blender 2.8 version of YABEE differs slightly from the Blender 2.7 version, I believe). It may thus be wise to look into which option offers the features that you want.

(Amongst those export options I’m only familiar with the Blender 2.7 version of YABEE, I’m afraid, and so feel that I’m not in a position to advise between them, myself.)

Thanks for your quick answer !

In fact the version of yabee i use is the one who’s suposed to suport blender 2.8 but… it didn’t work very well ! Using blender 2.78 could be an option but i fell like it is way less beginner friendly (i already downloaded and used the zip fil). I also tried to import a 3d model created on blender 2.8 on blender 2.7 but it didn’t work either.

I tried to use panda’s gtlf importer but when i used the command “import gtlf” as the github page tell me to do, python didn’t recognize the command.

“blend2bam” could be the solution to my problems but as i said i don’t know how to use it ^^ I found 0 tutorial on how to use it, just how to download it; wich i did. When i use the command pip list it says:"

Package Version


panda3d 1.10.6
panda3d-blend2bam 0.12
panda3d-gltf 0.7
panda3d-simplepbr 0.6
pip 20.2.1
"
so it is really installed ^^
I don’t know what to do…

This may be a typo in your reply, but I note that the import-line that you quoted has "import gtlf, rather than gltf–that is, it has the “t” and the “l” the wrong way around. In case that’s not just a typo in your reply, perhaps try the importer again with the “l” before the “t”!

Ah, fair enough. I’ve never used it myself–I’ve chosen to stick with Blender 2.7 and its associated version of YABEE.

That’s very fair: the older versions of Blender have a pretty steep learning curve, I fear.

Fair enough! I’ve not used it myself, but I see that the GitHub page for it seems to contain instructions:

If those don’t help, perhaps try searching the forums–others may have faced the same uncertainty.

You can just use blend2bam on the command-line to convert a blend file to a bam file.

I am not sure why you would try to import gltf. If you install panda3d-gltf, you should be able to just load .gltf files without need for additional imports.

Could you tell me please how to use blend2bam ? Because “blend2bam” is not recognized as an internal command, there must be a protocole if i want to use it, so could you tell me how ?

There should be installation instructions in the link that I gave above (as well as usage instructions). Have you followed those, and if so, what were the results? (e.g. Were there any errors or other pieces of output?)

the only instructions was : it’s an CLI command, wich helps me a lot cause it isn’t recognized as one in the command prompt :confused:

Blender 2.8 works fine with YABEE for me…

The document to which I linked above contains rather more than that, as I’m looking at it. In particular, there’s a section labelled “Installation”–have you followed that?

For the sake of clarity, here’s the link again:

When is use the command pip list it says:
"
Package Version


panda3d-blend2bam 0.12
panda3d-gltf 0.7
panda3d-simplepbr 0.6
pip 20.2.2
setuptools 49.3.1
"
wich means that it is installed, by the way it is suposed to “supplies a Python file loader to add “native” blend file support to Panda3D.” wich didn’t work when i tried to load it :

class MyGame(ShowBase):
def init(self):
super().init()
background = self.loader.loadModel(“mymodels\background”)
background.reparentTo(self.render)

(tell me if I made a mistake in my code because i just began Panda3d)
There are effectively instructions in the github page but they all use the command “blend2bam” wich isn’t a command :confused:

Ah, I see. Hum, that is odd!

Trying a quick installation-and-run on my system seems to indicate that it works–but then, I’m using Linux and it looks like you’re using Windows, so the results aren’t all that comparable, I fear.

I think that for file types other than “egg” and “bam” the loader expects the file extension to be supplied; if no file extension is given, it assumes that it’s either “egg” or “bam”.

So, in order to load a “blend” file, you would do something like this:

 background = self.loader.loadModel(“mymodels\background.blend”)

I tried to add .blend at the end but : “OSError: Could not load model file(s): [‘mymodels\background.blend’]”…
when you installed blend2bam have you just used the command “pip install panda3d-blend2bam” or have you made others manipulation like adding a blend2bam folder in your virtual environement or something like that ?

Just to check: is your model-folder (“mymodels”) a sub-folder of the folder that holds your main Python file, with no other folders in-between?

I note that the error that you posted there looks to me like an issue with the file-path, not with model-loading.

It’s slightly more complicated on my system because of restrictions that Linux puts in place, but aside from the associated prepending of “sudo -H”–a Linux command for operating as “root”–that’s pretty much it. No other manipulations, no creation of folders. (And I don’t have a virtual environment at all.)

I did use “pip3” instead of “pip” (i.e. I used the Python3 version pip); I don’t know whether the distinction exists under Windows, but it’s not likely to hurt to try.


I think so … ?

The pip and pip3 commands reacts the same way on my command prompt so I don’t think there is any problem here !

Probably the Python Scripts folder isn’t on the PATH.

You can invoke it as python -m blend2bam instead.

Hmm… It looks right, indeed. Very strange!

I suppose that a quick test would be to get an egg or bam file (you should find some in Panda’s model-folder, I think), copy it to that same folder, and see whether that loads successfully.

(However, if you do use one of those from Panda’s model-folder, remember to rename it! Otherwise it might load the model from the original folder, and only seem to work!)

That’s a good point; I’d be interested to know whether that works!

Yes ! Now it’s recognized as a command ! Thanks a lot ! One last question : the program doesn’t found the blender file, could you tell me how to tell him where is the file please ? I try the different commands but it doesn’t find it…

1 Like

If you’re running blend2bam from the command-line (as opposed to from within your own program), then the easiest way might be to just run it with the command-line’s current directory being the folder that contains your blend-file. That is, using “cd” to change the directory in the command-line until it’s the one that holds the blend-file.

In fact it is searching for blender and not the .blend file. I added blender to the system PATH and used the command “python -m blend2bam --blender-dir C:\Program Files\Blender Foundation\Blender 2.83\blender.exe background.blend background.bam” but it didn’t work… How can it find blender ?