浏览代码

changes from Jason Pratt to support running epydoc--don't do stuff on module import

David Rose 20 年之前
父节点
当前提交
468fb19220

+ 1 - 1
direct/src/controls/ControlManager.py

@@ -4,7 +4,7 @@ from direct.showbase.ShowBaseGlobal import *
 #from PythonUtil import *
 #from IntervalGlobal import *
 
-from otp.avatar import Avatar
+#from otp.avatar import Avatar
 from direct.directnotify import DirectNotifyGlobal
 #import GhostWalker
 #import GravityWalker

+ 1 - 1
direct/src/fsm/FSM.py

@@ -308,7 +308,7 @@ class FSM(DirectObject.DirectObject):
             # request) not listed in defaultTransitions and not
             # handled by an earlier filter.
             if request[0] in string.uppercase:
-                raise RequestedDenied, request
+                raise RequestDenied, request
 
         # In either case, we quietly ignore unhandled command
         # (lowercase) requests.

+ 126 - 123
direct/src/gui/DirectGuiTest.py

@@ -1,133 +1,136 @@
-from direct.showbase.ShowBaseGlobal import *
-from DirectGui import *
-from whrandom import *
-
-# EXAMPLE CODE
-# Load a model
-smiley = loader.loadModel('models/misc/smiley')
-
-# Here we specify the button's command
-def dummyCmd(index):
-    print 'Button %d POW!!!!' % index
-
-# Define some commands to bind to enter, exit and click events
-def shrink(db):
-    db['text2_text'] = 'Hi!'
-    taskMgr.remove('shrink')
-    taskMgr.remove('expand')
-    # Get a handle on the geometry for the rollover state
-    rolloverSmiley = db.component('geom2')
-    rolloverSmiley.setScale(db.component('geom0').getScale()[0])
-    rolloverSmiley.lerpScale(.1,.1,.1, 1.0, blendType = 'easeInOut',
-                             task = 'shrink')
-
-def expand(db):
-    db['text0_text'] = 'Bye!'
-    taskMgr.remove('shrink')
-    taskMgr.remove('expand')
-    db.component('geom0').setScale(db.component('geom2').getScale()[0])
-    db.component('geom0').lerpScale(1,1,1, 1, blendType = 'easeInOut',
-                             task = 'expand')
-    db.component('geom2').clearColor()
-
-def ouch(db):
-    taskMgr.remove('shrink')
-    taskMgr.remove('expand')
-    taskMgr.remove('runAway')
-    db.component('geom0').setScale(db.component('geom2').getScale()[0])
-    db.component('geom1').setScale(db.component('geom2').getScale()[0])
-    db['text2_text'] = 'Ouch!'
-    db['geom2_color'] = Vec4(1,0,0,1)
-    newX = -1.0 + random() * 2.0
-    newZ = -1.0 + random() * 2.0
-    db.lerpPos(Point3(newX, 0, newZ), 1.0, task = 'runAway',
-               blendType = 'easeOut')
-
-dl = DirectFrame(image = 'models/maps/noise.rgb')
-dl.setScale(.5)
-
-# Create a button with a background image, smiley as a geometry element,
-# and a text overlay, set a different text for the four button states:
-# (normal, press, rollover, and disabled), set scale = .15, and relief raised
-dbArray = []
-for i in range(10):
-    db = DirectButton(parent = dl,
+
+if __name__ == "__main__":
+    from direct.directbase import DirectStart
+    from DirectGui import *
+    from whrandom import *
+
+    # EXAMPLE CODE
+    # Load a model
+    smiley = loader.loadModel('models/misc/smiley')
+
+    # Here we specify the button's command
+    def dummyCmd(index):
+        print 'Button %d POW!!!!' % index
+
+    # Define some commands to bind to enter, exit and click events
+    def shrink(db):
+        db['text2_text'] = 'Hi!'
+        taskMgr.remove('shrink')
+        taskMgr.remove('expand')
+        # Get a handle on the geometry for the rollover state
+        rolloverSmiley = db.component('geom2')
+        rolloverSmiley.setScale(db.component('geom0').getScale()[0])
+        rolloverSmiley.lerpScale(.1,.1,.1, 1.0, blendType = 'easeInOut',
+                                 task = 'shrink')
+
+    def expand(db):
+        db['text0_text'] = 'Bye!'
+        taskMgr.remove('shrink')
+        taskMgr.remove('expand')
+        db.component('geom0').setScale(db.component('geom2').getScale()[0])
+        db.component('geom0').lerpScale(1,1,1, 1, blendType = 'easeInOut',
+                                 task = 'expand')
+        db.component('geom2').clearColor()
+
+    def ouch(db):
+        taskMgr.remove('shrink')
+        taskMgr.remove('expand')
+        taskMgr.remove('runAway')
+        db.component('geom0').setScale(db.component('geom2').getScale()[0])
+        db.component('geom1').setScale(db.component('geom2').getScale()[0])
+        db['text2_text'] = 'Ouch!'
+        db['geom2_color'] = Vec4(1,0,0,1)
+        newX = -1.0 + random() * 2.0
+        newZ = -1.0 + random() * 2.0
+        db.lerpPos(Point3(newX, 0, newZ), 1.0, task = 'runAway',
+                   blendType = 'easeOut')
+
+    dl = DirectFrame(image = 'models/maps/noise.rgb')
+    dl.setScale(.5)
+
+    # Create a button with a background image, smiley as a geometry element,
+    # and a text overlay, set a different text for the four button states:
+    # (normal, press, rollover, and disabled), set scale = .15, and relief raised
+    dbArray = []
+    for i in range(10):
+        db = DirectButton(parent = dl,
+                          image = 'models/maps/noise.rgb',
+                          geom = smiley,
+                          text = ('Hi!', 'Ouch!', 'Bye!', 'ZZZZ!'),
+                          scale = .15, relief = 'raised',
+                          # Here we set an option for a component of the button
+                          geom1_color = Vec4(1,0,0,1),
+                          # Here is an example of a component group option
+                          text_pos = (.6, -.8),
+                          # Set audio characteristics
+                          clickSound = getDefaultClickSound(),
+                          rolloverSound = getDefaultRolloverSound()
+                          )
+
+        # You can set component or component group options after a gui item
+        # has been created
+        db['text_scale'] = 0.5
+        db['command'] = lambda i = i: dummyCmd(i)
+
+        # Bind the commands
+        db.bind(ENTER, lambda x, db = db: shrink(db))
+        db.bind(EXIT, lambda x, db = db: expand(db))
+        db.bind(B1PRESS, lambda x, db = db: ouch(db))
+        # Pop up placer when button 2 is pressed
+        db.bind(B3PRESS, lambda x, db = db: db.place())
+
+        dbArray.append(db)
+    
+        # To get rid of button and clear out hooks call:
+        # db.destroy()
+
+    # DIRECT ENTRY EXAMPLE
+    def printEntryText(text):
+        print 'Text:', text
+
+    # Here we create an entry, and specify everything up front
+    # CALL de1.get() and de1.set('new text') to get and set entry contents
+    de1 = DirectEntry(initialText = 'Hello, how are you?',
                       image = 'models/maps/noise.rgb',
-                      geom = smiley,
-                      text = ('Hi!', 'Ouch!', 'Bye!', 'ZZZZ!'),
-                      scale = .15, relief = 'raised',
-                      # Here we set an option for a component of the button
-                      geom1_color = Vec4(1,0,0,1),
-                      # Here is an example of a component group option
-                      text_pos = (.6, -.8),
-                      # Set audio characteristics
-                      clickSound = getDefaultClickSound(),
-                      rolloverSound = getDefaultRolloverSound()
+                      image_pos = (4.55, 0, -2.55),
+                      image_scale = (5.5, 1, 4),
+                      command = printEntryText,
+                      pos = (-1.1875, 0, 0.879167),
+                      scale = 0.0707855,
+                      cursorKeys = 1,
                       )
 
-    # You can set component or component group options after a gui item
-    # has been created
-    db['text_scale'] = 0.5
-    db['command'] = lambda i = i: dummyCmd(i)
+    # DIRECT DIALOG EXAMPLE
+    def printDialogValue(value):
+        print 'Value:', value
 
-    # Bind the commands
-    db.bind(ENTER, lambda x, db = db: shrink(db))
-    db.bind(EXIT, lambda x, db = db: expand(db))
-    db.bind(B1PRESS, lambda x, db = db: ouch(db))
-    # Pop up placer when button 2 is pressed
-    db.bind(B3PRESS, lambda x, db = db: db.place())
+    simpleDialog = YesNoDialog(text = 'Simple',
+                               command = printDialogValue)
 
-    dbArray.append(db)
-    
-    # To get rid of button and clear out hooks call:
-    # db.destroy()
-
-# DIRECT ENTRY EXAMPLE
-def printEntryText(text):
-    print 'Text:', text
-
-# Here we create an entry, and specify everything up front
-# CALL de1.get() and de1.set('new text') to get and set entry contents
-de1 = DirectEntry(initialText = 'Hello, how are you?',
-                  image = 'models/maps/noise.rgb',
-                  image_pos = (4.55, 0, -2.55),
-                  image_scale = (5.5, 1, 4),
-                  command = printEntryText,
-                  pos = (-1.1875, 0, 0.879167),
-                  scale = 0.0707855,
-                  cursorKeys = 1,
-                  )
-
-# DIRECT DIALOG EXAMPLE
-def printDialogValue(value):
-    print 'Value:', value
-
-simpleDialog = YesNoDialog(text = 'Simple',
-                           command = printDialogValue)
-
-customValues = YesNoDialog(text = 'Not Quite So Simple',
-                           buttonValueList = ['Yes', 'No'],
-                           command = printDialogValue)
-
-
-fancyDialog = YesNoDialog(text = 'Testing Direct Dialog',
-                          geom = smiley,
-                          geom_scale = .1,
-                          geom_pos = (-0.3,0,0),
-                          command = printDialogValue)
+    customValues = YesNoDialog(text = 'Not Quite So Simple',
+                               buttonValueList = ['Yes', 'No'],
+                               command = printDialogValue)
+
+
+    fancyDialog = YesNoDialog(text = 'Testing Direct Dialog',
+                              geom = smiley,
+                              geom_scale = .1,
+                              geom_pos = (-0.3,0,0),
+                              command = printDialogValue)
 
-customDialog = DirectDialog(text = 'Pick a number',
-                            buttonTextList = map(str, range(10)),
-                            buttonValueList = range(10),
-                            command = printDialogValue)
+    customDialog = DirectDialog(text = 'Pick a number',
+                                buttonTextList = map(str, range(10)),
+                                buttonValueList = range(10),
+                                command = printDialogValue)
 
 
 
-# NOTE: There are some utility functions which help you get size
-# of a direct gui widget.  These can be used to position and scale an
-# image after you've created the entry.  scale = (width/2, 1, height/2)
-print 'BOUNDS:', de1.getBounds()
-print 'WIDTH:', de1.getWidth()
-print 'HEIGHT:', de1.getHeight()
-print 'CENTER:', de1.getCenter()
+    # NOTE: There are some utility functions which help you get size
+    # of a direct gui widget.  These can be used to position and scale an
+    # image after you've created the entry.  scale = (width/2, 1, height/2)
+    print 'BOUNDS:', de1.getBounds()
+    print 'WIDTH:', de1.getWidth()
+    print 'HEIGHT:', de1.getHeight()
+    print 'CENTER:', de1.getCenter()
 
+    run()

+ 201 - 198
direct/src/interval/IntervalTest.py

@@ -1,201 +1,204 @@
-from pandac.PandaModules import *
-from direct.showbase.ShowBaseGlobal import *
-from IntervalGlobal import *
-from direct.actor.Actor import *
 
-from direct.directutil import Mopath
-
-boat = loader.loadModel('models/misc/smiley')
-boat.reparentTo(render)
-
-donald = Actor()
-donald.loadModel("phase_6/models/char/donald-wheel-1000")
-donald.loadAnims({"steer":"phase_6/models/char/donald-wheel-wheel"})
-donald.reparentTo(boat)
-
-dock = loader.loadModel('models/misc/smiley')
-dock.reparentTo(render)
-
-sound = loader.loadSfx('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
-foghorn = loader.loadSfx('phase_6/audio/sfx/SZ_DD_foghorn.mp3')
-
-mp = Mopath.Mopath()
-mp.loadFile(Filename('phase_6/paths/dd-e-w'))
-
-# Set up the boat
-boatMopath = MopathInterval(mp, boat, 'boatpath')
-boatTrack = Track([boatMopath], 'boattrack')
-BOAT_START = boatTrack.getIntervalStartTime('boatpath')
-BOAT_END = boatTrack.getIntervalEndTime('boatpath')
-
-# This will create an anim interval that is posed every frame
-donaldSteerInterval = ActorInterval(donald, 'steer')
-# This will create an anim interval that is started at t = 0 and then
-# loops for 10 seconds
-donaldLoopInterval = ActorInterval(donald, 'steer', loop=1, duration = 10.0)
-donaldSteerTrack = Track([donaldSteerInterval, donaldLoopInterval],
-                         name = 'steerTrack')
-
-# Make the dock lerp up so that it's up when the boat reaches the end of
-# its mopath
-dockLerp = LerpPosHprInterval(dock, 5.0, 
-                              pos=Point3(0, 0, -5), 
-                              hpr=Vec3(0, 0, 0), 
-                              name='dock-lerp')
-# We need the dock's state to be defined before the lerp
-dockPos = PosHprInterval(dock, dock.getPos(), dock.getHpr(), 1.0, 'dockpos')
-dockUpTime = BOAT_END - dockLerp.getDuration()
-hpr2 = Vec3(90.0, 90.0, 90.0)
-dockLerp2 = LerpHprInterval(dock, 3.0, hpr2, name='hpr-lerp')
-dockTrack = Track([dockLerp2, dockPos, dockLerp], 'docktrack')
-dockTrack.setIntervalStartTime('dock-lerp', dockUpTime)
-dockTrack.setIntervalStartTime('hpr-lerp', BOAT_START)
-
-# Start the water sound 5 seconds after the boat starts moving
-waterStartTime = BOAT_START + 5.0
-waterSound = SoundInterval(sound, name='watersound')
-soundTrack = Track([waterSound], 'soundtrack')
-soundTrack.setIntervalStartTime('watersound', waterStartTime)
-
-# Throw an event when the water track ends
-eventTime = soundTrack.getIntervalEndTime('watersound')
-waterDone = EventInterval('water-is-done')
-waterEventTrack = Track([waterDone])
-waterEventTrack.setIntervalStartTime('water-is-done', eventTime)
-
-def handleWaterDone():
-    print 'water is done'
-
-# Interval can handle its own event
-messenger.accept('water-is-done', waterDone, handleWaterDone)
-
-foghornStartTime = BOAT_START + 4.0
-foghornSound = SoundInterval(foghorn, name='foghorn')
-soundTrack2 = Track([(foghornStartTime, foghornSound)], 'soundtrack2')
-
-mtrack = MultiTrack([boatTrack, dockTrack, soundTrack, soundTrack2, waterEventTrack,
-                     donaldSteerTrack])
-# Print out MultiTrack parameters
-print(mtrack)
-
-### Using lambdas and functions ###
-# Using a lambda
-i1 = FunctionInterval(lambda: base.transitions.fadeOut())
-i2 = FunctionInterval(lambda: base.transitions.fadeIn())
-
-def caughtIt():
-    print 'Caught here-is-an-event'
-
-class DummyAcceptor(DirectObject):
-    pass
-
-da = DummyAcceptor()
-i3 = AcceptInterval(da, 'here-is-an-event', caughtIt)
-
-i4 = EventInterval('here-is-an-event')
-
-i5 = IgnoreInterval(da, 'here-is-an-event')
-
-# Using a function
-def printDone():
-    print 'done'
-
-i6 = FunctionInterval(printDone)
-
-# Create track
-t1 = Track([
-    # Fade out
-    (0.0, i1),
-    # Fade in
-    (2.0, i2),
-    # Accept event
-    (4.0, i3),
-    # Throw it,
-    (5.0, i4),
-    # Ignore event
-    (6.0, i5),
-    # Throw event again and see if ignore worked
-    (7.0, i4),
-    # Print done
-    (8.0, i6)], name = 'demo')
-
-print(t1)
-
-### Specifying interval start times during track construction ###
-# Interval start time can be specified relative to three different points:
-# PREVIOUS_END
-# PREVIOUS_START
-# TRACK_START
-
-startTime = 0.0
-def printStart():
-    global startTime
-    startTime = globalClock.getFrameTime()
-    print 'Start'
-
-def printPreviousStart():
-    global startTime
-    currTime = globalClock.getFrameTime()
-    print 'PREVIOUS_END %0.2f' % (currTime - startTime)
-
-def printPreviousEnd():
-    global startTime
-    currTime = globalClock.getFrameTime()
-    print 'PREVIOUS_END %0.2f' % (currTime - startTime)
-
-def printTrackStart():
-    global startTime
-    currTime = globalClock.getFrameTime()
-    print 'TRACK_START %0.2f' % (currTime - startTime)
-
-def printArguments(a,b,c):
-    print 'My args were %d, %d, %d' % (a,b,c)
-
-i1 = FunctionInterval(printStart)
-# Just to take time
-i2 = LerpPosInterval(camera, 2.0, Point3(0,10,5))
-# This will be relative to end of camera move
-i3 = FunctionInterval(printPreviousEnd)
-# Just to take time
-i4 = LerpPosInterval(camera, 2.0, Point3(0,0,5))
-# This will be relative to the start of the camera move
-i5 = FunctionInterval(printPreviousStart)
-# This will be relative to track start
-i6 = FunctionInterval(printTrackStart)
-# This will print some arguments
-# This will be relative to track start
-i7 = FunctionInterval(printArguments, extraArgs = [1,10,100])
-# Create the track, if you don't specify offset type in tuple it defaults to
-# relative to TRACK_START (first entry below)
-t2 = Track([(0.0, i1),                 # i1 start at t = 0, duration = 0.0
-            (1.0, i2, TRACK_START),    # i2 start at t = 1, duration = 2.0
-            (2.0, i3, PREVIOUS_END),   # i3 start at t = 5, duration = 0.0
-            (1.0, i4, PREVIOUS_END),   # i4 start at t = 6, duration = 2.0
-            (3.0, i5, PREVIOUS_START), # i5 start at t = 9, duration = 0.0
-            (10.0, i6, TRACK_START),   # i6 start at t = 10, duration = 0.0
-            (12.0, i7)],               # i7 start at t = 12, duration = 0.0
-           name = 'startTimeDemo')
-
-print(t2)
-
-# Play tracks
-# mtrack.play()
-# t1.play()
-# t2.play()
-
-
-def test(n):
-    lerps = []
-    for i in range(n):
-        lerps.append(LerpPosHprInterval(dock, 5.0, 
-                                        pos=Point3(0, 0, -5), 
-                                        hpr=Vec3(0, 0, 0),
-                                        startPos=dock.getPos(),
-                                        startHpr=dock.getHpr(),
-                                        name='dock-lerp'))
-        lerps.append(EventInterval("joe"))
-    t = Track(lerps)
-    mt = MultiTrack([t])
-    # return mt
+if __name__ == "__main__":
+    from direct.directbase import DirectStart
+    from pandac.PandaModules import *
+    from IntervalGlobal import *
+    from direct.actor.Actor import *
 
+    from direct.directutil import Mopath
+    
+    boat = loader.loadModel('models/misc/smiley')
+    boat.reparentTo(render)
+    
+    donald = Actor()
+    donald.loadModel("phase_6/models/char/donald-wheel-1000")
+    donald.loadAnims({"steer":"phase_6/models/char/donald-wheel-wheel"})
+    donald.reparentTo(boat)
+    
+    dock = loader.loadModel('models/misc/smiley')
+    dock.reparentTo(render)
+    
+    sound = loader.loadSfx('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
+    foghorn = loader.loadSfx('phase_6/audio/sfx/SZ_DD_foghorn.mp3')
+    
+    mp = Mopath.Mopath()
+    mp.loadFile(Filename('phase_6/paths/dd-e-w'))
+    
+    # Set up the boat
+    boatMopath = MopathInterval(mp, boat, 'boatpath')
+    boatTrack = Track([boatMopath], 'boattrack')
+    BOAT_START = boatTrack.getIntervalStartTime('boatpath')
+    BOAT_END = boatTrack.getIntervalEndTime('boatpath')
+    
+    # This will create an anim interval that is posed every frame
+    donaldSteerInterval = ActorInterval(donald, 'steer')
+    # This will create an anim interval that is started at t = 0 and then
+    # loops for 10 seconds
+    donaldLoopInterval = ActorInterval(donald, 'steer', loop=1, duration = 10.0)
+    donaldSteerTrack = Track([donaldSteerInterval, donaldLoopInterval],
+                             name = 'steerTrack')
+    
+    # Make the dock lerp up so that it's up when the boat reaches the end of
+    # its mopath
+    dockLerp = LerpPosHprInterval(dock, 5.0, 
+                                  pos=Point3(0, 0, -5), 
+                                  hpr=Vec3(0, 0, 0), 
+                                  name='dock-lerp')
+    # We need the dock's state to be defined before the lerp
+    dockPos = PosHprInterval(dock, dock.getPos(), dock.getHpr(), 1.0, 'dockpos')
+    dockUpTime = BOAT_END - dockLerp.getDuration()
+    hpr2 = Vec3(90.0, 90.0, 90.0)
+    dockLerp2 = LerpHprInterval(dock, 3.0, hpr2, name='hpr-lerp')
+    dockTrack = Track([dockLerp2, dockPos, dockLerp], 'docktrack')
+    dockTrack.setIntervalStartTime('dock-lerp', dockUpTime)
+    dockTrack.setIntervalStartTime('hpr-lerp', BOAT_START)
+    
+    # Start the water sound 5 seconds after the boat starts moving
+    waterStartTime = BOAT_START + 5.0
+    waterSound = SoundInterval(sound, name='watersound')
+    soundTrack = Track([waterSound], 'soundtrack')
+    soundTrack.setIntervalStartTime('watersound', waterStartTime)
+    
+    # Throw an event when the water track ends
+    eventTime = soundTrack.getIntervalEndTime('watersound')
+    waterDone = EventInterval('water-is-done')
+    waterEventTrack = Track([waterDone])
+    waterEventTrack.setIntervalStartTime('water-is-done', eventTime)
+    
+    def handleWaterDone():
+        print 'water is done'
+    
+    # Interval can handle its own event
+    messenger.accept('water-is-done', waterDone, handleWaterDone)
+    
+    foghornStartTime = BOAT_START + 4.0
+    foghornSound = SoundInterval(foghorn, name='foghorn')
+    soundTrack2 = Track([(foghornStartTime, foghornSound)], 'soundtrack2')
+    
+    mtrack = MultiTrack([boatTrack, dockTrack, soundTrack, soundTrack2, waterEventTrack,
+                         donaldSteerTrack])
+    # Print out MultiTrack parameters
+    print(mtrack)
+    
+    ### Using lambdas and functions ###
+    # Using a lambda
+    i1 = FunctionInterval(lambda: base.transitions.fadeOut())
+    i2 = FunctionInterval(lambda: base.transitions.fadeIn())
+    
+    def caughtIt():
+        print 'Caught here-is-an-event'
+    
+    class DummyAcceptor(DirectObject):
+        pass
+    
+    da = DummyAcceptor()
+    i3 = AcceptInterval(da, 'here-is-an-event', caughtIt)
+    
+    i4 = EventInterval('here-is-an-event')
+    
+    i5 = IgnoreInterval(da, 'here-is-an-event')
+    
+    # Using a function
+    def printDone():
+        print 'done'
+    
+    i6 = FunctionInterval(printDone)
+    
+    # Create track
+    t1 = Track([
+        # Fade out
+        (0.0, i1),
+        # Fade in
+        (2.0, i2),
+        # Accept event
+        (4.0, i3),
+        # Throw it,
+        (5.0, i4),
+        # Ignore event
+        (6.0, i5),
+        # Throw event again and see if ignore worked
+        (7.0, i4),
+        # Print done
+        (8.0, i6)], name = 'demo')
+    
+    print(t1)
+    
+    ### Specifying interval start times during track construction ###
+    # Interval start time can be specified relative to three different points:
+    # PREVIOUS_END
+    # PREVIOUS_START
+    # TRACK_START
+    
+    startTime = 0.0
+    def printStart():
+        global startTime
+        startTime = globalClock.getFrameTime()
+        print 'Start'
+    
+    def printPreviousStart():
+        global startTime
+        currTime = globalClock.getFrameTime()
+        print 'PREVIOUS_END %0.2f' % (currTime - startTime)
+    
+    def printPreviousEnd():
+        global startTime
+        currTime = globalClock.getFrameTime()
+        print 'PREVIOUS_END %0.2f' % (currTime - startTime)
+    
+    def printTrackStart():
+        global startTime
+        currTime = globalClock.getFrameTime()
+        print 'TRACK_START %0.2f' % (currTime - startTime)
+    
+    def printArguments(a,b,c):
+        print 'My args were %d, %d, %d' % (a,b,c)
+    
+    i1 = FunctionInterval(printStart)
+    # Just to take time
+    i2 = LerpPosInterval(camera, 2.0, Point3(0,10,5))
+    # This will be relative to end of camera move
+    i3 = FunctionInterval(printPreviousEnd)
+    # Just to take time
+    i4 = LerpPosInterval(camera, 2.0, Point3(0,0,5))
+    # This will be relative to the start of the camera move
+    i5 = FunctionInterval(printPreviousStart)
+    # This will be relative to track start
+    i6 = FunctionInterval(printTrackStart)
+    # This will print some arguments
+    # This will be relative to track start
+    i7 = FunctionInterval(printArguments, extraArgs = [1,10,100])
+    # Create the track, if you don't specify offset type in tuple it defaults to
+    # relative to TRACK_START (first entry below)
+    t2 = Track([(0.0, i1),                 # i1 start at t = 0, duration = 0.0
+                (1.0, i2, TRACK_START),    # i2 start at t = 1, duration = 2.0
+                (2.0, i3, PREVIOUS_END),   # i3 start at t = 5, duration = 0.0
+                (1.0, i4, PREVIOUS_END),   # i4 start at t = 6, duration = 2.0
+                (3.0, i5, PREVIOUS_START), # i5 start at t = 9, duration = 0.0
+                (10.0, i6, TRACK_START),   # i6 start at t = 10, duration = 0.0
+                (12.0, i7)],               # i7 start at t = 12, duration = 0.0
+               name = 'startTimeDemo')
+    
+    print(t2)
+    
+    # Play tracks
+    # mtrack.play()
+    # t1.play()
+    # t2.play()
+    
     
+    def test(n):
+        lerps = []
+        for i in range(n):
+            lerps.append(LerpPosHprInterval(dock, 5.0, 
+                                            pos=Point3(0, 0, -5), 
+                                            hpr=Vec3(0, 0, 0),
+                                            startPos=dock.getPos(),
+                                            startHpr=dock.getHpr(),
+                                            name='dock-lerp'))
+            lerps.append(EventInterval("joe"))
+        t = Track(lerps)
+        mt = MultiTrack([t])
+        # return mt
+
+    test(5)
+    run()

+ 4 - 4
direct/src/interval/ProjectileIntervalTest.py

@@ -2,13 +2,13 @@ from pandac.PandaModules import *
 from direct.directbase.DirectStart import *
 from IntervalGlobal import *
 
-smiley = loader.loadModel('models/misc/smiley')
-smiley.reparentTo(render)
-
 def doTest():
+    smiley = loader.loadModel('models/misc/smiley')
+    smiley.reparentTo(render)
+
     pi = ProjectileInterval(smiley, startPos=Point3(0,0,0),
                             endZ = -10, wayPoint=Point3(10,0,0),
                             timeToWayPoint=3)
     pi.loop()
     return pi
-    
+

+ 8 - 6
direct/src/particles/ParticleFloorTest.py

@@ -1,4 +1,4 @@
-from direct.directbase.TestStart import *
+from pandac.PandaModules import *
 from direct.particles import ParticleEffect
 from direct.particles import Particles
 from direct.particles import ForceGroup
@@ -45,8 +45,10 @@ class ParticleFloorTest(NodePath):
     def start(self):
         self.f.enable()
 
-pt=ParticleFloorTest()
-pt.reparentTo(render)
-pt.start()
-camera.setY(-10.0)
-run()
+if __name__ == "__main__":
+    from direct.directbase.TestStart import *
+    pt=ParticleFloorTest()
+    pt.reparentTo(render)
+    pt.start()
+    camera.setY(-10.0)
+    run()

+ 30 - 21
direct/src/particles/ParticleTest.py

@@ -1,24 +1,33 @@
-from direct.directbase.TestStart import *
 
-from pandac.LinearVectorForce import LinearVectorForce
-from pandac.Vec3 import Vec3
-import ParticleEffect
-from direct.tkpanels import ParticlePanel
-import ForceGroup
+if __name__ == "__main__":
+    from direct.directbase.TestStart import *
+    
+    from pandac.LinearVectorForce import LinearVectorForce
+    from pandac.Vec3 import Vec3
+    import ParticleEffect
+    from direct.tkpanels import ParticlePanel
+    import Particles
+    import ForceGroup
+    
+    # Showbase
+    base.enableParticles()
+    
+    # ForceGroup
+    fg = ForceGroup.ForceGroup()
+    gravity = LinearVectorForce(Vec3(0.0, 0.0, -10.0))
+    fg.addForce(gravity)
+    
+    # Particles
+    p = Particles.Particles()
 
-# Showbase
-base.enableParticles()
+    # Particle effect
+    pe = ParticleEffect.ParticleEffect('particle-fx')
+    pe.reparentTo(render)
+    #pe.setPos(0.0, 5.0, 4.0)
+    pe.addForceGroup(fg)
+    pe.addParticles(p)
+    
+    # Particle Panel
+    pp = ParticlePanel.ParticlePanel(pe)
 
-# ForceGroup
-fg = ForceGroup.ForceGroup()
-gravity = LinearVectorForce(Vec3(0.0, 0.0, -10.0))
-fg.addForce(gravity)
-
-# Particle effect
-pe = ParticleEffect.ParticleEffect('particle-fx')
-pe.reparentTo(render)
-#pe.setPos(0.0, 5.0, 4.0)
-pe.addForceGroup(fg)
-
-# Particle Panel
-pp = ParticlePanel.ParticlePanel(pe)
+    run()

+ 7 - 6
direct/src/physics/FallTest.py

@@ -1,4 +1,3 @@
-from direct.directbase.ThreeUpStart import *
 
 class FallTest(NodePath):
     def __init__(self):
@@ -77,8 +76,10 @@ class FallTest(NodePath):
         #self.actorNode.getPhysicsObject().resetPosition(self.avatarNodePath.getPos())
         #self.actorNode.updateTransform()
 
-test=FallTest()
-test.reparentTo(render)
-test.setup()
-camera.setY(-10.0)
-run()
+if __name__ == "__main__":
+    from direct.directbase.ThreeUpStart import *
+    test=FallTest()
+    test.reparentTo(render)
+    test.setup()
+    camera.setY(-10.0)
+    run()

+ 7 - 6
direct/src/physics/RotationTest.py

@@ -1,4 +1,3 @@
-from direct.directbase.ThreeUpStart import *
 
 class RotationTest(NodePath):
     def __init__(self):
@@ -87,8 +86,10 @@ class RotationTest(NodePath):
         #self.actorNode.getPhysicsObject().resetPosition(self.avatarNodePath.getPos())
         #self.actorNode.updateTransform()
 
-test=RotationTest()
-test.reparentTo(render)
-test.setup()
-camera.setY(-10.0)
-run()
+if __name__ == "__main__":
+    from direct.directbase.ThreeUpStart import *
+    test=RotationTest()
+    test.reparentTo(render)
+    test.setup()
+    camera.setY(-10.0)
+    run()

+ 2 - 2
direct/src/pyinst/mkarchive.py

@@ -1,4 +1,4 @@
-import MkWrap
+#import MkWrap
 import imputil
 import strop
 import zlib
@@ -39,4 +39,4 @@ class MkImporter:
             f.seek(8)
             obj = zlib.compress(f.read(), 9)
             row.code = obj
-        self.db.commit()
+        self.db.commit()

+ 46 - 45
direct/src/showbase/pandaSqueezer.py

@@ -5,48 +5,49 @@ import pandaSqueezeTool
 
 # Assumption: We will be squeezing the files from the current directory or the -d directory.
 
-try:
-    opts, pargs = getopt.getopt(sys.argv[1:], 'Od:')
-except Exception, e:
-    # User passed in a bad option, print the error and the help, then exit
-    print e
-    print 'Usage: pass in -O for optimized'
-    print '       pass in -d directory'
-    sys.exit()
-
-fOptimized = 0
-# Store the option values into our variables
-for opt in opts:
-    flag, value = opt
-    if (flag == '-O'):
-        fOptimized = 1
-        print 'Squeezing pyo files'
-    elif (flag == '-d'):
-        os.chdir(value)
-
-def getSqueezeableFiles():
-    fileList = os.listdir(".")
-    newFileList = []
-    if fOptimized:
-        targetFileExtension = ".pyo"
-    else:
-        targetFileExtension = ".pyc"
-    for i in fileList:
-        base,ext = os.path.splitext(i)
-        if (ext == ".py"):
-            newFileList.append(i)
-    return newFileList
-
-def squeezePandaFiles():
-    l = getSqueezeableFiles()
-    pandaSqueezeTool.squeeze("PandaModules", "PandaModulesUnsqueezed", l)
-
-    # Clean up the source files now that they've been squeezed.  If
-    # you don't like this behavior (e.g. if you want to inspect the
-    # generated files), use genPyCode -n to avoid squeezing
-    # altogether.
-    for i in l:
-        os.unlink(i)
-
-
-squeezePandaFiles()
+if __name__ == "__main__":
+    try:
+        opts, pargs = getopt.getopt(sys.argv[1:], 'Od:')
+    except Exception, e:
+        # User passed in a bad option, print the error and the help, then exit
+        print e
+        print 'Usage: pass in -O for optimized'
+        print '       pass in -d directory'
+        sys.exit()
+    
+    fOptimized = 0
+    # Store the option values into our variables
+    for opt in opts:
+        flag, value = opt
+        if (flag == '-O'):
+            fOptimized = 1
+            print 'Squeezing pyo files'
+        elif (flag == '-d'):
+            os.chdir(value)
+    
+    def getSqueezeableFiles():
+        fileList = os.listdir(".")
+        newFileList = []
+        if fOptimized:
+            targetFileExtension = ".pyo"
+        else:
+            targetFileExtension = ".pyc"
+        for i in fileList:
+            base,ext = os.path.splitext(i)
+            if (ext == ".py"):
+                newFileList.append(i)
+        return newFileList
+    
+    def squeezePandaFiles():
+        l = getSqueezeableFiles()
+        pandaSqueezeTool.squeeze("PandaModules", "PandaModulesUnsqueezed", l)
+    
+        # Clean up the source files now that they've been squeezed.  If
+        # you don't like this behavior (e.g. if you want to inspect the
+        # generated files), use genPyCode -n to avoid squeezing
+        # altogether.
+        for i in l:
+            os.unlink(i)
+    
+    
+    squeezePandaFiles()