Opening panda3d bam cache files

Hi all :smile:

First of all, I am having a blast with Panda3D. It is cool that is one of the few frameworks out there with good python bindings.

Anywho, am working on a project where I am writing and reading to the bam cache directly for avoid constructing large model groups every time. Using the BamCache interface, using the lookup() and store() workflow

Since I write files directly sometimes need to look at the resulting bam model. Am wondering if there is better way to debug cache files other then loading them into new scene. I am thinking something like Pview but for cache files, since Pview cannot seem to load the bam files generated from BamCache. Could be that Pview can load them and I just doing something wrong, let me know :slightly_smiling_face:

thanks!!

Hi! Glad you are enjoying Panda3D. Welcome! Sorry it took so long to get to your message.

A .bam file is a serialized sequence of Panda3D objects, in the case of a cache file that is a BamCacheRecord followed by a ModelRoot. A regular .bam file is just a ModelRoot.

You can use the lower level BamFile interface to read a cache file:

from panda3d.core import *

file = BamFile()
if not file.open_read('0b9afe3ec2d70cadc46f3857ffc8879a.bam'):
    print("Failed!")

record = file.read_object()
file.resolve()
print(record)

node = file.read_node()
file.close()

# You can write the extracted node to a bam file if you wish
NodePath(node).write_bam_file('extracted.bam')
1 Like