Panda3D Manual: Writing 3D Models out to DiskPanda has two native file formats for models. Egg files (with the extension BAM FilesBecause of the way the egg syntax is designed, an egg file might be very large, sometimes many times larger than the file it was converted from. It can also sometimes take several seconds for Panda to load a large egg file. Bam files (with the extension You can always convert egg files to bam files using the program egg2bam. For many simple models, it is also possible to convert back again with the program bam2egg, but you should not rely on this, since it does not convert advanced features like animation; and some structure of the original egg file may be lost in the conversion. You can load files of these formats, as well as any other supported format, using the loader.loadModel interface. Any file types other than The Bam InterfaceThe easiest way to save geometry is to use to call 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 myPanda.writeBamFile("customPanda.bam") The Egg InterfaceOne easy way to create The complete documentation for using the egg interfaces has yet to be written, but the egg library is really quite simple to use. The basic idea is that you create an EggData, and an EggVertexPool to hold your vertices; and then you can create a series of EggVertex and EggPolygon objects. If you want to create some structure in your egg file, you can create one or more EggGroups to separate the polygons into different groups. Here is an example: def makeWedge(angleDegrees = 360, numSteps = 16): data = EggData() vp = EggVertexPool('fan') data.addChild(vp) poly = EggPolygon() data.addChild(poly) v = EggVertex() v.setPos(Point3D(0, 0, 0)) poly.addVertex(vp.addVertex(v)) angleRadians = deg2Rad(angleDegrees) for i in range(numSteps + 1): a = angleRadians * i / numSteps y = math.sin(a) x = math.cos(a) v = EggVertex() v.setPos(Point3D(x, 0, y)) poly.addVertex(vp.addVertex(v)) # To write the egg file to disk, use this: data.writeEgg(Filename("wedge.egg")) # To load the egg file and render it immediately, use this: node = loadEggData(data) return NodePath(node) See the generated API documentation for more complete information about the egg library. © Carnegie Mellon University 2010 |