Panda3D Manual: Enabling physics on a node
<<prev | top | next>> |
The ActorNode is the component of the physics system that tracks interactions and applies them to a model. The calculations factor in the amount of time elapsed between frames, so the physics will be robust against changes in framerate. To enable a node for physics, attach an ActorNode to it. The ActorNode keeps track of which NodePath it is attached to, and will change the position and orientation of that NodePath as physics is applied to the ActorNode. When an ActorNode is created, it must also be attached to a PhysicsManager. The PhysicsManager will handle the physics calculations every frame and notify the ActorNode of any changes it needs to apply to its parent NodePath. Panda provides a default physics manager, base.physicsMgr, which will often be suitable for most applications.
jetpackGuy=loader.loadModel("models/jetpack_guy") jetpackGuy.reparentTo(render) an=ActorNode("jetpack-guy-physics") anp=jetpackGuy.attachNewNode(an) base.physicsMgr.attachPhysicalNode(an)
Now, the "jetpack guy" model will be updated every frame with the physics applied to it. The ActorNode also serves as a repository for the PhysicsObject that describes the physical properties (i.e. mass) of the object. To modify these properties, use the getPhysicsObject call.
an.getPhysicsObject().setMass(136.077) #about 300 lbs
<<prev | top | next>> |