Bam2egg assertion error

I was trying to save a model (which I initially load from an Egg) as Bam and then convert it to Egg. The idea is to be able to work on materials and textures in a wysiwyg fashion by writing a simple editor.

Export to Bam works very well. If I set a new material on the model, save it as bam, and then load the bam, the model looks as expected.

I have a problem with using bam2egg, though. The material never gets written into the Egg. There’s always only the geometry data. Also, if the model has textures applied to it I get the following error:

Assertion failed: n >= 0 && n < (int)_render_stages.size() at line 104 of built/include/textureAttrib.I

EDIT: I know bam2egg isn’t the most reliable solution and that it might not always work, but this is a very simple case.

I’ll appreciate any help

EDIT2: Ok, I learned what seems to be the right way to do what I need. Instead of messing with bams I just modify the EggData, which seems a lot cleaner.

Still, it would be nice anyway if bam2egg worked, even just for the sake of it.

I think i have seen this issue when creating bam files with complex texture attributes setups (multiple textures). I think i was supplying a duplicated stage or a missing stage and it would save fine but would not convert to egg.