This example implements a basic flipbook in Python. When active, the script switches between its children at a rate of one per second. There are functions start() and stop() to control it; in the scene file, these are called by a wand trigger.
These files are included in the pyg.tgz tar file.
The scene file - flipper.scene:
light (position(0 0 1)) light (position(0.2 -1 1)) environment (skyColor(.2 .5 1)) transform (position(0 5 5)) { pySelector flip (script(flipper.py)) { staticObject (file(avatarHead.pfb)) staticObject (file(avatarHand.pfb)) staticObject (file(avatarBody.pfb)) } } wandTrigger (when(button1, flip.call(start())), when(button2, flip.call(stop())))
The Python script - flipper.py:
class flipper(ygSelector): def __init__(self): self.active = 0 def app(self): if (self.active) and (self.numChildren() > 0): val = int(ygdrasil.frameTime()) % self.numChildren() self.selectNum(val) def start(self): self.active = 1 def stop(self): self.active = 0
Last updated 13 September 2002.
home page