PandaObject to DirectObject

This commit is contained in:
Dave Schuyler 2005-12-20 22:51:18 +00:00
parent 6f16cdb12e
commit 8900f25533
19 changed files with 279 additions and 275 deletions

View File

@ -1,6 +1,6 @@
""" Class used to create and control radamec device """ """ Class used to create and control radamec device """
from math import * from math import *
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectDeviceManager import * from DirectDeviceManager import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal

View File

@ -1,5 +1,5 @@
""" Class used to create and control joybox device """ """ Class used to create and control joybox device """
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectDeviceManager import * from DirectDeviceManager import *
from direct.directtools.DirectUtil import * from direct.directtools.DirectUtil import *
from direct.gui import OnscreenText from direct.gui import OnscreenText

View File

@ -1,6 +1,6 @@
""" Class used to create and control radamec device """ """ Class used to create and control radamec device """
from math import * from math import *
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectDeviceManager import * from DirectDeviceManager import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal

View File

@ -1,4 +1,4 @@
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectUtil import * from DirectUtil import *
from DirectGeometry import * from DirectGeometry import *
from DirectGlobals import * from DirectGlobals import *

View File

@ -1,4 +1,4 @@
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectGlobals import * from DirectGlobals import *
from DirectUtil import * from DirectUtil import *
from DirectGeometry import * from DirectGeometry import *

View File

@ -1,4 +1,4 @@
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectGlobals import * from DirectGlobals import *
from DirectUtil import * from DirectUtil import *
from DirectGeometry import * from DirectGeometry import *

View File

@ -1,4 +1,4 @@
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from DirectGlobals import * from DirectGlobals import *
from DirectUtil import* from DirectUtil import*
from DirectCameraControl import * from DirectCameraControl import *

View File

@ -1,4 +1,4 @@
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from direct.directtools.DirectGeometry import * from direct.directtools.DirectGeometry import *
from pandac.PandaModules import NodePath from pandac.PandaModules import NodePath

View File

@ -4,7 +4,8 @@ This module and class exist only for backward compatibility with
existing code. New code should use the FSM module instead. existing code. New code should use the FSM module instead.
""" """
from direct.showbase.DirectObject import * from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
import types import types
import weakref import weakref

View File

@ -1,7 +1,8 @@
"""State module: contains State class""" """State module: contains State class"""
from direct.showbase.DirectObject import * from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
import types import types
# This gets set by a dconfig variable in ShowBase.py # This gets set by a dconfig variable in ShowBase.py

View File

@ -1,7 +1,8 @@
"""StateData module: contains StateData class""" """StateData module: contains StateData class"""
from direct.showbase.DirectObject import * from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
@ -11,7 +12,7 @@ class StateData(DirectObject):
State Machine (ClassicFSM). State Machine (ClassicFSM).
""" """
notify = DirectNotifyGlobal.directNotify.newCategory('StateData') notify = directNotify.newCategory('StateData')
def __init__(self, doneEvent): def __init__(self, doneEvent):
self.doneEvent = doneEvent self.doneEvent = doneEvent

View File

@ -2,7 +2,7 @@
from pandac.PandaModules import * from pandac.PandaModules import *
from direct.showbase.MessengerGlobal import * from direct.showbase.MessengerGlobal import *
from direct.directnotify.DirectNotifyGlobal import * from direct.directnotify.DirectNotifyGlobal import directNotify
import Interval import Interval
import types import types

View File

@ -1,6 +1,7 @@
"""Interval module: contains the Interval class""" """Interval module: contains the Interval class"""
from direct.showbase.DirectObject import * from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import * from pandac.PandaModules import *
from direct.task import Task from direct.task import Task
from direct.showbase import PythonUtil from direct.showbase import PythonUtil

View File

@ -1,5 +1,5 @@
from pandac.PandaModules import * from pandac.PandaModules import *
from direct.showbase.DirectObject import * from direct.showbase.DirectObject import DirectObject
from direct.showbase.PhysicsManagerGlobal import * from direct.showbase.PhysicsManagerGlobal import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal

View File

@ -1,8 +1,8 @@
from DirectObject import * ## from DirectObject import *
from pandac.PandaModules import * ## from pandac.PandaModules import *
##
class PandaObject(DirectObject): ## class PandaObject(DirectObject):
""" ## """
This is the class that all Panda/Show classes should inherit from ## This is the class that all Panda/Show classes should inherit from
""" ## """
pass ## pass

View File

@ -54,9 +54,9 @@ import base64, imp, marshal, os, string, sys, md5
# usage # usage
def usage(): def usage():
print print
print "SQUEEZE", VERSION, "(c) 1997-1998 by Secret Labs AB" print "SQUEEZE", VERSION, "(c) 1997-1998 by Secret Labs AB"
print """\ print """\
Convert a Python application to a compressed module package. Convert a Python application to a compressed module package.
Usage: squeeze [-1ux] -o app [-b start] modules... [-d files...] Usage: squeeze [-1ux] -o app [-b start] modules... [-d files...]
@ -84,7 +84,7 @@ The -x option can be used with -d to create a self-extracting archive,
instead of a package. When the resulting script is executed, the instead of a package. When the resulting script is executed, the
data files are extracted. Omit the -b option in this case. data files are extracted. Omit the -b option in this case.
""" """
sys.exit(1) sys.exit(1)
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -92,44 +92,44 @@ data files are extracted. Omit the -b option in this case.
class Squeezer: class Squeezer:
def __init__(self): def __init__(self):
self.rawbytes = self.bytes = 0 self.rawbytes = self.bytes = 0
self.modules = {} self.modules = {}
def addmodule(self, file): def addmodule(self, file):
if file[-1] == "c": if file[-1] == "c":
file = file[:-1] file = file[:-1]
m = os.path.splitext(os.path.split(file)[1])[0] m = os.path.splitext(os.path.split(file)[1])[0]
# read sourcefile # read sourcefile
f = open(file) f = open(file)
codestring = f.read() codestring = f.read()
f.close() f.close()
# dump to file # dump to file
self.modules[m] = compile(codestring, m, "exec") self.modules[m] = compile(codestring, m, "exec")
def adddata(self, file): def adddata(self, file):
self.modules["+"+file] = open(file, "rb").read() self.modules["+"+file] = open(file, "rb").read()
def getarchive(self): def getarchive(self):
# marshal our module dictionary # marshal our module dictionary
data = marshal.dumps(self.modules) data = marshal.dumps(self.modules)
self.rawbytes = len(data) self.rawbytes = len(data)
# return (compressed) dictionary # return (compressed) dictionary
data = zlib.compress(data, 9) data = zlib.compress(data, 9)
self.bytes = len(data) self.bytes = len(data)
return data return data
def getstatus(self): def getstatus(self):
return self.bytes, self.rawbytes return self.bytes, self.rawbytes
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -217,22 +217,22 @@ def explode():
def getloader(data, package): def getloader(data, package):
s = loader s = loader
if data: if data:
if explode: if explode:
s = s + loaderexplode s = s + loaderexplode
else: else:
s = s + loaderopen s = s + loaderopen
dict = { dict = {
"modules": "marshal, zlib", "modules": "marshal, zlib",
"data": "zlib.decompress(data)", "data": "zlib.decompress(data)",
} }
s = s % dict s = s % dict
return marshal.dumps(compile(s, "<package>", "exec")) return marshal.dumps(compile(s, "<package>", "exec"))
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -249,63 +249,63 @@ embed = 0
explode = 0 explode = 0
def squeeze(app, start, filelist, outputDir): def squeeze(app, start, filelist, outputDir):
localMagic = MAGIC localMagic = MAGIC
data = None data = None
bootstrap = os.path.join(outputDir, app + ".py") bootstrap = os.path.join(outputDir, app + ".py")
archiveBase = app + ".pyz" archiveBase = app + ".pyz"
archive = os.path.join(outputDir, archiveBase) archive = os.path.join(outputDir, archiveBase)
archiveid = app archiveid = app
# #
# avoid overwriting files not generated by squeeze # avoid overwriting files not generated by squeeze
try: try:
fp = open(bootstrap) fp = open(bootstrap)
s = fp.readline() s = fp.readline()
string.index(s, MAGIC) string.index(s, MAGIC)
except IOError: except IOError:
pass pass
except ValueError: except ValueError:
print bootstrap, "was not created by squeeze. You have to manually" print bootstrap, "was not created by squeeze. You have to manually"
print "remove the file to proceed." print "remove the file to proceed."
sys.exit(1) sys.exit(1)
# #
# collect modules # collect modules
sq = Squeezer() sq = Squeezer()
for file in filelist: for file in filelist:
# print 'addmodule:', file # print 'addmodule:', file
sq.addmodule(file) sq.addmodule(file)
package = sq.getarchive() package = sq.getarchive()
size = len(package) size = len(package)
# #
# get loader # get loader
loader = getloader(data, package) loader = getloader(data, package)
zbegin, zend = "zlib.decompress(", ")" zbegin, zend = "zlib.decompress(", ")"
loader = zlib.compress(loader, 9) loader = zlib.compress(loader, 9)
loaderlen = len(loader) loaderlen = len(loader)
magic = repr(imp.get_magic()) magic = repr(imp.get_magic())
version = string.split(sys.version)[0] version = string.split(sys.version)[0]
# #
# generate script and package files # generate script and package files
if embed: if embed:
# embedded archive # embedded archive
data = base64.encodestring(loader + package) data = base64.encodestring(loader + package)
fp = open(bootstrap, "w") fp = open(bootstrap, "w")
fp.write('''\ fp.write('''\
#%(localMagic)s %(archiveid)s #%(localMagic)s %(archiveid)s
import ihooks,zlib,base64,marshal import ihooks,zlib,base64,marshal
s=base64.decodestring(""" s=base64.decodestring("""
@ -314,25 +314,25 @@ exec marshal.loads(%(zbegin)ss[:%(loaderlen)d]%(zend)s)
boot("%(app)s",s,%(size)d,%(loaderlen)d) boot("%(app)s",s,%(size)d,%(loaderlen)d)
exec "import %(start)s" exec "import %(start)s"
''' % locals()) ''' % locals())
bytes = fp.tell() bytes = fp.tell()
else: else:
# separate archive file # separate archive file
fp = open(archive, "wb") fp = open(archive, "wb")
fp.write(loader) fp.write(loader)
fp.write(package) fp.write(package)
bytes = fp.tell() bytes = fp.tell()
fp.close() fp.close()
# #
# create bootstrap code # create bootstrap code
fp = open(bootstrap, "w") fp = open(bootstrap, "w")
# Note: David Rose adjusted the following to be panda-specific. # Note: David Rose adjusted the following to be panda-specific.
fp.write("""\ fp.write("""\
#%(localMagic)s %(archiveid)s #%(localMagic)s %(archiveid)s
import ihooks,zlib,marshal,os,sys import ihooks,zlib,marshal,os,sys
@ -360,13 +360,13 @@ boot("%(app)s",f,%(size)d)
exec "from %(start)s import *" exec "from %(start)s import *"
#exec "run()" #exec "run()"
""" % locals()) """ % locals())
bytes = bytes + fp.tell() bytes = bytes + fp.tell()
fp.close() fp.close()
# #
# show statistics # show statistics
dummy, rawbytes = sq.getstatus() dummy, rawbytes = sq.getstatus()
print "squeezed", rawbytes, "to", bytes, "bytes", print "squeezed", rawbytes, "to", bytes, "bytes",
print "(%d%%)" % (bytes * 100 / rawbytes) print "(%d%%)" % (bytes * 100 / rawbytes)

View File

@ -81,15 +81,15 @@ class Slider(Valuator):
class SliderWidget(Pmw.MegaWidget): class SliderWidget(Pmw.MegaWidget):
def __init__(self, parent = None, **kw): def __init__(self, parent = None, **kw):
# Define the megawidget options. # Define the megawidget options.
INITOPT = Pmw.INITOPT INITOPT = Pmw.INITOPT
optiondefs = ( optiondefs = (
# Appearance # Appearance
('style', VALUATOR_MINI, INITOPT), ('style', VALUATOR_MINI, INITOPT),
('relief', RAISED, self.setRelief), ('relief', RAISED, self.setRelief),
('borderwidth', 2, self.setBorderwidth), ('borderwidth', 2, self.setBorderwidth),
('background', 'grey75', self.setBackground), ('background', 'grey75', self.setBackground),
('fliparrow', 0, INITOPT), ('fliparrow', 0, INITOPT),
# Behavior # Behavior
# Bounds # Bounds
('min', 0.0, self.setMin), ('min', 0.0, self.setMin),
@ -106,14 +106,14 @@ class SliderWidget(Pmw.MegaWidget):
('postCallback', None, None), ('postCallback', None, None),
# Extra data to be passed to callback function, needs to be a list # Extra data to be passed to callback function, needs to be a list
('callbackData', [], None), ('callbackData', [], None),
) )
self.defineoptions(kw, optiondefs) self.defineoptions(kw, optiondefs)
# Initialise the base class (after defining the options). # Initialise the base class (after defining the options).
Pmw.MegaWidget.__init__(self, parent) Pmw.MegaWidget.__init__(self, parent)
# Create the components. # Create the components.
interior = self.interior() interior = self.interior()
# Current value # Current value
self.value = self['value'] self.value = self['value']
@ -199,36 +199,36 @@ class SliderWidget(Pmw.MegaWidget):
self._maxLabel.pack(side = LEFT) self._maxLabel.pack(side = LEFT)
# Create slider # Create slider
if self['style'] == VALUATOR_MINI: if self['style'] == VALUATOR_MINI:
# Create the arrow button to invoke slider # Create the arrow button to invoke slider
self._arrowBtn = self.createcomponent( self._arrowBtn = self.createcomponent(
'arrowbutton', 'arrowbutton',
(), None, (), None,
Canvas, (interior,), borderwidth = 0, Canvas, (interior,), borderwidth = 0,
relief = FLAT, width = 14, height = 14, relief = FLAT, width = 14, height = 14,
scrollregion = (-7,-7,7,7)) scrollregion = (-7,-7,7,7))
self._arrowBtn.pack(expand = 1, fill = BOTH) self._arrowBtn.pack(expand = 1, fill = BOTH)
self._arrowBtn.create_polygon(-5, -5, 5, -5, 0, 5, self._arrowBtn.create_polygon(-5, -5, 5, -5, 0, 5,
fill = 'grey50', fill = 'grey50',
tags = 'arrow') tags = 'arrow')
self._arrowBtn.create_line(-5, 5, 5, 5, self._arrowBtn.create_line(-5, 5, 5, 5,
fill = 'grey50', fill = 'grey50',
tags = 'arrow') tags = 'arrow')
# Create the dropdown window. # Create the dropdown window.
self._popup = self.createcomponent( self._popup = self.createcomponent(
'popup', 'popup',
(), None, (), None,
Toplevel, (interior,), Toplevel, (interior,),
relief = RAISED, borderwidth = 2) relief = RAISED, borderwidth = 2)
self._popup.withdraw() self._popup.withdraw()
self._popup.overrideredirect(1) self._popup.overrideredirect(1)
# Create popup slider # Create popup slider
createSlider(self._popup) createSlider(self._popup)
# Bind events to the arrow button. # Bind events to the arrow button.
self._arrowBtn.bind('<1>', self._postSlider) self._arrowBtn.bind('<1>', self._postSlider)
self._arrowBtn.bind('<Enter>', self.highlightWidget) self._arrowBtn.bind('<Enter>', self.highlightWidget)
self._arrowBtn.bind('<Leave>', self.restoreWidget) self._arrowBtn.bind('<Leave>', self.restoreWidget)
# Need to unpost the popup if the arrow Button is unmapped (eg: # Need to unpost the popup if the arrow Button is unmapped (eg:
@ -236,10 +236,10 @@ class SliderWidget(Pmw.MegaWidget):
# displayed. # displayed.
self._arrowBtn.bind('<Unmap>', self._unpostSlider) self._arrowBtn.bind('<Unmap>', self._unpostSlider)
# Bind events to the dropdown window. # Bind events to the dropdown window.
self._popup.bind('<Escape>', self._unpostSlider) self._popup.bind('<Escape>', self._unpostSlider)
self._popup.bind('<ButtonRelease-1>', self._widgetBtnRelease) self._popup.bind('<ButtonRelease-1>', self._widgetBtnRelease)
self._popup.bind('<ButtonPress-1>', self._widgetBtnPress) self._popup.bind('<ButtonPress-1>', self._widgetBtnPress)
self._popup.bind('<Motion>', self._widgetMove) self._popup.bind('<Motion>', self._widgetMove)
self._widget.bind('<Left>', self._decrementValue) self._widget.bind('<Left>', self._decrementValue)
@ -248,14 +248,14 @@ class SliderWidget(Pmw.MegaWidget):
self._widget.bind('<Shift-Right>', self._bigIncrementValue) self._widget.bind('<Shift-Right>', self._bigIncrementValue)
self._widget.bind('<Home>', self._goToMin) self._widget.bind('<Home>', self._goToMin)
self._widget.bind('<End>', self._goToMax) self._widget.bind('<End>', self._goToMax)
else: else:
createSlider(interior) createSlider(interior)
self._widget['command'] = self._firstScaleCommand self._widget['command'] = self._firstScaleCommand
self._widget.bind('<ButtonRelease-1>', self._scaleBtnRelease) self._widget.bind('<ButtonRelease-1>', self._scaleBtnRelease)
self._widget.bind('<ButtonPress-1>', self._scaleBtnPress) self._widget.bind('<ButtonPress-1>', self._scaleBtnPress)
# Check keywords and initialise options. # Check keywords and initialise options.
self.initialiseoptions(SliderWidget) self.initialiseoptions(SliderWidget)
# Adjust relief # Adjust relief
if not kw.has_key('relief'): if not kw.has_key('relief'):
@ -265,7 +265,7 @@ class SliderWidget(Pmw.MegaWidget):
self.updateIndicator(self['value']) self.updateIndicator(self['value'])
def destroy(self): def destroy(self):
if (self['style'] == VALUATOR_MINI) and self._isPosted: if (self['style'] == VALUATOR_MINI) and self._isPosted:
Pmw.popgrab(self._popup) Pmw.popgrab(self._popup)
Pmw.MegaWidget.destroy(self) Pmw.MegaWidget.destroy(self)
@ -416,10 +416,10 @@ class SliderWidget(Pmw.MegaWidget):
self._fPressInside = 0 self._fPressInside = 0
def _unpostOnNextRelease(self, event = None): def _unpostOnNextRelease(self, event = None):
self._fUnpost = 1 self._fUnpost = 1
def _unpostSlider(self, event=None): def _unpostSlider(self, event=None):
if not self._isPosted: if not self._isPosted:
# It is possible to get events on an unposted popup. For # It is possible to get events on an unposted popup. For
# example, by repeatedly pressing the space key to post # example, by repeatedly pressing the space key to post
# and unpost the popup. The <space> event may be # and unpost the popup. The <space> event may be
@ -433,9 +433,9 @@ class SliderWidget(Pmw.MegaWidget):
# can't redirect it. Also, return the grab to the next active # can't redirect it. Also, return the grab to the next active
# window in the stack, if any. # window in the stack, if any.
Pmw.popgrab(self._popup) Pmw.popgrab(self._popup)
self._popup.withdraw() self._popup.withdraw()
self._isPosted = 0 self._isPosted = 0
# Raise up arrow button # Raise up arrow button
self.interior()['relief'] = RAISED self.interior()['relief'] = RAISED

View File

@ -154,7 +154,7 @@ class myLevelEditor(AppShell):
self.initialiseoptions(myLevelEditor) self.initialiseoptions(myLevelEditor)
self.parent.resizable(False,False) ## Disable the ability to resize for this Window. self.parent.resizable(False,False) ## Disable the ability to resize for this Window.
######### Set the event handler ########## ######### Set the event handler ##########
self.dataFlowEvents = [ self.dataFlowEvents = [
## Event from Side Window ## Event from Side Window
@ -209,14 +209,14 @@ class myLevelEditor(AppShell):
['SEditor-ToggleBackface',self.toggleBackface], ['SEditor-ToggleBackface',self.toggleBackface],
['SEditor-ToggleTexture',self.toggleTexture], ['SEditor-ToggleTexture',self.toggleTexture],
['SEditor-ToggleWireframe',self.toggleWireframe], ['SEditor-ToggleWireframe',self.toggleWireframe],
['ParticlePanel_Added_Effect',self.addParticleEffect], ['ParticlePanel_Added_Effect',self.addParticleEffect],
] ]
################################# #################################
### Collision detection ### Collision detection
################################# #################################
self.cTrav = CollisionTraverser() self.cTrav = CollisionTraverser()
base.cTrav = self.cTrav base.cTrav = self.cTrav
for event in self.dataFlowEvents: for event in self.dataFlowEvents:
@ -230,7 +230,7 @@ class myLevelEditor(AppShell):
['SGE_Remove', self.remove], ['SGE_Remove', self.remove],
['SGE_Add Dummy', self.addDummyNode], ['SGE_Add Dummy', self.addDummyNode],
['SGE_Add Collision Object', self.addCollisionObj], ['SGE_Add Collision Object', self.addCollisionObj],
['SGE_Metadata', self.openMetadataPanel], ['SGE_Metadata', self.openMetadataPanel],
['SGE_Set as Reparent Target', self.setAsReparentTarget], ['SGE_Set as Reparent Target', self.setAsReparentTarget],
['SGE_Reparent to Target', self.reparentToNode], ['SGE_Reparent to Target', self.reparentToNode],
['SGE_Animation Panel', self.openAnimPanel], ['SGE_Animation Panel', self.openAnimPanel],
@ -262,17 +262,17 @@ class myLevelEditor(AppShell):
### Create SceneEditor Ver. DirectSession ### Create SceneEditor Ver. DirectSession
self.seSession = SeSession() self.seSession = SeSession()
self.seSession.enable() self.seSession.enable()
SEditor.camera.setPos(0,-50,10) SEditor.camera.setPos(0,-50,10)
self.placer=None self.placer=None
self.MopathPanel = None self.MopathPanel = None
self.alignPanelDict = {} self.alignPanelDict = {}
#self.quadview=QuadView() #self.quadview=QuadView()
self.lightingPanel = None self.lightingPanel = None
self.controllerPanel = None self.controllerPanel = None
self.particlePanel = None self.particlePanel = None
### Create Side Window ### Create Side Window
self.sideWindow = sideWindow(worldColor = self.worldColor, self.sideWindow = sideWindow(worldColor = self.worldColor,
@ -305,7 +305,7 @@ class myLevelEditor(AppShell):
### Creating the Buttons in the window frame ### Creating the Buttons in the window frame
####################################################### #######################################################
buttonFrame = Frame(interior) buttonFrame = Frame(interior)
self.image=[] self.image=[]
self.image.append(self.getPhotoImage('models/icons/new.gif'))#0 self.image.append(self.getPhotoImage('models/icons/new.gif'))#0
self.image.append(self.getPhotoImage('models/icons/open.gif'))#1 self.image.append(self.getPhotoImage('models/icons/open.gif'))#1
@ -327,20 +327,20 @@ class myLevelEditor(AppShell):
self.image.append(self.getPhotoImage('models/icons/blank.gif')) self.image.append(self.getPhotoImage('models/icons/blank.gif'))
self.image.append(self.getPhotoImage('models/icons/blank.gif')) self.image.append(self.getPhotoImage('models/icons/blank.gif'))
self.image.append(self.getPhotoImage('models/icons/blank.gif')) self.image.append(self.getPhotoImage('models/icons/blank.gif'))
self.image.append(self.getPhotoImage('models/icons/blank.gif')) self.image.append(self.getPhotoImage('models/icons/blank.gif'))
self.image.append(self.getPhotoImage('models/icons/blank.gif')) self.image.append(self.getPhotoImage('models/icons/blank.gif'))
self.image.append(self.getPhotoImage('models/icons/blank.gif')) self.image.append(self.getPhotoImage('models/icons/blank.gif'))
i = 0 i = 0
for element in self.image: for element in self.image:
i += 1 i += 1
button = Button(buttonFrame, image = element, command=lambda n=i : self.buttonPushed(n)) button = Button(buttonFrame, image = element, command=lambda n=i : self.buttonPushed(n))
button.pack(fill=X, side = LEFT) button.pack(fill=X, side = LEFT)
buttonFrame.pack(fill=X, side=LEFT,expand=True) buttonFrame.pack(fill=X, side=LEFT,expand=True)
def buttonPushed(self, buttonIndex): def buttonPushed(self, buttonIndex):
################################################################# #################################################################
# buttonPushed(self, buttonNum) # buttonPushed(self, buttonNum)
@ -351,8 +351,8 @@ class myLevelEditor(AppShell):
#### Change here to process the button event further. #### Change here to process the button event further.
#### ####
if buttonIndex==1: # New Scene if buttonIndex==1: # New Scene
self.newScene() self.newScene()
return return
elif buttonIndex==2: # Open Scene elif buttonIndex==2: # Open Scene
self.openScene() self.openScene()
return return
@ -369,13 +369,13 @@ class myLevelEditor(AppShell):
self.openPlacerPanel() self.openPlacerPanel()
return return
elif buttonIndex==7: # Open Mopath Panel elif buttonIndex==7: # Open Mopath Panel
self.openMoPathPanel() self.openMoPathPanel()
return return
elif buttonIndex==8: # Open Lighting Panel elif buttonIndex==8: # Open Lighting Panel
self.openLightingPanel() self.openLightingPanel()
return return
elif buttonIndex==9: # Open Particle Panel elif buttonIndex==9: # Open Particle Panel
self.openParticlePanel() self.openParticlePanel()
return return
elif buttonIndex==10: elif buttonIndex==10:
self.openInputPanel() self.openInputPanel()
@ -582,7 +582,7 @@ class myLevelEditor(AppShell):
## Processing message events ## Processing message events
def makeDirty(self): def makeDirty(self):
self.Dirty=1 self.Dirty=1
def removeLight(self, lightNode): def removeLight(self, lightNode):
################################################################# #################################################################
@ -639,7 +639,7 @@ class myLevelEditor(AppShell):
list, lightNode = AllScene.createLight(type = type) list, lightNode = AllScene.createLight(type = type)
if self.lightingPanel != None: if self.lightingPanel != None:
self.lightingPanel.updateList(list,lightNode) self.lightingPanel.updateList(list,lightNode)
self.makeDirty() self.makeDirty()
return return
def lightingPanelClose(self): def lightingPanelClose(self):
@ -674,9 +674,9 @@ class myLevelEditor(AppShell):
return return
def openMetadataPanel(self,nodePath=None): def openMetadataPanel(self,nodePath=None):
print nodePath print nodePath
self.MetadataPanel=MetadataPanel(nodePath) self.MetadataPanel=MetadataPanel(nodePath)
pass pass
def duplicate(self, nodePath = None): def duplicate(self, nodePath = None):
################################################################# #################################################################
@ -718,7 +718,7 @@ class myLevelEditor(AppShell):
# #
################################################################# #################################################################
AllScene.addDummyNode(nodepath) AllScene.addDummyNode(nodepath)
self.makeDirty() self.makeDirty()
pass pass
def addCollisionObj(self, nodepath = None): def addCollisionObj(self, nodepath = None):
@ -832,67 +832,67 @@ class myLevelEditor(AppShell):
# and will reset the application title to "New Scene" # and will reset the application title to "New Scene"
################################################################# #################################################################
self.closeAllSubWindows() ## Close all sub window self.closeAllSubWindows() ## Close all sub window
if(self.CurrentFileName): if(self.CurrentFileName):
currentF=Filename(self.CurrentFileName) currentF=Filename(self.CurrentFileName)
self.CurrentFileName=None self.CurrentFileName=None
AllScene.resetAll() AllScene.resetAll()
currentModName=currentF.getBasenameWoExtension() currentModName=currentF.getBasenameWoExtension()
# Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module # Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module
# And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it # And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it
# If there is ever a garbage colleciton bug..this might be a point to look at # If there is ever a garbage colleciton bug..this might be a point to look at
if sys.modules.has_key(currentModName): if sys.modules.has_key(currentModName):
del sys.modules[currentModName] del sys.modules[currentModName]
print sys.getrefcount(AllScene.theScene) print sys.getrefcount(AllScene.theScene)
del AllScene.theScene del AllScene.theScene
else: else:
AllScene.resetAll() AllScene.resetAll()
self.parent.title('Scene Editor - New Scene') self.parent.title('Scene Editor - New Scene')
pass pass
def openScene(self): def openScene(self):
################################################################# #################################################################
# openScene(self) # openScene(self)
################################################################# #################################################################
# In the future try and provide merging of two scenes # In the future try and provide merging of two scenes
if(self.CurrentFileName or self.Dirty): if(self.CurrentFileName or self.Dirty):
saveScene = tkMessageBox._show("Load scene","Save the current scene?",icon = tkMessageBox.QUESTION,type = tkMessageBox.YESNOCANCEL) saveScene = tkMessageBox._show("Load scene","Save the current scene?",icon = tkMessageBox.QUESTION,type = tkMessageBox.YESNOCANCEL)
if (saveScene == "yes"): if (saveScene == "yes"):
self.saveScene() self.saveScene()
elif (saveScene == "cancel"): elif (saveScene == "cancel"):
return return
self.closeAllSubWindows() ## Close all sub window self.closeAllSubWindows() ## Close all sub window
if(self.CurrentFileName): if(self.CurrentFileName):
currentF=Filename(self.CurrentFileName) currentF=Filename(self.CurrentFileName)
AllScene.resetAll() AllScene.resetAll()
currentModName=currentF.getBasenameWoExtension() currentModName=currentF.getBasenameWoExtension()
# Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module # Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module
# And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it # And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it
# If there is ever a garbage colleciton bug..this might be a point to look at # If there is ever a garbage colleciton bug..this might be a point to look at
if sys.modules.has_key(currentModName): if sys.modules.has_key(currentModName):
del sys.modules[currentModName] del sys.modules[currentModName]
print sys.getrefcount(AllScene.theScene) print sys.getrefcount(AllScene.theScene)
del AllScene.theScene del AllScene.theScene
else: else:
AllScene.resetAll() AllScene.resetAll()
self.CurrentFileName = AllScene.loadScene() self.CurrentFileName = AllScene.loadScene()
if(self.CurrentFileName==None): if(self.CurrentFileName==None):
return return
thefile=Filename(self.CurrentFileName) thefile=Filename(self.CurrentFileName)
thedir=thefile.getFullpathWoExtension() thedir=thefile.getFullpathWoExtension()
print "SCENE EDITOR::" + thedir print "SCENE EDITOR::" + thedir
self.CurrentDirName=thedir self.CurrentDirName=thedir
if self.CurrentFileName != None: if self.CurrentFileName != None:
self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension())
if self.lightingPanel !=None: if self.lightingPanel !=None:
lightList=AllScene.getList() lightList=AllScene.getList()
self.lightingPanel.updateList(lightList) self.lightingPanel.updateList(lightList)
messenger.send('SGE_Update Explorer',[render]) messenger.send('SGE_Update Explorer',[render])
# Close the side window in order to reset all world settings to fit the scene we have loaded. # Close the side window in order to reset all world settings to fit the scene we have loaded.
self.sideWindow.quit() self.sideWindow.quit()
@ -917,45 +917,45 @@ class myLevelEditor(AppShell):
# If this filename exists in sys.modules you cannot use it # If this filename exists in sys.modules you cannot use it
################################################################# #################################################################
if(self.CurrentFileName): if(self.CurrentFileName):
f=FileSaver() f=FileSaver()
f.SaveFile(AllScene,self.CurrentFileName,self.CurrentDirName,1) f.SaveFile(AllScene,self.CurrentFileName,self.CurrentDirName,1)
self.Dirty=0 self.Dirty=0
else: else:
self.saveAsScene() self.saveAsScene()
pass pass
def saveAsScene(self): def saveAsScene(self):
################################################################# #################################################################
# saveAsScene(self) # saveAsScene(self)
# Ask for filename using a file save dialog # Ask for filename using a file save dialog
# If this filename exists in sys.modules you cannot use it # If this filename exists in sys.modules you cannot use it
# Instantiate FileSaver from seFileSaver.py and pass it the filename # Instantiate FileSaver from seFileSaver.py and pass it the filename
################################################################# #################################################################
fileName = tkFileDialog.asksaveasfilename(filetypes = [("PY","py")],title = "Save Scene") fileName = tkFileDialog.asksaveasfilename(filetypes = [("PY","py")],title = "Save Scene")
if(not fileName): if(not fileName):
return return
fCheck=Filename(fileName) fCheck=Filename(fileName)
#print fCheck.getBasenameWoExtension() #print fCheck.getBasenameWoExtension()
############################################################################### ###############################################################################
# !!!!! See if a module exists by this name... if it does you cannot use this filename !!!!! # !!!!! See if a module exists by this name... if it does you cannot use this filename !!!!!
############################################################################### ###############################################################################
if(sys.modules.has_key(fCheck.getBasenameWoExtension())): if(sys.modules.has_key(fCheck.getBasenameWoExtension())):
tkMessageBox.showwarning( tkMessageBox.showwarning(
"Save file", "Save file",
"Cannot save with this name because there is a system module with the same name. Please resave as something else." "Cannot save with this name because there is a system module with the same name. Please resave as something else."
) )
return return
self.CurrentDirName=fileName self.CurrentDirName=fileName
fileName=fileName+".py" fileName=fileName+".py"
f=FileSaver() f=FileSaver()
self.CurrentFileName=fileName self.CurrentFileName=fileName
f.SaveFile(AllScene,fileName,self.CurrentDirName,0) f.SaveFile(AllScene,fileName,self.CurrentDirName,0)
self.Dirty=0 self.Dirty=0
self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension())
pass pass
def loadModel(self): def loadModel(self):
@ -974,7 +974,7 @@ class myLevelEditor(AppShell):
title = 'Load New Model', title = 'Load New Model',
parent = self.parent) parent = self.parent)
if modelFilename: if modelFilename:
self.makeDirty() self.makeDirty()
if not AllScene.loadModel(modelFilename, Filename.fromOsSpecific(modelFilename)): if not AllScene.loadModel(modelFilename, Filename.fromOsSpecific(modelFilename)):
print '----Error! No Such Model File!' print '----Error! No Such Model File!'
pass pass
@ -995,9 +995,9 @@ class myLevelEditor(AppShell):
title = 'Load New Actor', title = 'Load New Actor',
parent = self.parent) parent = self.parent)
if ActorFilename: if ActorFilename:
self.makeDirty() self.makeDirty()
if not AllScene.loadActor(ActorFilename, Filename.fromOsSpecific(ActorFilename)): if not AllScene.loadActor(ActorFilename, Filename.fromOsSpecific(ActorFilename)):
print '----Error! No Such Model File!' print '----Error! No Such Model File!'
pass pass
@ -1174,24 +1174,24 @@ class myLevelEditor(AppShell):
return return
def addParticleEffect(self,effect_name,effect,node): def addParticleEffect(self,effect_name,effect,node):
AllScene.particleDict[effect_name]=effect AllScene.particleDict[effect_name]=effect
AllScene.particleNodes[effect_name]=node AllScene.particleNodes[effect_name]=node
if not self.ParticleEnable: if not self.ParticleEnable:
AllScene.particleNodes[effect_name].setTransparency(True) AllScene.particleNodes[effect_name].setTransparency(True)
AllScene.particleNodes[effect_name].setAlphaScale(0) AllScene.particleNodes[effect_name].setAlphaScale(0)
AllScene.particleNodes[effect_name].setBin("fixed",1) AllScene.particleNodes[effect_name].setBin("fixed",1)
return return
def openParticlePanel(self): def openParticlePanel(self):
if self.particlePanel != None: if self.particlePanel != None:
## There already has a Particle panel! ## There already has a Particle panel!
return return
if(len(AllScene.particleDict)==0): if(len(AllScene.particleDict)==0):
self.particlePanel=seParticlePanel.ParticlePanel() self.particlePanel=seParticlePanel.ParticlePanel()
else: else:
for effect in AllScene.particleDict: for effect in AllScene.particleDict:
theeffect=AllScene.particleDict[effect] theeffect=AllScene.particleDict[effect]
self.particlePanel=seParticlePanel.ParticlePanel(particleEffect=theeffect,effectsDict=AllScene.particleDict) self.particlePanel=seParticlePanel.ParticlePanel(particleEffect=theeffect,effectsDict=AllScene.particleDict)
pass pass
@ -1337,7 +1337,7 @@ class myLevelEditor(AppShell):
self.menuEdit.entryconfig('Duplicate', state=NORMAL) self.menuEdit.entryconfig('Duplicate', state=NORMAL)
self.menuEdit.entryconfig('Remove', state=NORMAL) self.menuEdit.entryconfig('Remove', state=NORMAL)
self.menuEdit.entryconfig('Object Properties', state=NORMAL) self.menuEdit.entryconfig('Object Properties', state=NORMAL)
if callBack: if callBack:
self.seSession.select(nodePath,fResetAncestry=1) self.seSession.select(nodePath,fResetAncestry=1)
messenger.send('SGE_Update Explorer',[render]) messenger.send('SGE_Update Explorer',[render])
if not taskMgr.hasTaskNamed('seMonitorSelectedNode'): if not taskMgr.hasTaskNamed('seMonitorSelectedNode'):

View File

@ -149,7 +149,7 @@ def oscmd(cmd):
else: else:
res = os.system(cmd) res = os.system(cmd)
if res != 0: if res != 0:
exit("") exit("")
def getbuilding(opts): def getbuilding(opts):
building = 0 building = 0
@ -1180,7 +1180,7 @@ def EnqueueIgate(ipath=0, opts=0, outd=0, obj=0, src=0, module=0, library=0, als
if ((ipath==0)|(opts==0)|(outd==0)|(obj==0)|(src==0)|(module==0)|(library==0)|(also==0)|(skip==0)): if ((ipath==0)|(opts==0)|(outd==0)|(obj==0)|(src==0)|(module==0)|(library==0)|(also==0)|(skip==0)):
exit("syntax error in EnqueueIgate directive") exit("syntax error in EnqueueIgate directive")
if (COMPILER=="MSVC7"): if (COMPILER=="MSVC7"):
altdep = "built/bin/interrogate.exe" altdep = "built/bin/interrogate.exe"
wobj = "built/tmp/"+obj wobj = "built/tmp/"+obj
fn = CompileIgateMSVC7 fn = CompileIgateMSVC7
if (COMPILER=="LINUXA"): if (COMPILER=="LINUXA"):
@ -1234,11 +1234,11 @@ def EnqueueImod(ipath=0, opts=0, obj=0, module=0, library=0, files=0):
if ((ipath==0)|(opts==0)|(obj==0)|(module==0)|(library==0)|(files==0)): if ((ipath==0)|(opts==0)|(obj==0)|(module==0)|(library==0)|(files==0)):
exit("syntax error in EnqueueImod directive") exit("syntax error in EnqueueImod directive")
if (COMPILER=="MSVC7"): if (COMPILER=="MSVC7"):
altdep = "built/bin/interrogate_module.exe" altdep = "built/bin/interrogate_module.exe"
wobj = "built/tmp/"+obj[:-4]+".obj" wobj = "built/tmp/"+obj[:-4]+".obj"
fn = CompileImodMSVC7 fn = CompileImodMSVC7
if (COMPILER=="LINUXA"): if (COMPILER=="LINUXA"):
altdep = "built/bin/interrogate_module" altdep = "built/bin/interrogate_module"
wobj = "built/tmp/"+obj[:-4]+".o" wobj = "built/tmp/"+obj[:-4]+".o"
fn = CompileImodLINUXA fn = CompileImodLINUXA
if (SLAVEBUILD!=0) and (SLAVEBUILD!=wobj): return if (SLAVEBUILD!=0) and (SLAVEBUILD!=wobj): return