DistributedSmoothActor.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from direct.distributed.DistributedSmoothNode import DistributedSmoothNode
  2. from panda3d.core import NodePath
  3. from direct.actor.Actor import Actor
  4. class DistributedSmoothActor(DistributedSmoothNode, Actor):
  5. def __init__(self, cr):
  6. Actor.__init__(self, "models/ralph",
  7. {"run": "models/ralph-run",
  8. "walk": "models/ralph-walk"})
  9. DistributedSmoothNode.__init__(self, cr)
  10. self.setCacheable(1)
  11. self.setScale(.2)
  12. def generate(self):
  13. DistributedSmoothNode.generate(self)
  14. self.activateSmoothing(True, False)
  15. self.startSmooth()
  16. def announceGenerate(self):
  17. DistributedSmoothNode.announceGenerate(self)
  18. self.reparentTo(render)
  19. def disable(self):
  20. # remove all anims, on all parts and all lods
  21. self.stopSmooth()
  22. if (not self.isEmpty()):
  23. Actor.unloadAnims(self, None, None, None)
  24. DistributedSmoothNode.disable(self)
  25. def delete(self):
  26. try:
  27. self.DistributedActor_deleted
  28. except:
  29. self.DistributedActor_deleted = 1
  30. DistributedSmoothNode.delete(self)
  31. Actor.delete(self)
  32. def start(self):
  33. # Let the DistributedSmoothNode take care of broadcasting the
  34. # position updates several times a second.
  35. self.startPosHprBroadcast()
  36. def loop(self, animName):
  37. self.sendUpdate("loop", [animName])
  38. return Actor.loop(self, animName)
  39. def pose(self, animName, frame):
  40. self.sendUpdate("pose", [animName, frame])
  41. return Actor.pose(self, animName, frame)