I am following this tut from the manual in order to create my .bam files:

[b]The Bam Interface

The easiest way to save geometry is to use to call writeBamFile(filename) from the NodePath that contains your geometry. myPanda=loader.loadModel(“panda”)

#do some fancy calculations on the normals, or texture coordinates that you dont
#want to do at runtime

#Save your new custom Panda

How do I use the same method on Actors which contain animation files?

Exactly the same way, I think. Have you tried it?

I haven’t tried anything because I didn’t know where to start. However, something just came to mind. I wonder if I could write to bam each animation on the same model, like this:


Maybe that might work.
However, before I can do that, I have to get the first code to work. I checked the folder for the .bam files after I run the game, and it’s empty.
I have to run a check and see if this is because I created the .bam file in a different folder to the .egg file.

No, all animations will be saved to the same .bam file.
You can then later load the actor like this:

actor = Actor("yourmodel.bam")

Instead of having multiple animation files, this file will have all the animations and model in the same file - since the anims will already be bound to the model.

Hang on a minute. When you do actor.writeBamFile(‘foo.bam’), it will write out the actor model, but it will probably not include the animations bound to the actor (unless they all came from the same egg file in the first place).

But that’s OK. The animations are still available in their original egg / bam files. You can writeBamFile the animation files too, but there’s no reason to do this, because the resulting bam file will be the same thing as the one you started with. (You can’t manipulate animation tables at runtime in Panda, so there’s no reason to load and re-save animation files.)

The only reason to do this writeBamFile() trick at all is to save out a bam file that you created and/or finessed at runtime within Python. It’s tricky to manipulate an animated model, which is why this question doesn’t come up often for animated models–most people aren’t trying to manipulate their models’ vertices at runtime. Is that what you’re doing?


Ah! I was just about to post. I realized that it would be imposible to do what thought of, since the animations cannot be identified seperately on a model. You solved it for me. Thanks again.

Oh! I found the .bam files. It was a mistake on my part.

Wait! Drwr it seems like I was writing the same time you posted.

No, I am not trying to manipulate my models. I was just using this method to do a quick egg-to-bam rather than using the egg2bam tool, which is a bit time consuming.

I noticed you said probably. Does this mean that there is a probability that the animations might be included?
If they definitely will not be included, can you show me how to

do this? Thanks

In general, you can always do:

m = loader.loadModel('foo.egg')

and it will have roughly the same result as:

egg2bam -o foo.bam foo.egg

This will work just fine for static models, animated models, and animation tables, or really anything at all you can put in an egg file. The point is that you can load all of these egg files directly with loader.loadModel(), and you will get a node; and that node can be written to a bam file.

When I said “it will probably not include the animations bound to the actor”, I only mean that the Actor interface won’t put the animations in the same node with the model, so when you write out the model, it won’t include the animations that you loaded with the Actor interface. It would include those only if they were in the egg file with the model in the first place.

But for the purposes of replacing egg2bam, you wouldn’t use the Actor interface to load up your egg files. Just load them directly.



Let me see if I understand correctly. Basically drwr, I would now have to load all my animation files as a single model, and then write them as a bam. Whew! That’s a lot of animations, which adds up to a lot of work. I might as well use egg2bam if that’s the only way. Thanks

Ynjh_jo, I downloaded the file and will take a look at it right now. Thanks

I need some help with wxPython.
I get a message at the start of wxPython installation saying that no installation of python 2.6 was found in the registry, and to be sure to enter a pathname that places wxPython on the PYTHONPATH. I went ahead and installed on the pathname ‘C:\Panda3D-1.5.2\python\Lib’, but this messed up my python (I believe I was using 2.5) which no longer worked. I restored the computer, downloaded python 2.6.2 (zip), and unzipped it to the panda folder. I just want to be sure of the correct way to do this so that I do not run into problems. So I have a two questions.

Should I use the python 2.6.2 installer instead of the zip, so that it installs in the registry?
Is unzipping Python 2.6.2 to the panda folder the correct thing to do?

Sure, but it doesn’t have to be work for you. Let the computer do it for you. Write a program that reads all of your files in a loop or something. You can use Python’s glob module and do it in about five lines of code.

No, remember, Panda is built with Python 2.5. You can’t mix-and-match different Python versions. Get all that Python 2.6 stuff out of there, and then go download a version of wxPython that uses Python 2.5. Either that, or build your own Panda that uses Python 2.6.


drwr, I wish that were as easy for me to do as you said it, but I am not that good at programming. I have an idea what to do, but I don’t often get the coding right.

I downloaded the right version of wxPython, and it’s working. Thanks

I can’t just accept this without saying…
… to the person(s) responsible for the bam copier program.
Good Job! You knocked 99% of work and time off my shoulders.

Good for you. :smiley:

Thank’s a lot, interesting thread, I thought it was not possible to convert any model into bam (because egg2bam is nice, but if you have models from various sources, you have to use different commandlines executables for each source object depending on its type, very tedious… I wonder why there’s not a central wrapper to automate this?).

Here is my code to convert in batch a whole directory of 3D models into BAM:

class ModelsConverter:
    def model2Bam(self, modelpath, bampath):
        ''' Standard way to convert any 3D model (from any supported format by Panda3D) into a BAM (compiled runtime)
        equivalent to: egg2bam -o foo.bam foo.egg
        WARNING: BAM files only work for the very specific version of Panda3D they were built with, so you should keep the original 3D models somewhere and use BAM files only for runtime!


        #do some fancy calculations on the normals, or texture coordinates that you dont
        #want to do at runtime

        #Save your new custom Panda

        # Free memory

        return True

    def model2BamMulti(self, modeldir, bamdir):
        ''' Convert in batch all 3D models in a directory into BAM '''

        for model in os.listdir(modeldir):
            modelName = model.split('.')[0] # Get only the model name, without extension
            self.model2Bam( os.path.join(modeldir, model), os.path.join(bamdir, "%s.bam" % modelName) ) # convert it to BAM

        return True