Blender >> Panda3D: Clearing the Cache

Part III of this Panda3D/Python crash tutorial. I hacked some code into Tut-Step-2-Basic-Setup.py (from the Panda3D tutorial).

In Panda3D, you can load geometry using loader.loadModel(PATH). Obviously just loading sample models doesn’t feel like overwhelming freedom. Here’s some tips for loading from Blender:

  • Just download Blender and export to X. Blender exports *.x out of the box and loader.loadModel recognizes X directly (formats, conversions and the afterlife of 3D models in Panda3D are somehow described elsewhere).
  • The (double) conversion preserves (at least some of) the material/colour information. That’s cool. Also, the models load to scale (if it’s 1.0 units in Blender it’s 1.0 units in Panda3D).
  • By default, Panda3D provides ambient lighting. This means we don’t need to add a light source to see ‘something’. Sure, it ain’t pretty.
  • I loaded my files relative to the current directory. You can select a model-path similar to a classpath.

Panda3D caveats

  • Select [Swap  ZY] in Blender export settings (or fix it your way). Otherwise your model’s top will turn it’s back to you.
  • By default, Panda3D caches loaded models in the [modelcache] directory. If you export your model, change it in blender and export again, cached geometry will be loaded instead. I don’t know how to disable this but you can at least delete all files in the cache (all files. It’s OK.)
  • You need to provide a file extension. Python seems to be assuming .egg.pz otherwise.

Python caveat: the Python interpreter doesn’t like mixing tabbed and spaced indents. By default the tutorial code I’ve got seems to be using 2 spaces per indent. Because I use hard tabs 2 spaces wide, it took me a while to work out why my code (tabbed) conflicted with the tutorial code (spaced). Remember python doesn’t use decorated brackets, so it’s gotta be strict about indents to figure nesting levels.

I paraphrased that code, as below:

box=loader.loadModel("models/pawn.x")
box.reparentTo(render)
box.setScale(1,1,1)
box.setPos(0,0,0)

Apart from the quirky reparentTo function, it’s all great, simple functions so far. Fingers crossed.

Sorry. I love Blender. I can’t help you if you don’t love Blender.

0 Responses to “Blender >> Panda3D: Clearing the Cache”



  1. Leave a Comment

Leave a comment