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

This commit is contained in:
David Rose 2005-04-28 17:59:00 +00:00
parent d4ba21fc11
commit 468fb19220
11 changed files with 424 additions and 404 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
import MkWrap #import MkWrap
import imputil import imputil
import strop import strop
import zlib import zlib

View File

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