This tutorial is intended as a quick reference to how to setup a simple scene using Panda3D – getting objects loaded, positionning them, and starting your game or virtual world.
If you are new to Panda3D, read and run the Panda3D hello world in their manual. I also find that the manual’s scene-graph introduction may be important.
Consider downloading the latest of Panda3D, Blender, Python and the Chicken plugin for Blender (The Python release shipping with Panda3D may not be supported by Blender).
Getting up to speed
# load global objects import direct.directbase.DirectStart # if you are using animated models from direct.actor import Actor
Loading models and actors
# all paths must use '/', not '\', even on Windows
loader.loadModel("path")
# an actor is a model associated with several named animations
Actor.Actor(path,{"animName":"animPath"}[,...])
I create my models using Blender and export them using the Chicken plugin (see my article about Chicken export and caveats).
Setting the stage
Methods you can use on models and actors
reparentTo(aNode) # use reparentTo(render) to add to world root setScale(x,y,z) # scale setPos(x,y,z) # translate setHpr(u,v,w) # rotate (degrees, e.g. 90, 180, ...)
Methods you can use on actors:
play("animName") # play an animation once
loop("animName") # loop an animation indefinitely
stop() # stop all animations
Raising the curtain
Run:
ppython PATH
where PATH is the path to your python script (including .py extension)
Note: I think ‘ppython’ is only available on Windows; there is an equivalent on Linux – check the Panda3D manual.
0 Responses to “Panda3D/Python: Setting the Stage”