diff --git a/doc/SceneEditor/MetadataPanel.py b/doc/SceneEditor/MetadataPanel.py index 0995d2f726..28906adbbd 100644 --- a/doc/SceneEditor/MetadataPanel.py +++ b/doc/SceneEditor/MetadataPanel.py @@ -23,10 +23,10 @@ class MetadataPanel(AppShell,Pmw.MegaWidget): optiondefs = ( ('title', self.appname, None), ) - self.defineoptions(kw, optiondefs) - self.Metanode=nodePath - if(nodePath.hasTag("Metadata")): - self.Metatag=self.Metanode.getTag("Metadata") + self.defineoptions(kw, optiondefs) + self.Metanode=nodePath + if(nodePath.hasTag("Metadata")): + self.Metatag=self.Metanode.getTag("Metadata") if parent == None: self.parent = Toplevel() @@ -36,24 +36,24 @@ class MetadataPanel(AppShell,Pmw.MegaWidget): def appInit(self): - print "Metadata Panel" + print "Metadata Panel" def createInterface(self): interior = self.interior() mainFrame = Frame(interior) - tag_label=Label (mainFrame,text="Enter Metadata",font=('MSSansSerif', 15), + tag_label=Label (mainFrame,text="Enter Metadata",font=('MSSansSerif', 15), relief = RIDGE, borderwidth=5) - tag_label.pack() - source=StringVar() - source.set(self.Metatag) - self.tag_text=Entry(mainFrame, width=10,textvariable=source) - self.tag_text.pack() - set_button=Button(mainFrame, text='Set Metadata',font=('MSSansSerif', 15), + tag_label.pack() + source=StringVar() + source.set(self.Metatag) + self.tag_text=Entry(mainFrame, width=10,textvariable=source) + self.tag_text.pack() + set_button=Button(mainFrame, text='Set Metadata',font=('MSSansSerif', 15), relief = RIDGE, borderwidth=5, command= lambda:self.SetIt()) - set_button.pack() - mainFrame.pack(fill = 'both', expand = 1) + set_button.pack() + mainFrame.pack(fill = 'both', expand = 1) def SetIt(self): - self.Metanode.setTag("Metadata",self.tag_text.get()) - - + self.Metanode.setTag("Metadata",self.tag_text.get()) + + diff --git a/doc/SceneEditor/dataHolder.py b/doc/SceneEditor/dataHolder.py index 9033060ea4..c9b8ff4981 100644 --- a/doc/SceneEditor/dataHolder.py +++ b/doc/SceneEditor/dataHolder.py @@ -126,7 +126,7 @@ class dataHolder: # resetAll(self) # This function will reset the whole scene ################################################################# - # Delete Everything in the Scene Graph + # Delete Everything in the Scene Graph for index in self.ModelDic: self.ModelDic[index].removeNode() for index in self.ActorDic: @@ -137,22 +137,22 @@ class dataHolder: self.collisionDict[index].removeNode() for index in self.particleNodes: self.particleDict[index].cleanup() - self.particleNodes[index].removeNode() + self.particleNodes[index].removeNode() # Clear all data containers in the dataHolder - self.ModelDic.clear() + self.ModelDic.clear() self.ModelRefDic.clear() self.ActorDic.clear() self.ActorRefDic.clear() - self.dummyDict.clear() - self.lightManager.deleteAll() - self.blendAnimDict.clear() - self.particleDict.clear() - self.particleNodes.clear() + self.dummyDict.clear() + self.lightManager.deleteAll() + self.blendAnimDict.clear() + self.particleDict.clear() + self.particleNodes.clear() self.ModelNum=0 self.ActorNum=0 - self.theScene=None + self.theScene=None messenger.send('SGE_Update Explorer',[render]) print 'Scene should be cleaned up!' @@ -207,10 +207,10 @@ class dataHolder: self.removeObj(node) list = self.lightManager.delete(name) return list - elif self.particleNodes.has_key(name): - self.particleNodes[name].removeNode() - del self.particleNodes[name] - del self.particleDict[name] + elif self.particleNodes.has_key(name): + self.particleNodes[name].removeNode() + del self.particleNodes[name] + del self.particleDict[name] else: print 'You cannot remove this NodePath' return @@ -588,7 +588,7 @@ class dataHolder: return True return False - + def bindCurveToNode(self,node,curveCollection): ########################################################################### # bindCurveToNode(self,node,curveCollection) @@ -929,143 +929,143 @@ class dataHolder: # loadScene(self) # Opens a dialog box asking for a scene file to load. It then removes # the current scene and opens the new one. - # It basically proceeds by executig the python file containing the scene - # and then re-populating the various dictionaries based on the dictionaries - # in the scene file hence reviving the state for the scene + # It basically proceeds by executig the python file containing the scene + # and then re-populating the various dictionaries based on the dictionaries + # in the scene file hence reviving the state for the scene ########################################################################### ### Ask for a filename - OpenFilename = tkFileDialog.askopenfilename(filetypes = [("PY","py")],title = "Load Scene") - if(not OpenFilename): - return None - f=Filename.fromOsSpecific(OpenFilename) - fileName=f.getBasenameWoExtension() - dirName=f.getFullpathWoExtension() - print "DATAHOLDER::" + dirName - ############################################################################ - # Append the path to this file to our sys path where python looks for modules - # We do this so that we can use "import" on our saved scene code and execute it - ############################################################################ - sys.path.append(os.path.dirname(f.toOsSpecific())) + OpenFilename = tkFileDialog.askopenfilename(filetypes = [("PY","py")],title = "Load Scene") + if(not OpenFilename): + return None + f=Filename.fromOsSpecific(OpenFilename) + fileName=f.getBasenameWoExtension() + dirName=f.getFullpathWoExtension() + print "DATAHOLDER::" + dirName + ############################################################################ + # Append the path to this file to our sys path where python looks for modules + # We do this so that we can use "import" on our saved scene code and execute it + ############################################################################ + sys.path.append(os.path.dirname(f.toOsSpecific())) - ############################################################################ - # Actually import the scene... this executes the code in the scene - ############################################################################ - self.theScene=__import__(fileName) - self.Scene=self.theScene.SavedScene(0,seParticleEffect,seParticles,dirName) # Specify load mode of 0 which will allow us to pass seParticle and seParticleEffect - messenger.send('SGE_Update Explorer',[render]) + ############################################################################ + # Actually import the scene... this executes the code in the scene + ############################################################################ + self.theScene=__import__(fileName) + self.Scene=self.theScene.SavedScene(0,seParticleEffect,seParticles,dirName) # Specify load mode of 0 which will allow us to pass seParticle and seParticleEffect + messenger.send('SGE_Update Explorer',[render]) # Lets call some important initialization methods on our scene: #self.Scene.starteffects(0,seParticleEffect,seParticles,dirName) # This special calling of start effect with mode 0 is to use seParticleEffect and seParticles - ############################################################################ - # Populate Model related Dictionaries - ############################################################################ - for model in self.Scene.ModelDic: - self.ModelDic[model]=self.Scene.ModelDic[model] - #self.ModelRefDic[model]=self.Scene.ModelRefDic[model] # The Old absolute paths way - self.ModelRefDic[model]=Filename(dirName + "/" + self.Scene.ModelRefDic[model]) # Relative Paths + ############################################################################ + # Populate Model related Dictionaries + ############################################################################ + for model in self.Scene.ModelDic: + self.ModelDic[model]=self.Scene.ModelDic[model] + #self.ModelRefDic[model]=self.Scene.ModelRefDic[model] # The Old absolute paths way + self.ModelRefDic[model]=Filename(dirName + "/" + self.Scene.ModelRefDic[model]) # Relative Paths self.ModelNum=self.ModelNum+1 - ############################################################################ - # Populate Actor related Dictionaries - ############################################################################ - for actor in self.Scene.ActorDic: - self.ActorDic[actor]=self.Scene.ActorDic[actor] - #self.ActorRefDic[actor]=self.Scene.ActorRefDic[actor] # Old way of doing absolute paths - self.ActorRefDic[actor]=Filename(dirName + "/" + self.Scene.ActorRefDic[actor]) # Relative Paths - if(self.Scene.blendAnimDict.has_key(str(actor))): - self.blendAnimDict[actor]=self.Scene.blendAnimDict[actor] - self.ActorNum=self.ActorNum+1 + ############################################################################ + # Populate Actor related Dictionaries + ############################################################################ + for actor in self.Scene.ActorDic: + self.ActorDic[actor]=self.Scene.ActorDic[actor] + #self.ActorRefDic[actor]=self.Scene.ActorRefDic[actor] # Old way of doing absolute paths + self.ActorRefDic[actor]=Filename(dirName + "/" + self.Scene.ActorRefDic[actor]) # Relative Paths + if(self.Scene.blendAnimDict.has_key(str(actor))): + self.blendAnimDict[actor]=self.Scene.blendAnimDict[actor] + self.ActorNum=self.ActorNum+1 - ############################################################################ - # Populate Light related Dictionaries - ############################################################################ + ############################################################################ + # Populate Light related Dictionaries + ############################################################################ #print self.Scene.LightDict for light in self.Scene.LightDict: - #print light - alight=self.Scene.LightDict[light] - type=self.Scene.LightTypes[light] - thenode=self.Scene.LightNodes[light] - #print type - if type == 'ambient': + #print light + alight=self.Scene.LightDict[light] + type=self.Scene.LightTypes[light] + thenode=self.Scene.LightNodes[light] + #print type + if type == 'ambient': self.lightManager.create('ambient',alight.getColor(),name=alight.getName(),tag=thenode.getTag("Metadata")) elif type == 'directional': - #print alight.getPoint() - #print alight.getDirection() + #print alight.getPoint() + #print alight.getDirection() self.lightManager.create('directional',alight.getColor(),alight.getSpecularColor(),thenode.getPos(),thenode.getHpr(),name=alight.getName(),tag=thenode.getTag("Metadata")) elif type == 'point': - atten=alight.getAttenuation() - #print alight.getPoint() + atten=alight.getAttenuation() + #print alight.getPoint() self.lightManager.create('point',alight.getColor(),alight.getSpecularColor(),thenode.getPos(),Vec3(1,0,0),atten.getX(),atten.getY(),atten.getZ(),name=alight.getName(),tag=thenode.getTag("Metadata")) elif type == 'spot': - atten=alight.getAttenuation() + atten=alight.getAttenuation() self.lightManager.create('spot',alight.getColor(),alight.getSpecularColor(),thenode.getPos(),thenode.getHpr(),atten.getX(),atten.getY(),atten.getZ(),alight.getExponent(),name=alight.getName(),tag=thenode.getTag("Metadata")) else: - print 'Invalid light type' + print 'Invalid light type' - ############################################################################ - # Populate Dummy related Dictionaries - ############################################################################ - for dummy in self.Scene.dummyDict: - self.dummyDict[dummy] = self.Scene.dummyDict[dummy] + ############################################################################ + # Populate Dummy related Dictionaries + ############################################################################ + for dummy in self.Scene.dummyDict: + self.dummyDict[dummy] = self.Scene.dummyDict[dummy] - ############################################################################ - # Populate Collision related Dictionaries - ############################################################################ - for collnode in self.Scene.collisionDict: - self.collisionDict[collnode]=self.Scene.collisionDict[collnode] + ############################################################################ + # Populate Collision related Dictionaries + ############################################################################ + for collnode in self.Scene.collisionDict: + self.collisionDict[collnode]=self.Scene.collisionDict[collnode] - ############################################################################ - # Populate Mopath related Dictionaries - ############################################################################ - for node in self.Scene.curveDict: - curveCollection=self.Scene.curveDict[node] - for curve in curveCollection: - curveColl=ParametricCurveCollection() - nodeP=loader.loadModel(curve) - curveColl.addCurves(nodeP.node()) - nodeP.removeNode() - thenode=render.find("**/"+str(node)) - self.bindCurveToNode(thenode,curveColl) - - ############################################################################ - # Populate Particle related Dictionaries - ############################################################################ + ############################################################################ + # Populate Mopath related Dictionaries + ############################################################################ + for node in self.Scene.curveDict: + curveCollection=self.Scene.curveDict[node] + for curve in curveCollection: + curveColl=ParametricCurveCollection() + nodeP=loader.loadModel(curve) + curveColl.addCurves(nodeP.node()) + nodeP.removeNode() + thenode=render.find("**/"+str(node)) + self.bindCurveToNode(thenode,curveColl) + + ############################################################################ + # Populate Particle related Dictionaries + ############################################################################ for effect in self.Scene.particleDict: - theeffect=self.Scene.particleDict[effect] - emitter=loader.loadModel("sphere") - emitter.setPosHprScale(theeffect.getX(),theeffect.getY(),theeffect.getZ(),theeffect.getH(),theeffect.getP(),theeffect.getR(),theeffect.getSx(),theeffect.getSy(),theeffect.getSz()) - theeffect.setPos(0,0,0) - theeffect.setName(str(effect)) - tempparent=theeffect.getParent() - theeffect.reparentTo(emitter) - emitter.setName(str(effect)) - emitter.reparentTo(tempparent) - theeffect.enable() - self.particleDict[effect]=theeffect - self.particleNodes[effect]=emitter - - - - # Clean up things added to scene graph by saved file's code execution - for light in self.Scene.LightDict: - vestige=render.find('**/'+light) - if(vestige != None): - vestige.removeNode() + theeffect=self.Scene.particleDict[effect] + emitter=loader.loadModel("sphere") + emitter.setPosHprScale(theeffect.getX(),theeffect.getY(),theeffect.getZ(),theeffect.getH(),theeffect.getP(),theeffect.getR(),theeffect.getSx(),theeffect.getSy(),theeffect.getSz()) + theeffect.setPos(0,0,0) + theeffect.setName(str(effect)) + tempparent=theeffect.getParent() + theeffect.reparentTo(emitter) + emitter.setName(str(effect)) + emitter.reparentTo(tempparent) + theeffect.enable() + self.particleDict[effect]=theeffect + self.particleNodes[effect]=emitter - ############################################################################ - # return the filename and update the scenegraph explorer window - ############################################################################ + + + # Clean up things added to scene graph by saved file's code execution + for light in self.Scene.LightDict: + vestige=render.find('**/'+light) + if(vestige != None): + vestige.removeNode() + + ############################################################################ + # return the filename and update the scenegraph explorer window + ############################################################################ messenger.send('SGE_Update Explorer',[render]) - if(OpenFilename): + if(OpenFilename): return OpenFilename - else: - return None + else: + return None def getList(self): - return self.lightManager.getList() + return self.lightManager.getList() diff --git a/doc/SceneEditor/quad.py b/doc/SceneEditor/quad.py index 8bff35bdd0..dbc6f66aec 100644 --- a/doc/SceneEditor/quad.py +++ b/doc/SceneEditor/quad.py @@ -22,51 +22,51 @@ class ViewPort: def __init__(self,X1,X2,Y1,Y2,layer,cam,background=Vec4(0.3,0.3,0.3,1),projection="perspective",type="top",scene=render): self.VPType=type self.VP_X1=X1 - self.VP_Y1=Y1 - self.VP_X2=X2 - self.VP_Y2=Y2 + self.VP_Y1=Y1 + self.VP_X2=X2 + self.VP_Y2=Y2 self.VP_width=self.VP_X2 - self.VP_X1 - self.VP_height=self.VP_Y2 - self.VP_Y1 + self.VP_height=self.VP_Y2 - self.VP_Y1 - self.the_viewport=layer.makeDisplayRegion(self.VP_X1, self.VP_X2,self.VP_Y1, self.VP_Y2) + self.the_viewport=layer.makeDisplayRegion(self.VP_X1, self.VP_X2,self.VP_Y1, self.VP_Y2) self.the_viewport.setCamera(cam) self.the_viewport.setClearDepthActive(1) self.the_viewport.setClearColorActive(1) self.the_viewport.setClearColor(background) - self.cam=cam + self.cam=cam # Set up the cameras to look in the right place. - if(type=="top"): + if(type=="top"): self.cam.setP(-90) self.cam.setZ(-40) - elif(type=="left"): + elif(type=="left"): self.cam.setH(-90) self.cam.setX(10) elif(type=="front"): self.cam.setY(-10) elif(type=="perspective"): - cam.setY(-100) - #cam.setX(10) - #cam.setZ(-10) - #cam.setH(45) + cam.setY(-100) + #cam.setX(10) + #cam.setZ(-10) + #cam.setH(45) #cam.setP(-45) - #print "aa" + #print "aa" if(projection=="ortho"): - self.lens=OrthographicLens() - self.lens.setAspectRatio((self.VP_X2-self.VP_X1)/(self.VP_Y2-self.VP_Y1)) + self.lens=OrthographicLens() + self.lens.setAspectRatio((self.VP_X2-self.VP_X1)/(self.VP_Y2-self.VP_Y1)) self.lens.setFilmSize(self.VP_width*200,self.VP_height*200) - #lens.setFilmOffset((self.VP_X2 + self.VP_X1) * 0.5, (self.VP_Y2 + self.VP_Y1) * 0.5) - self.lens.setNearFar(-1000, 1000) + #lens.setFilmOffset((self.VP_X2 + self.VP_X1) * 0.5, (self.VP_Y2 + self.VP_Y1) * 0.5) + self.lens.setNearFar(-1000, 1000) self.cam.node().setLens(self.lens) self.cam.node().setScene(scene) elif(projection=="perspective"): - self.lens=base.cam.node().getLens() - self.lens.setAspectRatio((self.VP_X2-self.VP_X1)/(self.VP_Y2-self.VP_Y1)) - self.cam.node().setLens(self.lens) - self.cam.node().setScene(scene) + self.lens=base.cam.node().getLens() + self.lens.setAspectRatio((self.VP_X2-self.VP_X1)/(self.VP_Y2-self.VP_Y1)) + self.cam.node().setLens(self.lens) + self.cam.node().setScene(scene) self.the_viewport.setCamera(self.cam) @@ -77,69 +77,69 @@ class ViewPort: self.the_viewport.setDimensions(self.VP_X1+width_increment,self.VP_X2,self.VP_Y1,self.VP_Y2) def resizeY(self,height_increment,direction): - if(self.VPType=="left" or self.type=="perspective"): + if(self.VPType=="left" or self.type=="perspective"): self.the_viewport.setDimensions(self.VP_X1,self.VP_X2,self.VP_Y1,self.VP_Y2+height_increment) - else: - self.the_viewport.setDimensions(self.VP_X1,self.VP_X2,self.VP_Y1+height_increment,self.VP_Y2) + else: + self.the_viewport.setDimensions(self.VP_X1,self.VP_X2,self.VP_Y1+height_increment,self.VP_Y2) def AdjustAspect(self,x,y): - if (y==0): - y=1 - self.lens.setAspectRatio(x/y) - self.cam.node().setLens(self.lens) + if (y==0): + y=1 + self.lens.setAspectRatio(x/y) + self.cam.node().setLens(self.lens) def resize(self,x,y): - - if(self.VPType=="left"): - self.the_viewport.setDimensions(0,x,0,y) - w=abs(x-self.VP_X1) - h=abs(y-self.VP_Y1) - if(h==0): - h=1 - self.lens.setAspectRatio(w/h) - self.cam.node().setLens(self.lens) - if(self.VPType=="top"): - self.the_viewport.setDimensions(0,x,y,1) - w=abs(x-self.VP_X1) - h=abs(self.VP_Y2-y) - if(h==0): - h=1 - self.lens.setAspectRatio(w/h) - self.cam.node().setLens(self.lens) - if(self.VPType=="front"): - self.the_viewport.setDimensions(x,1,y,1) - w=abs(self.VP_X2-x) - h=abs(self.VP_Y2-y) - if(h==0): - h=1 - self.lens.setAspectRatio(w/h) - self.cam.node().setLens(self.lens) - if(self.VPType=="perspective"): - self.the_viewport.setDimensions(x,1,0,y) - w=abs(self.VP_X2-x) - h=abs(y-self.VP_Y1) - if(h==0): - h=1 - self.lens.setAspectRatio(w/h) - self.cam.node().setLens(self.lens) + + if(self.VPType=="left"): + self.the_viewport.setDimensions(0,x,0,y) + w=abs(x-self.VP_X1) + h=abs(y-self.VP_Y1) + if(h==0): + h=1 + self.lens.setAspectRatio(w/h) + self.cam.node().setLens(self.lens) + if(self.VPType=="top"): + self.the_viewport.setDimensions(0,x,y,1) + w=abs(x-self.VP_X1) + h=abs(self.VP_Y2-y) + if(h==0): + h=1 + self.lens.setAspectRatio(w/h) + self.cam.node().setLens(self.lens) + if(self.VPType=="front"): + self.the_viewport.setDimensions(x,1,y,1) + w=abs(self.VP_X2-x) + h=abs(self.VP_Y2-y) + if(h==0): + h=1 + self.lens.setAspectRatio(w/h) + self.cam.node().setLens(self.lens) + if(self.VPType=="perspective"): + self.the_viewport.setDimensions(x,1,0,y) + w=abs(self.VP_X2-x) + h=abs(y-self.VP_Y1) + if(h==0): + h=1 + self.lens.setAspectRatio(w/h) + self.cam.node().setLens(self.lens) def setScene(self,scene): self.cam.node().setScene(scene) def setDR(self,mouseWatcher): - #mouseWatcher.setDisplayRegion(self.the_viewport) - pass + #mouseWatcher.setDisplayRegion(self.the_viewport) + pass def setCam(self): - #base.cam=self.cam - #base.cam.node().setLens(self.cam.node().getLens()) - base.camNode=self.cam.node() - #base.camNode.setLens(self.cam.node().getLens()) - #base.camLens=self.cam.node().getLens() + #base.cam=self.cam + #base.cam.node().setLens(self.cam.node().getLens()) + base.camNode=self.cam.node() + #base.camNode.setLens(self.cam.node().getLens()) + #base.camLens=self.cam.node().getLens() def getCam(self): return self.cam - + class QuadView(DirectObject.DirectObject): ######################################################################################################################################### @@ -150,43 +150,43 @@ class QuadView(DirectObject.DirectObject): def __init__(self): - self.PTracker=1 - self.ControlPressed=0 - self.AltPressed=0 + self.PTracker=1 + self.ControlPressed=0 + self.AltPressed=0 self.PanConstantX=50 - self.PanConstantY=50 - self.ZoomConstant=1 - self.FrontWidth=100 - self.FrontHeight=100 - self.TopWidth=100 - self.TopHeight=100 - self.LeftWidth=100 - self.LeftHeight=100 + self.PanConstantY=50 + self.ZoomConstant=1 + self.FrontWidth=100 + self.FrontHeight=100 + self.TopWidth=100 + self.TopHeight=100 + self.LeftWidth=100 + self.LeftHeight=100 - self.MouseButton=0 - self.CurrentQuad=4 - self.HorizontalAxis=0.0 - self.VerticalAxis=0.0 + self.MouseButton=0 + self.CurrentQuad=4 + self.HorizontalAxis=0.0 + self.VerticalAxis=0.0 #base.disableMouse() - self.MouseDragging=0 + self.MouseDragging=0 self.currX= 0 - self.oldX=self.currX + self.oldX=self.currX self.currY= 0 - self.oldY=self.currY + self.oldY=self.currY - self.FrontTexture=1 - self.LeftTexture=1 - self.PerspectiveTexture=1 - self.TopTexture=1 + self.FrontTexture=1 + self.LeftTexture=1 + self.PerspectiveTexture=1 + self.TopTexture=1 - self.FrontWire=0 - self.LeftWire=0 - self.PerspectiveWire=0 - self.TopWire=0 + self.FrontWire=0 + self.LeftWire=0 + self.PerspectiveWire=0 + self.TopWire=0 + + # Keep track of the currently selected window... values are 1-4 for four quadrants of a standard + # Cartesian coordinate system - # Keep track of the currently selected window... values are 1-4 for four quadrants of a standard - # Cartesian coordinate system - # These are the orthographic cameras # They will be restricted to panning and zooming i.e. no rotation # Top could be flipped to back, left to right and front to back @@ -194,13 +194,13 @@ class QuadView(DirectObject.DirectObject): self.frontCam = render.attachNewNode(Camera('frontCam')) self.leftCam= render.attachNewNode(Camera('leftCam')) - # This camera will have a trackball control since its perspective + # This camera will have a trackball control since its perspective self.perspectiveCam = render.attachNewNode(Camera('perspectiveCam')) - - #self.toplens=OrthographicLens() - #self.leftLens=OrthographicLens() - #self.frontLens=OrthographicLens() - #self.perspectiveLens=base.cam.node().getLens() + + #self.toplens=OrthographicLens() + #self.leftLens=OrthographicLens() + #self.frontLens=OrthographicLens() + #self.perspectiveLens=base.cam.node().getLens() # For now all lenses are same as that of base.cam #self.topCamLens=OrthographicLens() @@ -208,99 +208,99 @@ class QuadView(DirectObject.DirectObject): #self.leftCamLens= base.cam.node().getLens() #self.perspectiveCamLens= base.cam.node().getLens() - # Manipulate lenses here if need be - #self.topCamLens.setFilmSize(250) + # Manipulate lenses here if need be + #self.topCamLens.setFilmSize(250) - # Set the Lenses - #self.topCam.node().setLens(self.topCamLens) - #self.frontCam.node().setLens(self.frontCamLens) - #self.leftCam.node().setLens(self.leftCamLens) - #self.perspectiveCam.node().setLens(self.perspectiveCamLens) + # Set the Lenses + #self.topCam.node().setLens(self.topCamLens) + #self.frontCam.node().setLens(self.frontCamLens) + #self.leftCam.node().setLens(self.leftCamLens) + #self.perspectiveCam.node().setLens(self.perspectiveCamLens) #self.badwiz = loader.loadModel('badwizard1') - #self.badwiz.reparentTo(render) + #self.badwiz.reparentTo(render) - # Create four separate display regions for the quad view. + # Create four separate display regions for the quad view. # These will overlap the main display region # To stack these overlapping DisplayRegions, we need a new layer. If # they didn't overlap, we could put them in the same layer. self.newLayer = base.win.getChannel(0).makeLayer() - self.PerspectiveScene=NodePath('PerspectiveScene') - self.FrontScene=NodePath('FrontScene') - self.TopScene=NodePath('TopScene') - self.LeftScene=NodePath('LeftScene') - self.SceneParent=NodePath('SceneParent') + self.PerspectiveScene=NodePath('PerspectiveScene') + self.FrontScene=NodePath('FrontScene') + self.TopScene=NodePath('TopScene') + self.LeftScene=NodePath('LeftScene') + self.SceneParent=NodePath('SceneParent') - #self.PerspectiveScene=render.copyTo(self.SceneParent) - #self.FrontScene=render.copyTo(self.SceneParent) - #self.TopScene=render.copyTo(self.SceneParent) - #self.LeftScene=render.copyTo(self.SceneParent) - - self.PerspectiveScene=render - self.FrontScene=render - self.TopScene=render - self.LeftScene=render - - #self.PerspectiveScene.reparentTo(self.SceneParent) - #self.FrontScene.reparentTo(self.SceneParent) - #self.TopScene.reparentTo(self.SceneParent) - #self.LeftScene.reparentTo(self.SceneParent) + #self.PerspectiveScene=render.copyTo(self.SceneParent) + #self.FrontScene=render.copyTo(self.SceneParent) + #self.TopScene=render.copyTo(self.SceneParent) + #self.LeftScene=render.copyTo(self.SceneParent) + + self.PerspectiveScene=render + self.FrontScene=render + self.TopScene=render + self.LeftScene=render + + #self.PerspectiveScene.reparentTo(self.SceneParent) + #self.FrontScene.reparentTo(self.SceneParent) + #self.TopScene.reparentTo(self.SceneParent) + #self.LeftScene.reparentTo(self.SceneParent) self.Perspective=ViewPort(0.5,1.0,0.0,0.5,self.newLayer,self.perspectiveCam,Vec4(0.75,0.75,0.75,1),"perspective","perspective",self.PerspectiveScene) - self.Top=ViewPort(0.0,0.5,0.5,1.0,self.newLayer,self.topCam,Vec4(0.80,0.80,0.80,1),"ortho","top",self.TopScene) + self.Top=ViewPort(0.0,0.5,0.5,1.0,self.newLayer,self.topCam,Vec4(0.80,0.80,0.80,1),"ortho","top",self.TopScene) self.Left=ViewPort(0.0,0.5,0.0,0.5,self.newLayer,self.leftCam,Vec4(0.85,0.85,0.85,1),"ortho","left",self.LeftScene) self.Front=ViewPort(0.5,1.0,0.5,1.0,self.newLayer,self.frontCam,Vec4(0.85,0.85,0.85,1),"ortho","front",self.FrontScene) - #self.Perspective=None - #self.Top=None - #self.Front=None - #self.Left=None + #self.Perspective=None + #self.Top=None + #self.Front=None + #self.Left=None - #self.raycaster = RayCaster( camera ) + #self.raycaster = RayCaster( camera ) #self.lastPickPoint = None - #base.useTrackball() - - #self.dataRoot = NodePath('dataRoot') + #base.useTrackball() + + #self.dataRoot = NodePath('dataRoot') # Cache the node so we do not ask for it every frame #self.dataRootNode = self.dataRoot.node() #self.dataUnused = NodePath('dataUnused') - #self.mak=None - #self.mak = self.dataRoot.attachNewNode(MouseAndKeyboard(base.win, 0, 'mak')) - #self.mak.node().setSource(base.win, 0) + #self.mak=None + #self.mak = self.dataRoot.attachNewNode(MouseAndKeyboard(base.win, 0, 'mak')) + #self.mak.node().setSource(base.win, 0) self.mouseWatcherNode = MouseWatcher('mouseWatcher') - + self.mouseWatcher = base.mak.attachNewNode(self.mouseWatcherNode) - #self.Perspective.setDR(self.mouseWatcherNode) + #self.Perspective.setDR(self.mouseWatcherNode) self.buttonThrower = self.mouseWatcher.attachNewNode(ButtonThrower('buttons')) - #ddr=DisplayRegionContext(self.Perspective.getCam()) - #base.setMouseOnNode(self.smiley.node()) # Let Mouse Control Perspective View for now - #base.enableSoftwareMousePointer() + #ddr=DisplayRegionContext(self.Perspective.getCam()) + #base.setMouseOnNode(self.smiley.node()) # Let Mouse Control Perspective View for now + #base.enableSoftwareMousePointer() # Message Handlers self.accept("a",self.setLeft) self.accept("q",self.setTop) self.accept("w",self.setFront) self.accept("s",self.setPerspective) - self.accept("mouse1",self.MouseTell,[1]) - self.accept("mouse2",self.MouseTell,[2]) - self.accept("mouse3",self.MouseTell,[3]) - self.accept("mouse1-up",self.MouseTellUp,[4]) - self.accept("mouse2-up",self.MouseTellUp,[5]) - self.accept("mouse3-up",self.MouseTellUp,[6]) - self.accept("mouse2-scroll",self.resizedr) - self.accept("r",self.resizedr) - self.accept("alt",self.AltHandler) - self.accept("alt-up",self.AltUpHandler) - self.accept("alt-mouse1",self.AltDown) - self.accept("alt-mouse1-up",self.AltUp) - self.accept("control-mouse1",self.CtlDown) - self.accept("control-mouse1-up",self.CtlUp) - + self.accept("mouse1",self.MouseTell,[1]) + self.accept("mouse2",self.MouseTell,[2]) + self.accept("mouse3",self.MouseTell,[3]) + self.accept("mouse1-up",self.MouseTellUp,[4]) + self.accept("mouse2-up",self.MouseTellUp,[5]) + self.accept("mouse3-up",self.MouseTellUp,[6]) + self.accept("mouse2-scroll",self.resizedr) + self.accept("r",self.resizedr) + self.accept("alt",self.AltHandler) + self.accept("alt-up",self.AltUpHandler) + self.accept("alt-mouse1",self.AltDown) + self.accept("alt-mouse1-up",self.AltUp) + self.accept("control-mouse1",self.CtlDown) + self.accept("control-mouse1-up",self.CtlUp) + # Methods #def setLastPickPoint( self ): @@ -309,153 +309,153 @@ class QuadView(DirectObject.DirectObject): # print self.lastPickPoint def AltDown(self): - self.AltPressed=1 + self.AltPressed=1 def AltUp(self): - self.AltPressed=0 + self.AltPressed=0 def CtlDown(self): - self.ControlPressed=1 + self.ControlPressed=1 def CtlUp(self): - self.ControlPressed=0 + self.ControlPressed=0 def ToggleWire(self): - if (self.CurrentQuad==1): # Front View - if(self.FrontWire): # Wireframe is On so turn it off - self.FrontScene.setRenderModeWireframe(100); + if (self.CurrentQuad==1): # Front View + if(self.FrontWire): # Wireframe is On so turn it off + self.FrontScene.setRenderModeWireframe(100); self.FrontScene.setTwoSided(1); - self.FrontScene.setTextureOff(100) - self.FrontWire=0 - else: - self.FrontScene.clearRenderMode() - #self.FrontScene.setTwoSided(not self.backfaceCullingEnabled) - if(self.FrontTexture): - self.FrontScene.clearTexture() - self.FrontWire=1 - elif (self.CurrentQuad==2): # Front View - if(self.TopWire): # Wireframe is On so turn it off - self.TopScene.setRenderModeWireframe(100); + self.FrontScene.setTextureOff(100) + self.FrontWire=0 + else: + self.FrontScene.clearRenderMode() + #self.FrontScene.setTwoSided(not self.backfaceCullingEnabled) + if(self.FrontTexture): + self.FrontScene.clearTexture() + self.FrontWire=1 + elif (self.CurrentQuad==2): # Front View + if(self.TopWire): # Wireframe is On so turn it off + self.TopScene.setRenderModeWireframe(100); self.TopScene.setTwoSided(1); - self.TopScene.setTextureOff(100) - self.TopWire=0 - else: - self.TopScene.clearRenderMode() - #self.TopScene.setTwoSided(not self.backfaceCullingEnabled) - if(self.TopTexture): - self.TopScene.clearTexture() - self.TopWire=1 - elif (self.CurrentQuad==3): # Front View - if(self.LeftWire): # Wireframe is On so turn it off - self.LeftScene.setRenderModeWireframe(100); + self.TopScene.setTextureOff(100) + self.TopWire=0 + else: + self.TopScene.clearRenderMode() + #self.TopScene.setTwoSided(not self.backfaceCullingEnabled) + if(self.TopTexture): + self.TopScene.clearTexture() + self.TopWire=1 + elif (self.CurrentQuad==3): # Front View + if(self.LeftWire): # Wireframe is On so turn it off + self.LeftScene.setRenderModeWireframe(100); self.LeftScene.setTwoSided(1); - self.LeftScene.setTextureOff(100) - self.LeftWire=0 - else: - self.LeftScene.clearRenderMode() - #self.LeftScene.setTwoSided(not self.backfaceCullingEnabled) - if(self.LeftTexture): - self.LeftScene.clearTexture() - self.LeftWire=1 - elif (self.CurrentQuad==4): # Front View - if(self.PerspectiveWire): # Wireframe is On so turn it off - self.PerspectiveScene.setRenderModeWireframe(100); + self.LeftScene.setTextureOff(100) + self.LeftWire=0 + else: + self.LeftScene.clearRenderMode() + #self.LeftScene.setTwoSided(not self.backfaceCullingEnabled) + if(self.LeftTexture): + self.LeftScene.clearTexture() + self.LeftWire=1 + elif (self.CurrentQuad==4): # Front View + if(self.PerspectiveWire): # Wireframe is On so turn it off + self.PerspectiveScene.setRenderModeWireframe(100); self.PerspectiveScene.setTwoSided(1); - self.PerspectiveScene.setTextureOff(100) - self.PerspectiveWire=0 - else: - self.PerspectiveScene.clearRenderMode() - #self.PerspectiveScene.setTwoSided(not self.backfaceCullingEnabled) - if(self.PerspectiveTexture): - self.PerspectiveScene.clearTexture() - self.PerspectiveWire=1 + self.PerspectiveScene.setTextureOff(100) + self.PerspectiveWire=0 + else: + self.PerspectiveScene.clearRenderMode() + #self.PerspectiveScene.setTwoSided(not self.backfaceCullingEnabled) + if(self.PerspectiveTexture): + self.PerspectiveScene.clearTexture() + self.PerspectiveWire=1 def ToggleTexture(self): - if (self.CurrentQuad==1): # Front View - if(self.FrontTexture): # Texture is on so turn it off - self.FrontScene.setTextureOff(100) - self.FrontTexture=0; - else: - self.FrontScene.clearTexture() - self.FrontTexture=1 - elif (self.CurrentQuad==2): # Top View - if(self.TopTexture): # Texture is on so turn it off - self.TopScene.setTextureOff(100) - self.TopTexture=0; - else: - self.TopScene.clearTexture() - self.TopTexture=1 - elif (self.CurrentQuad==3): # Left View - if(self.LeftTexture): # Texture is on so turn it off - self.LeftScene.setTextureOff(100) - self.LeftTexture=0; - else: - self.LeftScene.clearTexture() - self.LeftTexture=1 - elif (self.CurrentQuad==4): # Perspective View - if(self.PerspectiveTexture): # Texture is on so turn it off - self.PerspectiveScene.setTextureOff(100) - self.PerspectiveTexture=0; - else: - self.PerspectiveScene.clearTexture() - self.PerspectiveTexture=1 + if (self.CurrentQuad==1): # Front View + if(self.FrontTexture): # Texture is on so turn it off + self.FrontScene.setTextureOff(100) + self.FrontTexture=0; + else: + self.FrontScene.clearTexture() + self.FrontTexture=1 + elif (self.CurrentQuad==2): # Top View + if(self.TopTexture): # Texture is on so turn it off + self.TopScene.setTextureOff(100) + self.TopTexture=0; + else: + self.TopScene.clearTexture() + self.TopTexture=1 + elif (self.CurrentQuad==3): # Left View + if(self.LeftTexture): # Texture is on so turn it off + self.LeftScene.setTextureOff(100) + self.LeftTexture=0; + else: + self.LeftScene.clearTexture() + self.LeftTexture=1 + elif (self.CurrentQuad==4): # Perspective View + if(self.PerspectiveTexture): # Texture is on so turn it off + self.PerspectiveScene.setTextureOff(100) + self.PerspectiveTexture=0; + else: + self.PerspectiveScene.clearTexture() + self.PerspectiveTexture=1 def reparenter(self): - #self.FrontScene.reparentTo(render) - #self.Front.setScene(render) - #self.Top.setScene(render) - #self.Left.setScene(render) - #self.Perspective.setScene(render) - pass + #self.FrontScene.reparentTo(render) + #self.Front.setScene(render) + #self.Top.setScene(render) + #self.Left.setScene(render) + #self.Perspective.setScene(render) + pass def unparenter(self): - #self.PerspectiveScene=render.copyTo(render) - #self.FrontScene=render.copyTo(render) - #self.TopScene=render.copyTo(render) - #self.LeftScene=render.copyTo(render) - #self.SceneParent.reparentTo(render) - #self.PerspectiveScene.reparentTo(self.SceneParent) - #self.FrontScene.reparentTo(self.SceneParent) - #self.TopScene.reparentTo(self.SceneParent) - #self.LeftScene.reparentTo(self.SceneParent) - pass + #self.PerspectiveScene=render.copyTo(render) + #self.FrontScene=render.copyTo(render) + #self.TopScene=render.copyTo(render) + #self.LeftScene=render.copyTo(render) + #self.SceneParent.reparentTo(render) + #self.PerspectiveScene.reparentTo(self.SceneParent) + #self.FrontScene.reparentTo(self.SceneParent) + #self.TopScene.reparentTo(self.SceneParent) + #self.LeftScene.reparentTo(self.SceneParent) + pass def AltHandler(self): - self.oldX=self.mouseWatcherNode.getMouseX() - if(self.oldX<-1 or self.oldX>1): - return - self.oldY=self.mouseWatcherNode.getMouseY() - if(self.oldY<-1 or self.oldY>1): - return - taskMgr.add(self.DragAction,'DragAction') - + self.oldX=self.mouseWatcherNode.getMouseX() + if(self.oldX<-1 or self.oldX>1): + return + self.oldY=self.mouseWatcherNode.getMouseY() + if(self.oldY<-1 or self.oldY>1): + return + taskMgr.add(self.DragAction,'DragAction') + def AltUpHandler(self): - taskMgr.remove('DragAction') - + taskMgr.remove('DragAction') + def gridtoggle(self): #grid=DirectGrid() - #grid.enable() - pass + #grid.enable() + pass def resizedr(self,x,y): - #print "X: " + str(x) + " Y: " + str(y) - x=(x+1)/2.0 - y=(y+1)/2.0 + #print "X: " + str(x) + " Y: " + str(y) + x=(x+1)/2.0 + y=(y+1)/2.0 self.Perspective.resize(x,y) - self.Top.resize(x,y) - self.Front.resize(x,y) - self.Left.resize(x,y) + self.Top.resize(x,y) + self.Front.resize(x,y) + self.Left.resize(x,y) def setAppropriateViewPort(self,x,y): - #print "SET APPROPRIATE:" + str(x) + " " + str(y) - if(x1): - return - self.oldY=self.mouseWatcherNode.getMouseY() - if(self.oldY<-1 or self.oldY>1): - return + base.mouseWatcherNode=self.mouseWatcherNode + + self.oldX=self.mouseWatcherNode.getMouseX() + if(self.oldX<-1 or self.oldX>1): + return + + self.oldY=self.mouseWatcherNode.getMouseY() + if(self.oldY<-1 or self.oldY>1): + return self.Mouse_Dragging=1 - taskMgr.add(self.DragAction,'DragAction') + taskMgr.add(self.DragAction,'DragAction') def MouseTellUp(self,buttoncode): - #self.MouseButton=0 - self.PanConstantX= 50 - self.PanConstantY= 50 - self.ZoomConstant=1 - taskMgr.remove('DragAction') - self.Mouse_Draggin=0 - #print "Mouse Up" - + #self.MouseButton=0 + self.PanConstantX= 50 + self.PanConstantY= 50 + self.ZoomConstant=1 + taskMgr.remove('DragAction') + self.Mouse_Draggin=0 + #print "Mouse Up" + def Max_Style_Mouse_View(self,buttoncode): - pass - + pass + def ChangeBaseDR(self): - dr=base.win.getDisplayRegion(0) - if(self.CurrentQuad==1): #Front - dr.setDimensions(0.5,1,0.5,1) - elif(self.CurrentQuad==2): #Top - dr.setDimensions(0,0.5,0.5,1) - elif(self.CurrentQuad==3): #Left - dr.setDimensions(0,0.5,0,0.5) - elif(self.CurrentQuad==4): #Perspective - dr.setDimensions(0.5,1,0,0.5) + dr=base.win.getDisplayRegion(0) + if(self.CurrentQuad==1): #Front + dr.setDimensions(0.5,1,0.5,1) + elif(self.CurrentQuad==2): #Top + dr.setDimensions(0,0.5,0.5,1) + elif(self.CurrentQuad==3): #Left + dr.setDimensions(0,0.5,0,0.5) + elif(self.CurrentQuad==4): #Perspective + dr.setDimensions(0.5,1,0,0.5) def setLeft(self): - print "LEFT" - self.CurrentQuad=3 - self.ChangeBaseDR() - self.Left.setCam() - #self.Left.setDR(self.mouseWatcherNode) + print "LEFT" + self.CurrentQuad=3 + self.ChangeBaseDR() + self.Left.setCam() + #self.Left.setDR(self.mouseWatcherNode) def setTop(self): - print "TOP" - self.CurrentQuad=2 - self.ChangeBaseDR() - self.Top.setCam() - #self.Top.setDR(self.mouseWatcherNode) + print "TOP" + self.CurrentQuad=2 + self.ChangeBaseDR() + self.Top.setCam() + #self.Top.setDR(self.mouseWatcherNode) def setPerspective(self): - print "PERSPECTIVE" - self.CurrentQuad=4 - self.ChangeBaseDR() - self.Perspective.setCam() - #self.Perspective.setDR(self.mouseWatcherNode) - + print "PERSPECTIVE" + self.CurrentQuad=4 + self.ChangeBaseDR() + self.Perspective.setCam() + #self.Perspective.setDR(self.mouseWatcherNode) + def setFront(self): - print "FRONT" - self.CurrentQuad=1 - self.ChangeBaseDR() - self.Front.setCam() - #self.Front.setDR(self.mouseWatcherNode) + print "FRONT" + self.CurrentQuad=1 + self.ChangeBaseDR() + self.Front.setCam() + #self.Front.setDR(self.mouseWatcherNode) def DragAction(self,task): #if(self.MouseDragging==1): self.currX= self.mouseWatcherNode.getMouseX() - if(self.currX<-1 or self.currX>1): - return - self.currY= self.mouseWatcherNode.getMouseY() - if(self.currY<-1 or self.currY>1): - return + if(self.currX<-1 or self.currX>1): + return + self.currY= self.mouseWatcherNode.getMouseY() + if(self.currY<-1 or self.currY>1): + return - self.diffX=self.currX-self.oldX - self.diffY=self.currY-self.oldY + self.diffX=self.currX-self.oldX + self.diffY=self.currY-self.oldY - if(self.ControlPressed): # Change Size of the ViewPorts - #if(base.getControl()): - self.VerticalAxis=self.currX - self.HorizontalAxis=self.currY - if(self.HorizontalAxis<-1 or self.HorizontalAxis>1 or self.VerticalAxis<-1 or self.VerticalAxis>1): - return - self.resizedr(self.VerticalAxis,self.HorizontalAxis) - - #if(self.AltPressed): # View Camera Transforms -> Maya style - elif(1): - #print "ALTPRESSED" - if(self.PanConstantX<4096): - self.PanConstantX= self.PanConstantX * 2 - self.PanConstantY= self.PanConstantY * 2 - self.ZoomConstant= self.ZoomConstant + 50 - if(self.MouseButton==1): # TrackBall rotation only for Perspective View - if(self.CurrentQuad==4): - pass + if(self.ControlPressed): # Change Size of the ViewPorts + #if(base.getControl()): + self.VerticalAxis=self.currX + self.HorizontalAxis=self.currY + if(self.HorizontalAxis<-1 or self.HorizontalAxis>1 or self.VerticalAxis<-1 or self.VerticalAxis>1): + return + self.resizedr(self.VerticalAxis,self.HorizontalAxis) + + #if(self.AltPressed): # View Camera Transforms -> Maya style + elif(1): + #print "ALTPRESSED" + if(self.PanConstantX<4096): + self.PanConstantX= self.PanConstantX * 2 + self.PanConstantY= self.PanConstantY * 2 + self.ZoomConstant= self.ZoomConstant + 50 + if(self.MouseButton==1): # TrackBall rotation only for Perspective View + if(self.CurrentQuad==4): + pass elif(self.MouseButton==2): # Do Panning - if(self.CurrentQuad==1): # Y and Z values change meanings for different cameras - self.MoveCamera(-self.diffX*self.PanConstantX,0,-self.diffY*self.PanConstantY,self.CurrentQuad) - elif(self.CurrentQuad==2): - self.MoveCamera(-self.diffX*self.PanConstantX,-self.diffY*self.PanConstantY,0,self.CurrentQuad) - elif(self.CurrentQuad==3): - self.MoveCamera(0,self.diffX*self.PanConstantX,-self.diffY*self.PanConstantY,self.CurrentQuad) - elif(self.CurrentQuad==4): - pass + if(self.CurrentQuad==1): # Y and Z values change meanings for different cameras + self.MoveCamera(-self.diffX*self.PanConstantX,0,-self.diffY*self.PanConstantY,self.CurrentQuad) + elif(self.CurrentQuad==2): + self.MoveCamera(-self.diffX*self.PanConstantX,-self.diffY*self.PanConstantY,0,self.CurrentQuad) + elif(self.CurrentQuad==3): + self.MoveCamera(0,self.diffX*self.PanConstantX,-self.diffY*self.PanConstantY,self.CurrentQuad) + elif(self.CurrentQuad==4): + pass elif(self.MouseButton==3): # Do Zoom - if(self.CurrentQuad==1): # Y and Z values change meanings for different cameras - #lens = OrthographicLens() + if(self.CurrentQuad==1): # Y and Z values change meanings for different cameras + #lens = OrthographicLens() #lens.setFilmSize(l,self.VP_height*200) - #lens.setFilmOffset((self.VP_X2 + self.VP_X1) * 0.5, (self.VP_Y2 + self.VP_Y1) * 0.5) - #lens.setNearFar(-1000, 1000) - self.FrontWidth= self.FrontWidth + self.diffX - self.FrontHeight= self.FrontHeight + self.diffX - self.FrontWidth= self.FrontWidth + self.diffY - self.FrontHeight= self.FrontHeight + self.diffY + #lens.setFilmOffset((self.VP_X2 + self.VP_X1) * 0.5, (self.VP_Y2 + self.VP_Y1) * 0.5) + #lens.setNearFar(-1000, 1000) + self.FrontWidth= self.FrontWidth + self.diffX + self.FrontHeight= self.FrontHeight + self.diffX + self.FrontWidth= self.FrontWidth + self.diffY + self.FrontHeight= self.FrontHeight + self.diffY + + if(self.FrontWidth<=0): + Frontwidth=1 + if(self.FrontHeight<=0): + FrontHeight=1 + self.frontCam.node().getLens().setFilmSize(self.FrontWidth,self.FrontHeight) + self.resizedr(self.VerticalAxis,self.HorizontalAxis) + elif(self.CurrentQuad==2): + self.TopWidth= self.TopWidth + self.diffX + self.TopHeight= self.TopHeight + self.diffX + self.TopWidth= self.TopWidth + self.diffY + self.TopHeight= self.TopHeight + self.diffY + self.topCam.node().getLens().setFilmSize(self.TopWidth,self.TopHeight) + self.resizedr(self.VerticalAxis,self.HorizontalAxis) + elif(self.CurrentQuad==3): + self.LeftWidth= self.LeftWidth + self.diffX + self.LeftHeight= self.LeftHeight + self.diffX + self.LeftWidth= self.LeftWidth + self.diffY + self.LeftHeight= self.LeftHeight + self.diffY + self.leftCam.node().getLens().setFilmSize(self.LeftWidth,self.LeftHeight) + self.resizedr(self.VerticalAxis,self.HorizontalAxis) + elif(self.CurrentQuad==4): + pass + else: + pass - if(self.FrontWidth<=0): - Frontwidth=1 - if(self.FrontHeight<=0): - FrontHeight=1 - self.frontCam.node().getLens().setFilmSize(self.FrontWidth,self.FrontHeight) - self.resizedr(self.VerticalAxis,self.HorizontalAxis) - elif(self.CurrentQuad==2): - self.TopWidth= self.TopWidth + self.diffX - self.TopHeight= self.TopHeight + self.diffX - self.TopWidth= self.TopWidth + self.diffY - self.TopHeight= self.TopHeight + self.diffY - self.topCam.node().getLens().setFilmSize(self.TopWidth,self.TopHeight) - self.resizedr(self.VerticalAxis,self.HorizontalAxis) - elif(self.CurrentQuad==3): - self.LeftWidth= self.LeftWidth + self.diffX - self.LeftHeight= self.LeftHeight + self.diffX - self.LeftWidth= self.LeftWidth + self.diffY - self.LeftHeight= self.LeftHeight + self.diffY - self.leftCam.node().getLens().setFilmSize(self.LeftWidth,self.LeftHeight) - self.resizedr(self.VerticalAxis,self.HorizontalAxis) - elif(self.CurrentQuad==4): - pass - else: - pass - self.oldX=self.currX self.oldY=self.currY return Task.cont @@ -659,16 +659,16 @@ class QuadView(DirectObject.DirectObject): def MoveCamera(self,X_amt,Y_amt,Z_amt,quad): - if(quad==1): + if(quad==1): self.frontCam.setPos(self.frontCam.getX()+X_amt,self.frontCam.getY()+Y_amt,self.frontCam.getZ()+Z_amt) - elif(quad==2): + elif(quad==2): self.topCam.setPos(self.topCam.getX()+X_amt,self.topCam.getY()+Y_amt,self.topCam.getZ()+Z_amt) - elif(quad==3): + elif(quad==3): self.leftCam.setPos(self.leftCam.getX()+X_amt,self.leftCam.getY()+Y_amt,self.leftCam.getZ()+Z_amt) - elif(quad==4): + elif(quad==4): self.perspectiveCam.setPos(self.perspectiveCam.getX()+X_amt,self.perspectiveCam.getY()+Y_amt,self.perspectiveCam.getZ()+Z_amt) - + #View=QuadView() -#run() \ No newline at end of file +#run() diff --git a/doc/SceneEditor/sceneEditor.py b/doc/SceneEditor/sceneEditor.py index 4b39c8606f..8833adcc74 100644 --- a/doc/SceneEditor/sceneEditor.py +++ b/doc/SceneEditor/sceneEditor.py @@ -147,7 +147,7 @@ class myLevelEditor(AppShell): self.initialiseoptions(myLevelEditor) self.parent.resizable(False,False) ## Disable the ability to resize for this Window. - + ######### Set the event handler ########## self.dataFlowEvents = [ ## Event from Side Window @@ -202,14 +202,14 @@ class myLevelEditor(AppShell): ['SEditor-ToggleBackface',self.toggleBackface], ['SEditor-ToggleTexture',self.toggleTexture], ['SEditor-ToggleWireframe',self.toggleWireframe], - ['ParticlePanel_Added_Effect',self.addParticleEffect], + ['ParticlePanel_Added_Effect',self.addParticleEffect], ] ################################# ### Collision detection ################################# - self.cTrav = CollisionTraverser() + self.cTrav = CollisionTraverser() base.cTrav = self.cTrav for event in self.dataFlowEvents: @@ -223,7 +223,7 @@ class myLevelEditor(AppShell): ['SGE_Remove', self.remove], ['SGE_Add Dummy', self.addDummyNode], ['SGE_Add Collision Object', self.addCollisionObj], - ['SGE_Metadata', self.openMetadataPanel], + ['SGE_Metadata', self.openMetadataPanel], ['SGE_Set as Reparent Target', self.setAsReparentTarget], ['SGE_Reparent to Target', self.reparentToNode], ['SGE_Animation Panel', self.openAnimPanel], @@ -255,17 +255,17 @@ class myLevelEditor(AppShell): ### Create SceneEditor Ver. DirectSession self.seSession = SeSession() self.seSession.enable() - SEditor.camera.setPos(0,-50,10) + SEditor.camera.setPos(0,-50,10) - self.placer=None - self.MopathPanel = None - self.alignPanelDict = {} - #self.quadview=QuadView() - + self.placer=None + self.MopathPanel = None + self.alignPanelDict = {} + #self.quadview=QuadView() - self.lightingPanel = None - self.controllerPanel = None - self.particlePanel = None + + self.lightingPanel = None + self.controllerPanel = None + self.particlePanel = None ### Create Side Window self.sideWindow = sideWindow(worldColor = self.worldColor, @@ -293,7 +293,7 @@ class myLevelEditor(AppShell): ### Creating the Buttons in the window frame ####################################################### buttonFrame = Frame(interior) - self.image=[] + self.image=[] self.image.append(PhotoImage(file='new.gif'))#0 self.image.append(PhotoImage(file='open.gif'))#1 self.image.append(PhotoImage(file='save.gif'))#2 @@ -314,9 +314,9 @@ class myLevelEditor(AppShell): self.image.append(PhotoImage(file='blank.gif')) self.image.append(PhotoImage(file='blank.gif')) self.image.append(PhotoImage(file='blank.gif')) - self.image.append(PhotoImage(file='blank.gif')) - self.image.append(PhotoImage(file='blank.gif')) - self.image.append(PhotoImage(file='blank.gif')) + self.image.append(PhotoImage(file='blank.gif')) + self.image.append(PhotoImage(file='blank.gif')) + self.image.append(PhotoImage(file='blank.gif')) i = 0 @@ -324,11 +324,11 @@ class myLevelEditor(AppShell): i += 1 button = Button(buttonFrame, image = element, command=lambda n=i : self.buttonPushed(n)) button.pack(fill=X, side = LEFT) - + buttonFrame.pack(fill=X, side=LEFT,expand=True) - - + + def buttonPushed(self, buttonIndex): ################################################################# # buttonPushed(self, buttonNum) @@ -339,8 +339,8 @@ class myLevelEditor(AppShell): #### Change here to process the button event further. #### if buttonIndex==1: # New Scene - self.newScene() - return + self.newScene() + return elif buttonIndex==2: # Open Scene self.openScene() return @@ -357,13 +357,13 @@ class myLevelEditor(AppShell): self.openPlacerPanel() return elif buttonIndex==7: # Open Mopath Panel - self.openMoPathPanel() + self.openMoPathPanel() return elif buttonIndex==8: # Open Lighting Panel self.openLightingPanel() return elif buttonIndex==9: # Open Particle Panel - self.openParticlePanel() + self.openParticlePanel() return elif buttonIndex==10: self.openInputPanel() @@ -570,7 +570,7 @@ class myLevelEditor(AppShell): ## Processing message events def makeDirty(self): - self.Dirty=1 + self.Dirty=1 def removeLight(self, lightNode): ################################################################# @@ -627,7 +627,7 @@ class myLevelEditor(AppShell): list, lightNode = AllScene.createLight(type = type) if self.lightingPanel != None: self.lightingPanel.updateList(list,lightNode) - self.makeDirty() + self.makeDirty() return def lightingPanelClose(self): @@ -662,9 +662,9 @@ class myLevelEditor(AppShell): return def openMetadataPanel(self,nodePath=None): - print nodePath - self.MetadataPanel=MetadataPanel(nodePath) - pass + print nodePath + self.MetadataPanel=MetadataPanel(nodePath) + pass def duplicate(self, nodePath = None): ################################################################# @@ -706,7 +706,7 @@ class myLevelEditor(AppShell): # ################################################################# AllScene.addDummyNode(nodepath) - self.makeDirty() + self.makeDirty() pass def addCollisionObj(self, nodepath = None): @@ -820,67 +820,67 @@ class myLevelEditor(AppShell): # and will reset the application title to "New Scene" ################################################################# self.closeAllSubWindows() ## Close all sub window - if(self.CurrentFileName): - currentF=Filename(self.CurrentFileName) - self.CurrentFileName=None + if(self.CurrentFileName): + currentF=Filename(self.CurrentFileName) + self.CurrentFileName=None AllScene.resetAll() - currentModName=currentF.getBasenameWoExtension() - # 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 - # If there is ever a garbage colleciton bug..this might be a point to look at - if sys.modules.has_key(currentModName): - del sys.modules[currentModName] - print sys.getrefcount(AllScene.theScene) - del AllScene.theScene - else: - AllScene.resetAll() - self.parent.title('Scene Editor - New Scene') + currentModName=currentF.getBasenameWoExtension() + # 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 + # If there is ever a garbage colleciton bug..this might be a point to look at + if sys.modules.has_key(currentModName): + del sys.modules[currentModName] + print sys.getrefcount(AllScene.theScene) + del AllScene.theScene + else: + AllScene.resetAll() + self.parent.title('Scene Editor - New Scene') pass def 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): - saveScene = tkMessageBox._show("Load scene","Save the current scene?",icon = tkMessageBox.QUESTION,type = tkMessageBox.YESNOCANCEL) - if (saveScene == "yes"): - self.saveScene() - elif (saveScene == "cancel"): - return + saveScene = tkMessageBox._show("Load scene","Save the current scene?",icon = tkMessageBox.QUESTION,type = tkMessageBox.YESNOCANCEL) + if (saveScene == "yes"): + self.saveScene() + elif (saveScene == "cancel"): + return self.closeAllSubWindows() ## Close all sub window - if(self.CurrentFileName): - currentF=Filename(self.CurrentFileName) - AllScene.resetAll() - currentModName=currentF.getBasenameWoExtension() - # 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 - # If there is ever a garbage colleciton bug..this might be a point to look at - if sys.modules.has_key(currentModName): - del sys.modules[currentModName] - print sys.getrefcount(AllScene.theScene) - del AllScene.theScene + if(self.CurrentFileName): + currentF=Filename(self.CurrentFileName) + AllScene.resetAll() + currentModName=currentF.getBasenameWoExtension() + # 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 + # If there is ever a garbage colleciton bug..this might be a point to look at + if sys.modules.has_key(currentModName): + del sys.modules[currentModName] + print sys.getrefcount(AllScene.theScene) + del AllScene.theScene else: - AllScene.resetAll() + AllScene.resetAll() - self.CurrentFileName = AllScene.loadScene() - - if(self.CurrentFileName==None): - return + self.CurrentFileName = AllScene.loadScene() - thefile=Filename(self.CurrentFileName) - thedir=thefile.getFullpathWoExtension() - print "SCENE EDITOR::" + thedir - self.CurrentDirName=thedir - if self.CurrentFileName != None: + if(self.CurrentFileName==None): + return + + thefile=Filename(self.CurrentFileName) + thedir=thefile.getFullpathWoExtension() + print "SCENE EDITOR::" + thedir + self.CurrentDirName=thedir + if self.CurrentFileName != None: self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) - if self.lightingPanel !=None: + if self.lightingPanel !=None: lightList=AllScene.getList() self.lightingPanel.updateList(lightList) messenger.send('SGE_Update Explorer',[render]) - + # Close the side window in order to reset all world settings to fit the scene we have loaded. self.sideWindow.quit() @@ -905,45 +905,45 @@ class myLevelEditor(AppShell): # If this filename exists in sys.modules you cannot use it ################################################################# - if(self.CurrentFileName): - f=FileSaver() - f.SaveFile(AllScene,self.CurrentFileName,self.CurrentDirName,1) - self.Dirty=0 - else: - self.saveAsScene() + if(self.CurrentFileName): + f=FileSaver() + f.SaveFile(AllScene,self.CurrentFileName,self.CurrentDirName,1) + self.Dirty=0 + else: + self.saveAsScene() pass def saveAsScene(self): ################################################################# - # saveAsScene(self) + # saveAsScene(self) # Ask for filename using a file save dialog # If this filename exists in sys.modules you cannot use it # Instantiate FileSaver from seFileSaver.py and pass it the filename ################################################################# fileName = tkFileDialog.asksaveasfilename(filetypes = [("PY","py")],title = "Save Scene") - if(not fileName): - return - fCheck=Filename(fileName) - #print fCheck.getBasenameWoExtension() - ############################################################################### - # !!!!! See if a module exists by this name... if it does you cannot use this filename !!!!! - ############################################################################### - if(sys.modules.has_key(fCheck.getBasenameWoExtension())): - tkMessageBox.showwarning( + if(not fileName): + return + fCheck=Filename(fileName) + #print fCheck.getBasenameWoExtension() + ############################################################################### + # !!!!! See if a module exists by this name... if it does you cannot use this filename !!!!! + ############################################################################### + if(sys.modules.has_key(fCheck.getBasenameWoExtension())): + tkMessageBox.showwarning( "Save file", "Cannot save with this name because there is a system module with the same name. Please resave as something else." - ) + ) - return - self.CurrentDirName=fileName - fileName=fileName+".py" + return + self.CurrentDirName=fileName + fileName=fileName+".py" f=FileSaver() - self.CurrentFileName=fileName - f.SaveFile(AllScene,fileName,self.CurrentDirName,0) - self.Dirty=0 - self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) + self.CurrentFileName=fileName + f.SaveFile(AllScene,fileName,self.CurrentDirName,0) + self.Dirty=0 + self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) pass def loadModel(self): @@ -962,7 +962,7 @@ class myLevelEditor(AppShell): title = 'Load New Model', parent = self.parent) if modelFilename: - self.makeDirty() + self.makeDirty() if not AllScene.loadModel(modelFilename, Filename.fromOsSpecific(modelFilename)): print '----Error! No Such Model File!' pass @@ -983,9 +983,9 @@ class myLevelEditor(AppShell): title = 'Load New Actor', parent = self.parent) - + if ActorFilename: - self.makeDirty() + self.makeDirty() if not AllScene.loadActor(ActorFilename, Filename.fromOsSpecific(ActorFilename)): print '----Error! No Such Model File!' pass @@ -1162,24 +1162,24 @@ class myLevelEditor(AppShell): return def addParticleEffect(self,effect_name,effect,node): - AllScene.particleDict[effect_name]=effect - AllScene.particleNodes[effect_name]=node - if not self.ParticleEnable: + AllScene.particleDict[effect_name]=effect + AllScene.particleNodes[effect_name]=node + if not self.ParticleEnable: AllScene.particleNodes[effect_name].setTransparency(True) AllScene.particleNodes[effect_name].setAlphaScale(0) AllScene.particleNodes[effect_name].setBin("fixed",1) - return + return def openParticlePanel(self): if self.particlePanel != None: ## There already has a Particle panel! return - if(len(AllScene.particleDict)==0): - self.particlePanel=seParticlePanel.ParticlePanel() - else: - for effect in AllScene.particleDict: - theeffect=AllScene.particleDict[effect] - self.particlePanel=seParticlePanel.ParticlePanel(particleEffect=theeffect,effectsDict=AllScene.particleDict) + if(len(AllScene.particleDict)==0): + self.particlePanel=seParticlePanel.ParticlePanel() + else: + for effect in AllScene.particleDict: + theeffect=AllScene.particleDict[effect] + self.particlePanel=seParticlePanel.ParticlePanel(particleEffect=theeffect,effectsDict=AllScene.particleDict) pass @@ -1325,7 +1325,7 @@ class myLevelEditor(AppShell): self.menuEdit.entryconfig('Duplicate', state=NORMAL) self.menuEdit.entryconfig('Remove', state=NORMAL) self.menuEdit.entryconfig('Object Properties', state=NORMAL) - if callBack: + if callBack: self.seSession.select(nodePath,fResetAncestry=1) messenger.send('SGE_Update Explorer',[render]) if not taskMgr.hasTaskNamed('seMonitorSelectedNode'): diff --git a/doc/SceneEditor/seAnimPanel.py b/doc/SceneEditor/seAnimPanel.py index 009ef70631..7829ddffa7 100644 --- a/doc/SceneEditor/seAnimPanel.py +++ b/doc/SceneEditor/seAnimPanel.py @@ -603,6 +603,6 @@ class LoadAnimPanel(AppShell): # Then, it will close the panel itself. ################################################################# messenger.send('AW_AnimationLoad',[self.Actor,self.animDic]) - #print self.animDic + #print self.animDic self.quit() return diff --git a/doc/SceneEditor/seFileSaver.py b/doc/SceneEditor/seFileSaver.py index 045aa8419b..bbe2f46193 100644 --- a/doc/SceneEditor/seFileSaver.py +++ b/doc/SceneEditor/seFileSaver.py @@ -31,696 +31,696 @@ class FileSaver: #################################################################################################################################################### def __init(self): - pass + pass def SaveFile(self,AllScene,filename,dirname,reSaveFlag=0): - ################################################################################################################################################ - # This function takes the "dataHolder" instance "AllScene" which has dictionaries containing scene information - # The filename is where the scene will be written to - ################################################################################################################################################ - - i1=" " # indentation - i2=i1+i1 # double indentation - out_file = open(filename,"w") - print "dirname:" + dirname - if( not os.path.isdir(dirname)): - os.mkdir(dirname) - savepathname=Filename(filename) - self.savepath=savepathname.getBasenameWoExtension() - out_file.write("##########################################################################################################\n") - out_file.write("# Auto Generated Code by Scene Editor\n") - out_file.write("# Edit with caution\n") - out_file.write("# Using this file in your code:\n") - out_file.write("# For example, if you have named this file as \"myscene.py\"\n") - out_file.write("# Do the following:\n") - out_file.write("# from myscene import * \n") - out_file.write("# theScene=SavedScene() #instantiate the class\n") - out_file.write("# IMPORTANT: All the documentation below refers to \"theScene\" as the instance of SavedScene()\n") - out_file.write("##########################################################################################################\n\n") - - out_file.write("##########################################################################################################\n") - out_file.write("# Import Panda Modules\n") - out_file.write("##########################################################################################################\n") - out_file.write("from ShowBaseGlobal import * # Core functionality for running the \"show\"\n") - out_file.write("import Actor # Importing models with animations\n") - out_file.write("import Mopath # Motion Paths\n") - out_file.write("import MopathInterval # Motion Paths\n") - out_file.write("from IntervalGlobal import * # Intervals for interpolation, sequencing and parallelization\n") - out_file.write("import ParticleEffect # Particle Systems\n") - out_file.write("import ForceGroup # Forces acting on Particles\n") - out_file.write("import Particles\n\n") - out_file.write("##########################################################################################################\n") - out_file.write("# This class stores the entire scene\n") - out_file.write("##########################################################################################################\n\n") - out_file.write("class SavedScene(DirectObject): # We inherit from DirectObject so that we can use self.accept method to catch messages\n") + ################################################################################################################################################ + # This function takes the "dataHolder" instance "AllScene" which has dictionaries containing scene information + # The filename is where the scene will be written to + ################################################################################################################################################ + + i1=" " # indentation + i2=i1+i1 # double indentation + out_file = open(filename,"w") + print "dirname:" + dirname + if( not os.path.isdir(dirname)): + os.mkdir(dirname) + savepathname=Filename(filename) + self.savepath=savepathname.getBasenameWoExtension() + out_file.write("##########################################################################################################\n") + out_file.write("# Auto Generated Code by Scene Editor\n") + out_file.write("# Edit with caution\n") + out_file.write("# Using this file in your code:\n") + out_file.write("# For example, if you have named this file as \"myscene.py\"\n") + out_file.write("# Do the following:\n") + out_file.write("# from myscene import * \n") + out_file.write("# theScene=SavedScene() #instantiate the class\n") + out_file.write("# IMPORTANT: All the documentation below refers to \"theScene\" as the instance of SavedScene()\n") + out_file.write("##########################################################################################################\n\n") + + out_file.write("##########################################################################################################\n") + out_file.write("# Import Panda Modules\n") + out_file.write("##########################################################################################################\n") + out_file.write("from ShowBaseGlobal import * # Core functionality for running the \"show\"\n") + out_file.write("import Actor # Importing models with animations\n") + out_file.write("import Mopath # Motion Paths\n") + out_file.write("import MopathInterval # Motion Paths\n") + out_file.write("from IntervalGlobal import * # Intervals for interpolation, sequencing and parallelization\n") + out_file.write("import ParticleEffect # Particle Systems\n") + out_file.write("import ForceGroup # Forces acting on Particles\n") + out_file.write("import Particles\n\n") + out_file.write("##########################################################################################################\n") + out_file.write("# This class stores the entire scene\n") + out_file.write("##########################################################################################################\n\n") + out_file.write("class SavedScene(DirectObject): # We inherit from DirectObject so that we can use self.accept method to catch messages\n") out_file.write("\n") - out_file.write(i1+"# These dictionaries are required for re-loading a scene in the editor\n") - out_file.write(i1+"# They can be used to access the objects as well\n\n") - out_file.write(i1+"ModelDic={}# Stores all the models and static geometry\n") - out_file.write(i1+"ModelRefDic={}# Stores the paths to the models\n") + out_file.write(i1+"# These dictionaries are required for re-loading a scene in the editor\n") + out_file.write(i1+"# They can be used to access the objects as well\n\n") + out_file.write(i1+"ModelDic={}# Stores all the models and static geometry\n") + out_file.write(i1+"ModelRefDic={}# Stores the paths to the models\n") out_file.write("\n") - out_file.write(i1+"ActorDic={}# Stores all the actors\n") - out_file.write(i1+"ActorRefDic={}# Stores the paths to the actors\n") - out_file.write(i1+"ActorAnimsDic={}# Stores the animations for each actor\n") - out_file.write(i1+"blendAnimDict={}# Stores all the blended animations\n") + out_file.write(i1+"ActorDic={}# Stores all the actors\n") + out_file.write(i1+"ActorRefDic={}# Stores the paths to the actors\n") + out_file.write(i1+"ActorAnimsDic={}# Stores the animations for each actor\n") + out_file.write(i1+"blendAnimDict={}# Stores all the blended animations\n") out_file.write("\n") - out_file.write(i1+"LightDict={}# Stores all the lights\n") - out_file.write(i1+"LightTypes={}# Stores types for the lights\n") - out_file.write(i1+"LightNodes={}# Stores the actual nodes for the lights\n") + out_file.write(i1+"LightDict={}# Stores all the lights\n") + out_file.write(i1+"LightTypes={}# Stores types for the lights\n") + out_file.write(i1+"LightNodes={}# Stores the actual nodes for the lights\n") out_file.write("\n") - out_file.write(i1+"dummyDict={}# Stores dummies\n") + out_file.write(i1+"dummyDict={}# Stores dummies\n") out_file.write("\n") - out_file.write(i1+"collisionDict={}# Stores Collision information\n") + out_file.write(i1+"collisionDict={}# Stores Collision information\n") out_file.write("\n") - out_file.write(i1+"curveDict={}# Stores Mopath information\n") - out_file.write(i1+"curveIntervals=[]# Stores list of mopath intervals\n") - out_file.write(i1+"curveRefColl=[]# Stores paths to mopaths\n") - out_file.write(i1+"curveIntervalsDict={}# Stores mopath intervals\n") + out_file.write(i1+"curveDict={}# Stores Mopath information\n") + out_file.write(i1+"curveIntervals=[]# Stores list of mopath intervals\n") + out_file.write(i1+"curveRefColl=[]# Stores paths to mopaths\n") + out_file.write(i1+"curveIntervalsDict={}# Stores mopath intervals\n") out_file.write("\n") - out_file.write(i1+"particleDict={}# Stores particles\n") - out_file.write(i1+"particleNodes={}# Stores particle nodes\n") + out_file.write(i1+"particleDict={}# Stores particles\n") + out_file.write(i1+"particleNodes={}# Stores particle nodes\n") out_file.write("\n") out_file.write(i1+"#Light Count\n") - out_file.write(i1+"ambientCount=0\n") - out_file.write(i1+"directionalCount=0\n") - out_file.write(i1+"pointCount=0\n") - out_file.write(i1+"spotCount=0\n") + out_file.write(i1+"ambientCount=0\n") + out_file.write(i1+"directionalCount=0\n") + out_file.write(i1+"pointCount=0\n") + out_file.write(i1+"spotCount=0\n") out_file.write("\n") - out_file.write(i1+"#Lighting Attribute\n") - out_file.write(i1+"lightAttrib = LightAttrib.makeAllOff()# Initialize lighting\n") + out_file.write(i1+"#Lighting Attribute\n") + out_file.write(i1+"lightAttrib = LightAttrib.makeAllOff()# Initialize lighting\n") out_file.write("\n") - out_file.write(i1+"CollisionHandler=CollisionHandlerEvent()# Setup a Collision Handler\n") + out_file.write(i1+"CollisionHandler=CollisionHandlerEvent()# Setup a Collision Handler\n") - out_file.write(i1+"##########################################################################################################\n") - out_file.write(i1+"# Constructor: this is run first when you instantiate the SavedScene class\n") - out_file.write(i1+"##########################################################################################################\n") - out_file.write(i1+"def __init__(self,loadmode=1,seParticleEffect=None,seParticles=None,executionpath=None):# loadmode 0 specifies that this file is being loaded by the scene editor and it passes its own versions of the particle fx modules\n") - out_file.write("\n") - out_file.write(i2+"self.loadmode=loadmode\n") - out_file.write(i2+"self.seParticleEffect=seParticleEffect\n") - out_file.write(i2+"self.seParticles=seParticles\n") - out_file.write(i2+"self.executionpath=executionpath\n") + out_file.write(i1+"##########################################################################################################\n") + out_file.write(i1+"# Constructor: this is run first when you instantiate the SavedScene class\n") + out_file.write(i1+"##########################################################################################################\n") + out_file.write(i1+"def __init__(self,loadmode=1,seParticleEffect=None,seParticles=None,executionpath=None):# loadmode 0 specifies that this file is being loaded by the scene editor and it passes its own versions of the particle fx modules\n") out_file.write("\n") - out_file.write(i2+"base.enableParticles()# Enable Particle effects\n") + out_file.write(i2+"self.loadmode=loadmode\n") + out_file.write(i2+"self.seParticleEffect=seParticleEffect\n") + out_file.write(i2+"self.seParticles=seParticles\n") + out_file.write(i2+"self.executionpath=executionpath\n") out_file.write("\n") - out_file.write(i2+"self.cTrav = CollisionTraverser() # Setup a traverser for collisions\n") - out_file.write(i2+"base.cTrav = self.cTrav\n") - out_file.write(i2+"self.CollisionHandler.setInPattern(\"enter%in\")# The message to be raised when something enters a collision node\n") - out_file.write(i2+"self.CollisionHandler.setOutPattern(\"exit%in\")# The message to be raised when something exits a collision node\n") + out_file.write(i2+"base.enableParticles()# Enable Particle effects\n") out_file.write("\n") - #################################################################################################################################################### - # Save Models - #################################################################################################################################################### + out_file.write(i2+"self.cTrav = CollisionTraverser() # Setup a traverser for collisions\n") + out_file.write(i2+"base.cTrav = self.cTrav\n") + out_file.write(i2+"self.CollisionHandler.setInPattern(\"enter%in\")# The message to be raised when something enters a collision node\n") + out_file.write(i2+"self.CollisionHandler.setOutPattern(\"exit%in\")# The message to be raised when something exits a collision node\n") + out_file.write("\n") + #################################################################################################################################################### + # Save Models + #################################################################################################################################################### - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Code for all the models\n") - out_file.write(i2+"# To access these models:\n") - out_file.write(i2+"# theScene.ModelDic[\"'Model_Name\"']\n") - out_file.write(i2+"# where theScene is the SavedScene class instance\n") - out_file.write(i2+"# Properties saved include:\n") - out_file.write(i2+"# Transformations\n") - out_file.write(i2+"# Alpha and color\n") - out_file.write(i2+"# Parent and child information\n") - out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Code for all the models\n") + out_file.write(i2+"# To access these models:\n") + out_file.write(i2+"# theScene.ModelDic[\"'Model_Name\"']\n") + out_file.write(i2+"# where theScene is the SavedScene class instance\n") + out_file.write(i2+"# Properties saved include:\n") + out_file.write(i2+"# Transformations\n") + out_file.write(i2+"# Alpha and color\n") + out_file.write(i2+"# Parent and child information\n") + out_file.write(i2+"##########################################################################################################\n") - for model in AllScene.ModelDic: + for model in AllScene.ModelDic: out_file.write("\n") - modelS=str(model) - - if(1): # This is kept for now... perhaps later some sort of check might have to be enforced based on loadMode + modelS=str(model) + + if(1): # This is kept for now... perhaps later some sort of check might have to be enforced based on loadMode #Loading Code - out_file.write(i2+"# Loading model's egg file\n") - #out_file.write(i2+ "self."+ modelS + "=loader.loadModel(\'" + AllScene.ModelRefDic[model].getFullpath() + "\')\n")#Absolute Paths + out_file.write(i2+"# Loading model's egg file\n") + #out_file.write(i2+ "self."+ modelS + "=loader.loadModel(\'" + AllScene.ModelRefDic[model].getFullpath() + "\')\n")#Absolute Paths - newpath = dirname + "/" + AllScene.ModelRefDic[model].getBasename() - newpathF=Filename(newpath) - newpathSpecific=newpathF.toOsSpecific() + newpath = dirname + "/" + AllScene.ModelRefDic[model].getBasename() + newpathF=Filename(newpath) + newpathSpecific=newpathF.toOsSpecific() - # Copy all the textures referenced by this file over to the relative directory - fnamelist=[] - modelData=EggData() - modelData.read(AllScene.ModelRefDic[model]) - textures=EggTextureCollection() - textures.findUsedTextures(modelData) - for index in range(textures.getNumTextures()): - texture=textures.getTexture(index) - texfilename=texture.getFilename() - fnamelist.append(texfilename.getFullpath()) - oldFilename=Filename(Filename(AllScene.ModelRefDic[model].getDirname()),texfilename) - if(not oldFilename.isRegularFile()): - if(texfilename.resolveFilename(getTexturePath(),"")): - oldFilename=texfilename - oldtexpath=oldFilename.toOsSpecific(); - - newtexpath=dirname + "/" + texfilename.getBasename() - newtexpathF=Filename(newtexpath) - newtexpathSpecific=newtexpathF.toOsSpecific() - - print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific - if(oldtexpath != newtexpathSpecific): - shutil.copyfile(oldtexpath,newtexpathSpecific) + # Copy all the textures referenced by this file over to the relative directory + fnamelist=[] + modelData=EggData() + modelData.read(AllScene.ModelRefDic[model]) + textures=EggTextureCollection() + textures.findUsedTextures(modelData) + for index in range(textures.getNumTextures()): + texture=textures.getTexture(index) + texfilename=texture.getFilename() + fnamelist.append(texfilename.getFullpath()) + oldFilename=Filename(Filename(AllScene.ModelRefDic[model].getDirname()),texfilename) + if(not oldFilename.isRegularFile()): + if(texfilename.resolveFilename(getTexturePath(),"")): + oldFilename=texfilename + oldtexpath=oldFilename.toOsSpecific(); - - - + newtexpath=dirname + "/" + texfilename.getBasename() + newtexpathF=Filename(newtexpath) + newtexpathSpecific=newtexpathF.toOsSpecific() - - # Copy the file over to the relative directory - oldModelpath=AllScene.ModelRefDic[model].toOsSpecific() - print "FILESAVER:: copying from " + AllScene.ModelRefDic[model].toOsSpecific() + "to" + newpathSpecific - if(oldModelpath!=newpathSpecific): - shutil.copyfile(oldModelpath,newpathSpecific) - - - e=EggData() - e.read(AllScene.ModelRefDic[model]) - etc=EggTextureCollection() - etc.extractTextures(e) - for index in range(len(fnamelist)): - print fnamelist[index] - tex=etc.findFilename(Filename(fnamelist[index])) - fn=Filename(tex.getFilename()) - fn.setDirname("") - tex.setFilename(fn) - e.writeEgg(Filename.fromOsSpecific(newpathSpecific)) - + print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific + if(oldtexpath != newtexpathSpecific): + shutil.copyfile(oldtexpath,newtexpathSpecific) - out_file.write(i2+"if(self.loadmode==1):\n") - out_file.write(i2+i1+ "self."+ modelS + "=loader.loadModel(\'" + self.savepath + "/" + AllScene.ModelRefDic[model].getBasename() + "')\n")#Relative Path - out_file.write(i2+"else:\n") - out_file.write(i2+i1+ "self."+ modelS + "=loader.loadModel(self.executionpath + \'/" + AllScene.ModelRefDic[model].getBasename() + "')\n")#Relative Path with execution point specified by the invoking-level-editor - #Transformation Code + + + + # Copy the file over to the relative directory + oldModelpath=AllScene.ModelRefDic[model].toOsSpecific() + print "FILESAVER:: copying from " + AllScene.ModelRefDic[model].toOsSpecific() + "to" + newpathSpecific + if(oldModelpath!=newpathSpecific): + shutil.copyfile(oldModelpath,newpathSpecific) + + + e=EggData() + e.read(AllScene.ModelRefDic[model]) + etc=EggTextureCollection() + etc.extractTextures(e) + for index in range(len(fnamelist)): + print fnamelist[index] + tex=etc.findFilename(Filename(fnamelist[index])) + fn=Filename(tex.getFilename()) + fn.setDirname("") + tex.setFilename(fn) + e.writeEgg(Filename.fromOsSpecific(newpathSpecific)) + + + + out_file.write(i2+"if(self.loadmode==1):\n") + out_file.write(i2+i1+ "self."+ modelS + "=loader.loadModel(\'" + self.savepath + "/" + AllScene.ModelRefDic[model].getBasename() + "')\n")#Relative Path + out_file.write(i2+"else:\n") + out_file.write(i2+i1+ "self."+ modelS + "=loader.loadModel(self.executionpath + \'/" + AllScene.ModelRefDic[model].getBasename() + "')\n")#Relative Path with execution point specified by the invoking-level-editor + + #Transformation Code out_file.write("\n") - out_file.write(i2+"# Transforming the model\n") - out_file.write(i2+ "self."+ modelS + ".setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"% (AllScene.ModelDic[model].getX(),AllScene.ModelDic[model].getY(),AllScene.ModelDic[model].getZ(),AllScene.ModelDic[model].getH(),AllScene.ModelDic[model].getP(),AllScene.ModelDic[model].getR(),AllScene.ModelDic[model].getSx(),AllScene.ModelDic[model].getSy(),AllScene.ModelDic[model].getSz())) + out_file.write(i2+"# Transforming the model\n") + out_file.write(i2+ "self."+ modelS + ".setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"% (AllScene.ModelDic[model].getX(),AllScene.ModelDic[model].getY(),AllScene.ModelDic[model].getZ(),AllScene.ModelDic[model].getH(),AllScene.ModelDic[model].getP(),AllScene.ModelDic[model].getR(),AllScene.ModelDic[model].getSx(),AllScene.ModelDic[model].getSy(),AllScene.ModelDic[model].getSz())) - if(AllScene.ModelDic[model].hasTransparency()): + if(AllScene.ModelDic[model].hasTransparency()): out_file.write("\n") - out_file.write(i2+"# Alpha\n") - out_file.write(i2+ "self."+ modelS + ".setTransparency(1)\n") - clr=AllScene.ModelDic[model].getColor() - out_file.write(i2+ "self."+ modelS + ".setColor(%.4f,%.4f,%.4f,%.4f)\n"%(clr.getX(),clr.getY(),clr.getZ(),clr.getW())) + out_file.write(i2+"# Alpha\n") + out_file.write(i2+ "self."+ modelS + ".setTransparency(1)\n") + clr=AllScene.ModelDic[model].getColor() + out_file.write(i2+ "self."+ modelS + ".setColor(%.4f,%.4f,%.4f,%.4f)\n"%(clr.getX(),clr.getY(),clr.getZ(),clr.getW())) out_file.write("\n") - out_file.write(i2+ "# Reparent To Render for now and later we update all the parentings\n") - out_file.write(i2+ "self."+ modelS + ".reparentTo(render)\n") + out_file.write(i2+ "# Reparent To Render for now and later we update all the parentings\n") + out_file.write(i2+ "self."+ modelS + ".reparentTo(render)\n") out_file.write("\n") - out_file.write(i2+ "# Save Metadata...can be retrieved by doing theScene.ModelDic[\"Model_Name\"].getTag(\"Metadata\")\n") - out_file.write(i2+ "self."+ modelS + ".setTag(\"Metadata\",\"" + AllScene.ModelDic[model].getTag("Metadata") + "\")\n") + out_file.write(i2+ "# Save Metadata...can be retrieved by doing theScene.ModelDic[\"Model_Name\"].getTag(\"Metadata\")\n") + out_file.write(i2+ "self."+ modelS + ".setTag(\"Metadata\",\"" + AllScene.ModelDic[model].getTag("Metadata") + "\")\n") out_file.write("\n") - out_file.write(i2+ "# Fill in the dictionaries which are used by level Ed to reload state\n") + out_file.write(i2+ "# Fill in the dictionaries which are used by level Ed to reload state\n") out_file.write(i2+ "self.ModelDic[\'" + modelS + "\']=self." + AllScene.ModelDic[model].getName()+"\n") #out_file.write(i2+ "self.ModelRefDic[\'" + modelS + "\']=Filename(\'"+ AllScene.ModelRefDic[model].getFullpath() +"\')\n")# The old Absolute Path way - out_file.write(i2+ "self.ModelRefDic[\'" + modelS + "\']=\'"+ AllScene.ModelRefDic[model].getBasename() +"\'\n")# Relative paths - out_file.write(i2+ "self.ModelDic[\'"+ modelS + "\'].setName(\'"+ modelS +"\')\n") + out_file.write(i2+ "self.ModelRefDic[\'" + modelS + "\']=\'"+ AllScene.ModelRefDic[model].getBasename() +"\'\n")# Relative paths + out_file.write(i2+ "self.ModelDic[\'"+ modelS + "\'].setName(\'"+ modelS +"\')\n") out_file.write("\n") - #################################################################################################################################################### - # Save Dummies - #################################################################################################################################################### - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Code for all the Dummy Objects\n") - out_file.write(i2+"# To access the dummies\n") - out_file.write(i2+"# theScene.dummyDict['Dummy_Name']\n") - out_file.write(i2+"##########################################################################################################\n") + #################################################################################################################################################### + # Save Dummies + #################################################################################################################################################### + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Code for all the Dummy Objects\n") + out_file.write(i2+"# To access the dummies\n") + out_file.write(i2+"# theScene.dummyDict['Dummy_Name']\n") + out_file.write(i2+"##########################################################################################################\n") for dummy in AllScene.dummyDict: out_file.write("\n") - dummyS=str(dummy) - + dummyS=str(dummy) + if(1): # This is kept for now... perhaps later some sort of check might have to be enforced based on loadMode - out_file.write(i2+ "self."+ dummyS + "=loader.loadModelCopy(\"misc/sphere\")\n") - #Transformation Code - out_file.write(i2+"# Transforming the Dummy\n") - out_file.write(i2+ "self."+ dummyS + ".setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"% (AllScene.dummyDict[dummy].getX(),AllScene.dummyDict[dummy].getY(),AllScene.dummyDict[dummy].getZ(),AllScene.dummyDict[dummy].getH(),AllScene.dummyDict[dummy].getP(),AllScene.dummyDict[dummy].getR(),AllScene.dummyDict[dummy].getSx(),AllScene.dummyDict[dummy].getSy(),AllScene.dummyDict[dummy].getSz())) + out_file.write(i2+ "self."+ dummyS + "=loader.loadModelCopy(\"misc/sphere\")\n") + #Transformation Code + out_file.write(i2+"# Transforming the Dummy\n") + out_file.write(i2+ "self."+ dummyS + ".setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"% (AllScene.dummyDict[dummy].getX(),AllScene.dummyDict[dummy].getY(),AllScene.dummyDict[dummy].getZ(),AllScene.dummyDict[dummy].getH(),AllScene.dummyDict[dummy].getP(),AllScene.dummyDict[dummy].getR(),AllScene.dummyDict[dummy].getSx(),AllScene.dummyDict[dummy].getSy(),AllScene.dummyDict[dummy].getSz())) out_file.write("\n") - out_file.write(i2+ "# Fill in the dictionaries which are used by level Ed to reload state\n") - out_file.write(i2+ "self.dummyDict[\'" + dummyS + "\']=self." + AllScene.dummyDict[dummy].getName()+"\n") + out_file.write(i2+ "# Fill in the dictionaries which are used by level Ed to reload state\n") + out_file.write(i2+ "self.dummyDict[\'" + dummyS + "\']=self." + AllScene.dummyDict[dummy].getName()+"\n") out_file.write(i2+ "self.dummyDict[\'"+ dummyS + "\'].setName(\'"+ dummyS +"\')\n") - out_file.write("\n") - out_file.write(i2+ "# Save Metadata...can be retrieved by doing theScene.dummyDict[\"Dummy_Name\"].getTag(\"Metadata\")\n") - out_file.write(i2+ "self."+ dummyS + ".setTag(\"Metadata\",\"" + AllScene.dummyDict[dummy].getTag("Metadata") + "\")\n") + out_file.write("\n") + out_file.write(i2+ "# Save Metadata...can be retrieved by doing theScene.dummyDict[\"Dummy_Name\"].getTag(\"Metadata\")\n") + out_file.write(i2+ "self."+ dummyS + ".setTag(\"Metadata\",\"" + AllScene.dummyDict[dummy].getTag("Metadata") + "\")\n") out_file.write("\n") - #################################################################################################################################################### - # Saving Actors and their animations - #################################################################################################################################################### - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Code for all the Actors and animations\n") - out_file.write(i2+"# To access the Actors\n") - out_file.write(i2+"# theScene.ActorDic[\'Actor_Name\']\n") - out_file.write(i2+"# theScene.ActorDic[\'Actor_Name\'].play(\'Animation_Name\')\n") - out_file.write(i2+"##########################################################################################################\n") - for actor in AllScene.ActorDic: - out_file.write("\n") - actorS=str(actor) + #################################################################################################################################################### + # Saving Actors and their animations + #################################################################################################################################################### + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Code for all the Actors and animations\n") + out_file.write(i2+"# To access the Actors\n") + out_file.write(i2+"# theScene.ActorDic[\'Actor_Name\']\n") + out_file.write(i2+"# theScene.ActorDic[\'Actor_Name\'].play(\'Animation_Name\')\n") + out_file.write(i2+"##########################################################################################################\n") + for actor in AllScene.ActorDic: + out_file.write("\n") + actorS=str(actor) - if(1): # This is kept for now... perhaps later some sort of check might have to be enforced based on loadMode - #out_file.write(i2+ "self."+ actorS + "=Actor.Actor(\'"+ AllScene.ActorRefDic[actor].getFullpath() + "\')\n")# The old way with absolute paths + if(1): # This is kept for now... perhaps later some sort of check might have to be enforced based on loadMode + #out_file.write(i2+ "self."+ actorS + "=Actor.Actor(\'"+ AllScene.ActorRefDic[actor].getFullpath() + "\')\n")# The old way with absolute paths - newpath = dirname + "/" + AllScene.ActorRefDic[actor].getBasename() - newpathF=Filename(newpath) - newpathSpecific=newpathF.toOsSpecific() + newpath = dirname + "/" + AllScene.ActorRefDic[actor].getBasename() + newpathF=Filename(newpath) + newpathSpecific=newpathF.toOsSpecific() - # Copy all the textures referenced by this file over to the relative directory - actorfnamelist=[] - actorData=EggData() - actorData.read(AllScene.ActorRefDic[actor]) - textures=EggTextureCollection() - textures.findUsedTextures(actorData) - for index in range(textures.getNumTextures()): - texture=textures.getTexture(index) - texfilename=texture.getFilename() - actorfnamelist.append(texfilename.getFullpath()) + # Copy all the textures referenced by this file over to the relative directory + actorfnamelist=[] + actorData=EggData() + actorData.read(AllScene.ActorRefDic[actor]) + textures=EggTextureCollection() + textures.findUsedTextures(actorData) + for index in range(textures.getNumTextures()): + texture=textures.getTexture(index) + texfilename=texture.getFilename() + actorfnamelist.append(texfilename.getFullpath()) - oldFilename=Filename(Filename(AllScene.ActorRefDic[actor].getDirname()),texfilename) - if(not oldFilename.isRegularFile()): - if(texfilename.resolveFilename(getTexturePath(),"")): - oldFilename=texfilename - oldtexpath=oldFilename.toOsSpecific(); + oldFilename=Filename(Filename(AllScene.ActorRefDic[actor].getDirname()),texfilename) + if(not oldFilename.isRegularFile()): + if(texfilename.resolveFilename(getTexturePath(),"")): + oldFilename=texfilename + oldtexpath=oldFilename.toOsSpecific(); - newtexpath=dirname + "/" + texfilename.getBasename() - newtexpathF=Filename(newtexpath) - newtexpathSpecific=newtexpathF.toOsSpecific() - print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific - if(oldtexpath != newtexpathSpecific): - shutil.copyfile(oldtexpath,newtexpathSpecific) + newtexpath=dirname + "/" + texfilename.getBasename() + newtexpathF=Filename(newtexpath) + newtexpathSpecific=newtexpathF.toOsSpecific() + print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific + if(oldtexpath != newtexpathSpecific): + shutil.copyfile(oldtexpath,newtexpathSpecific) - # Copy the file over to the relative directory - oldActorpath=AllScene.ActorRefDic[actor].toOsSpecific() - print "FILESAVER:: copying from " + AllScene.ActorRefDic[actor].toOsSpecific() + "to" + newpathSpecific - if(oldActorpath!=newpathSpecific): - shutil.copyfile(oldActorpath,newpathSpecific) - - - e=EggData() - e.read(AllScene.ActorRefDic[actor]) - etc=EggTextureCollection() - etc.extractTextures(e) - for index in range(len(actorfnamelist)): - print actorfnamelist[index] - tex=etc.findFilename(Filename(actorfnamelist[index])) - fn=Filename(tex.getFilename()) - fn.setDirname("") - tex.setFilename(fn) - e.writeEgg(Filename.fromOsSpecific(newpathSpecific)) - + # Copy the file over to the relative directory + oldActorpath=AllScene.ActorRefDic[actor].toOsSpecific() + print "FILESAVER:: copying from " + AllScene.ActorRefDic[actor].toOsSpecific() + "to" + newpathSpecific + if(oldActorpath!=newpathSpecific): + shutil.copyfile(oldActorpath,newpathSpecific) - out_file.write(i2+"if(self.loadmode==1):\n") - out_file.write(i2+i1+ "self."+ actorS + "=Actor.Actor(\'" + self.savepath + "/" + AllScene.ActorRefDic[actor].getBasename() + "')\n")#Relative Path - out_file.write(i2+"else:\n") - out_file.write(i2+i1+ "self."+ actorS + "=Actor.Actor(self.executionpath + \'/" + AllScene.ActorRefDic[actor].getBasename() + "')\n")#Relative Path with execution point specified by the invoking-level-editor + e=EggData() + e.read(AllScene.ActorRefDic[actor]) + etc=EggTextureCollection() + etc.extractTextures(e) + for index in range(len(actorfnamelist)): + print actorfnamelist[index] + tex=etc.findFilename(Filename(actorfnamelist[index])) + fn=Filename(tex.getFilename()) + fn.setDirname("") + tex.setFilename(fn) + e.writeEgg(Filename.fromOsSpecific(newpathSpecific)) - #Transformation Code - out_file.write(i2+"# Transforming the Actor\n") - out_file.write(i2+ "self."+ actorS + ".setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"% (AllScene.ActorDic[actor].getX(),AllScene.ActorDic[actor].getY(),AllScene.ActorDic[actor].getZ(),AllScene.ActorDic[actor].getH(),AllScene.ActorDic[actor].getP(),AllScene.ActorDic[actor].getR(),AllScene.ActorDic[actor].getSx(),AllScene.ActorDic[actor].getSy(),AllScene.ActorDic[actor].getSz())) - if(AllScene.ActorDic[actor].hasTransparency()): - out_file.write(i2+"# Alpha\n") - out_file.write(i2+ "self."+ actorS + ".setTransparency(1)\n") - clr=AllScene.ActorDic[actor].getColor() - out_file.write(i2+ "self."+ actorS + ".setColor(%.4f,%.4f,%.4f,%.4f)\n"%(clr.getX(),clr.getY(),clr.getZ(),clr.getW())) - out_file.write(i2+ "self."+ actorS + ".reparentTo(render)\n") + out_file.write(i2+"if(self.loadmode==1):\n") + out_file.write(i2+i1+ "self."+ actorS + "=Actor.Actor(\'" + self.savepath + "/" + AllScene.ActorRefDic[actor].getBasename() + "')\n")#Relative Path + out_file.write(i2+"else:\n") + out_file.write(i2+i1+ "self."+ actorS + "=Actor.Actor(self.executionpath + \'/" + AllScene.ActorRefDic[actor].getBasename() + "')\n")#Relative Path with execution point specified by the invoking-level-editor + + #Transformation Code + out_file.write(i2+"# Transforming the Actor\n") + out_file.write(i2+ "self."+ actorS + ".setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"% (AllScene.ActorDic[actor].getX(),AllScene.ActorDic[actor].getY(),AllScene.ActorDic[actor].getZ(),AllScene.ActorDic[actor].getH(),AllScene.ActorDic[actor].getP(),AllScene.ActorDic[actor].getR(),AllScene.ActorDic[actor].getSx(),AllScene.ActorDic[actor].getSy(),AllScene.ActorDic[actor].getSz())) + + if(AllScene.ActorDic[actor].hasTransparency()): + out_file.write(i2+"# Alpha\n") + out_file.write(i2+ "self."+ actorS + ".setTransparency(1)\n") + clr=AllScene.ActorDic[actor].getColor() + out_file.write(i2+ "self."+ actorS + ".setColor(%.4f,%.4f,%.4f,%.4f)\n"%(clr.getX(),clr.getY(),clr.getZ(),clr.getW())) + + out_file.write(i2+ "self."+ actorS + ".reparentTo(render)\n") - out_file.write("\n") - out_file.write(i2+ "# Save Metadata...can be retrieved by doing theScene.ActorDic[\"Actor_Name\"].getTag(\"Metadata\")\n") - out_file.write(i2+ "self."+ actorS + ".setTag(\"Metadata\",\"" + AllScene.ActorDic[actor].getTag("Metadata") + "\")\n") + out_file.write("\n") + out_file.write(i2+ "# Save Metadata...can be retrieved by doing theScene.ActorDic[\"Actor_Name\"].getTag(\"Metadata\")\n") + out_file.write(i2+ "self."+ actorS + ".setTag(\"Metadata\",\"" + AllScene.ActorDic[actor].getTag("Metadata") + "\")\n") - out_file.write("\n") - out_file.write(i2+ "# Fill in the dictionaries which are used by level Ed to reload state\n") - ActorAnimations=AllScene.getAnimationDictFromActor(actor) - ActorAnimationsInvoke={} + out_file.write("\n") + out_file.write(i2+ "# Fill in the dictionaries which are used by level Ed to reload state\n") + ActorAnimations=AllScene.getAnimationDictFromActor(actor) + ActorAnimationsInvoke={} - if(ActorAnimations!={}): #Check if a dictionary of animations exists for this actor - for animation in ActorAnimations: - #out_file.write(i2+ "self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Old way with absolute paths - print "ACTOR ANIMATIONS" + ActorAnimations[animation] - oldAnimPath=Filename(ActorAnimations[animation]) - oldAnim=oldAnimPath.toOsSpecific() - dirOS=Filename(dirname) - newAnim=dirOS.toOsSpecific() + "\\" + oldAnimPath.getBasename() - print "ACTOR ANIM SAVER:: Comparing" + oldAnim +"and" + newAnim - if(oldAnim!=newAnim): - shutil.copyfile(oldAnim,newAnim) - newAnimF=Filename.fromOsSpecific(newAnim) - ActorAnimationsInvoke[animation]="self.executionpath +" + "/" +newAnimF.getBasename() - ActorAnimations[animation]= self.savepath + "/" + newAnimF.getBasename() + if(ActorAnimations!={}): #Check if a dictionary of animations exists for this actor + for animation in ActorAnimations: + #out_file.write(i2+ "self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Old way with absolute paths + print "ACTOR ANIMATIONS" + ActorAnimations[animation] + oldAnimPath=Filename(ActorAnimations[animation]) + oldAnim=oldAnimPath.toOsSpecific() + dirOS=Filename(dirname) + newAnim=dirOS.toOsSpecific() + "\\" + oldAnimPath.getBasename() + print "ACTOR ANIM SAVER:: Comparing" + oldAnim +"and" + newAnim + if(oldAnim!=newAnim): + shutil.copyfile(oldAnim,newAnim) + newAnimF=Filename.fromOsSpecific(newAnim) + ActorAnimationsInvoke[animation]="self.executionpath +" + "/" +newAnimF.getBasename() + ActorAnimations[animation]= self.savepath + "/" + newAnimF.getBasename() - out_file.write(i2+"if(self.loadmode==1):\n") - out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Now with new relative paths - out_file.write(i2+"else:\n") - theloadAnimString=str(ActorAnimationsInvoke)# We hack the "self.executionpath" part into the dictionary as a variable using string replace - print "LOAD ANIM STRING BEFORE" + theloadAnimString - theloadAnimString=theloadAnimString.replace('\'self.executionpath +','self.executionpath + \'') - print "LOAD ANIM STRING AFTER" + theloadAnimString - out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + theloadAnimString +")\n") # Now with new relative paths based on editor invocation + out_file.write(i2+"if(self.loadmode==1):\n") + out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Now with new relative paths + out_file.write(i2+"else:\n") + theloadAnimString=str(ActorAnimationsInvoke)# We hack the "self.executionpath" part into the dictionary as a variable using string replace + print "LOAD ANIM STRING BEFORE" + theloadAnimString + theloadAnimString=theloadAnimString.replace('\'self.executionpath +','self.executionpath + \'') + print "LOAD ANIM STRING AFTER" + theloadAnimString + out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + theloadAnimString +")\n") # Now with new relative paths based on editor invocation out_file.write(i2+ "self.ActorDic[\'" + actorS + "\']=self." + AllScene.ActorDic[actor].getName()+"\n") - #out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=Filename(\'"+AllScene.ActorRefDic[actor].getFullpath() +"\')\n") # Old way with absolute paths - out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=\'"+ AllScene.ActorRefDic[actor].getBasename() +"\'\n")# Relative paths - out_file.write(i2+ "self.ActorDic[\'"+ actorS + "\'].setName(\'"+ actorS +"\')\n") - if(AllScene.blendAnimDict.has_key(actor)): # Check if a dictionary of blended animations exists - out_file.write(i2+ "self.blendAnimDict[\"" + actorS +"\"]=" + str(AllScene.blendAnimDict[actor]) + "\n") - - - out_file.write("\n") - - #################################################################################################################################################### - # Collsion Node Saving - #################################################################################################################################################### - - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Code for setting up Collision Nodes\n") - out_file.write(i2+"# To use collision detection:\n") - out_file.write(i2+"# You must set up your own bitmasking and event handlers, the traverser \"cTrav\" is created for you at the top\n") - out_file.write(i2+"# The collision nodes are stored in collisionDict\n") - out_file.write(i2+"##########################################################################################################\n\n") - for collnode in AllScene.collisionDict: - collnodeS=str(collnode) - solid=AllScene.collisionDict[collnode].node().getSolid(0) + #out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=Filename(\'"+AllScene.ActorRefDic[actor].getFullpath() +"\')\n") # Old way with absolute paths + out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=\'"+ AllScene.ActorRefDic[actor].getBasename() +"\'\n")# Relative paths + out_file.write(i2+ "self.ActorDic[\'"+ actorS + "\'].setName(\'"+ actorS +"\')\n") + if(AllScene.blendAnimDict.has_key(actor)): # Check if a dictionary of blended animations exists + out_file.write(i2+ "self.blendAnimDict[\"" + actorS +"\"]=" + str(AllScene.blendAnimDict[actor]) + "\n") + + + out_file.write("\n") + + #################################################################################################################################################### + # Collsion Node Saving + #################################################################################################################################################### + + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Code for setting up Collision Nodes\n") + out_file.write(i2+"# To use collision detection:\n") + out_file.write(i2+"# You must set up your own bitmasking and event handlers, the traverser \"cTrav\" is created for you at the top\n") + out_file.write(i2+"# The collision nodes are stored in collisionDict\n") + out_file.write(i2+"##########################################################################################################\n\n") + for collnode in AllScene.collisionDict: + collnodeS=str(collnode) + solid=AllScene.collisionDict[collnode].node().getSolid(0) nodetype=solid.getType().getName() - if(nodetype=="CollisionSphere"): #Save Collison Sphere - out_file.write(i2+"collSolid=CollisionSphere(%.3f,%.3f,%.3f,%.3f)\n"%(solid.getCenter().getX(),solid.getCenter().getY(),solid.getCenter().getZ(),solid.getRadius())) - pass - elif(nodetype=="CollisionPolygon"): #Save Collison Polygon + if(nodetype=="CollisionSphere"): #Save Collison Sphere + out_file.write(i2+"collSolid=CollisionSphere(%.3f,%.3f,%.3f,%.3f)\n"%(solid.getCenter().getX(),solid.getCenter().getY(),solid.getCenter().getZ(),solid.getRadius())) + pass + elif(nodetype=="CollisionPolygon"): #Save Collison Polygon - ax=AllScene.collisionDict[collnode].getTag("A_X") - ay=AllScene.collisionDict[collnode].getTag("A_Y") - az=AllScene.collisionDict[collnode].getTag("A_Z") + ax=AllScene.collisionDict[collnode].getTag("A_X") + ay=AllScene.collisionDict[collnode].getTag("A_Y") + az=AllScene.collisionDict[collnode].getTag("A_Z") - bx=AllScene.collisionDict[collnode].getTag("B_X") - by=AllScene.collisionDict[collnode].getTag("B_Y") - bz=AllScene.collisionDict[collnode].getTag("B_Z") + bx=AllScene.collisionDict[collnode].getTag("B_X") + by=AllScene.collisionDict[collnode].getTag("B_Y") + bz=AllScene.collisionDict[collnode].getTag("B_Z") - cx=AllScene.collisionDict[collnode].getTag("C_X") - cy=AllScene.collisionDict[collnode].getTag("C_Y") - cz=AllScene.collisionDict[collnode].getTag("C_Z") + cx=AllScene.collisionDict[collnode].getTag("C_X") + cy=AllScene.collisionDict[collnode].getTag("C_Y") + cz=AllScene.collisionDict[collnode].getTag("C_Z") - out_file.write(i2+"pointA = Point3(" + ax + "," + ay + "," + az + ")\n") - out_file.write(i2+"pointB = Point3(" + bx + "," + by + "," + bz + ")\n") - out_file.write(i2+"pointC = Point3(" + cx + "," + cy + "," + cz + ")\n") + out_file.write(i2+"pointA = Point3(" + ax + "," + ay + "," + az + ")\n") + out_file.write(i2+"pointB = Point3(" + bx + "," + by + "," + bz + ")\n") + out_file.write(i2+"pointC = Point3(" + cx + "," + cy + "," + cz + ")\n") out_file.write(i2+"collSolid=CollisionPolygon(pointA, pointB, pointC)\n") - - pass - elif(nodetype=="CollisionSegment"): #Save Collison Segment - A=AllScene.collisionDict[collnode].node().getSolid(0).getPointA() - B=AllScene.collisionDict[collnode].node().getSolid(0).getPointB() - - out_file.write(i2+"pointA = Point3(%.3f,%.3f,%.3f)\n"%(A.getX(),A.getY(),A.getZ())) - out_file.write(i2+"pointB = Point3(%.3f,%.3f,%.3f)\n"%(B.getX(),B.getY(),B.getZ())) - out_file.write(i2+"collSolid=CollisionSegment()\n") - out_file.write(i2+"collSolid.setPointA(pointA)\n") - out_file.write(i2+"collSolid.setFromLens(base.cam.node(),Point2(-1,1))\n") - out_file.write(i2+"collSolid.setPointB(pointB)\n") + pass - pass + elif(nodetype=="CollisionSegment"): #Save Collison Segment + A=AllScene.collisionDict[collnode].node().getSolid(0).getPointA() + B=AllScene.collisionDict[collnode].node().getSolid(0).getPointB() - elif(nodetype=="CollisionRay"): #Save Collison Ray - P = AllScene.collisionDict[collnode].node().getSolid(0).getOrigin() + out_file.write(i2+"pointA = Point3(%.3f,%.3f,%.3f)\n"%(A.getX(),A.getY(),A.getZ())) + out_file.write(i2+"pointB = Point3(%.3f,%.3f,%.3f)\n"%(B.getX(),B.getY(),B.getZ())) + out_file.write(i2+"collSolid=CollisionSegment()\n") + out_file.write(i2+"collSolid.setPointA(pointA)\n") + out_file.write(i2+"collSolid.setFromLens(base.cam.node(),Point2(-1,1))\n") + out_file.write(i2+"collSolid.setPointB(pointB)\n") + + pass + + elif(nodetype=="CollisionRay"): #Save Collison Ray + P = AllScene.collisionDict[collnode].node().getSolid(0).getOrigin() V = AllScene.collisionDict[collnode].node().getSolid(0).getDirection() - out_file.write(i2+"point=Point3(%.3f,%.3f,%.3f)\n"%(P.getX(),P.getY(),P.getZ())) - out_file.write(i2+"vector=Vec3(%.3f,%.3f,%.3f)\n"%(V.getX(),V.getY(),V.getZ())) - out_file.write(i2+"collSolid=CollisionRay()\n") - out_file.write(i2+"collSolid.setOrigin(point)\n") - out_file.write(i2+"collSolid.setDirection(vector)\n") + out_file.write(i2+"point=Point3(%.3f,%.3f,%.3f)\n"%(P.getX(),P.getY(),P.getZ())) + out_file.write(i2+"vector=Vec3(%.3f,%.3f,%.3f)\n"%(V.getX(),V.getY(),V.getZ())) + out_file.write(i2+"collSolid=CollisionRay()\n") + out_file.write(i2+"collSolid.setOrigin(point)\n") + out_file.write(i2+"collSolid.setDirection(vector)\n") - pass - else: - print "Invalid Collision Node: " + nodetype - out_file.write("\n") + pass + else: + print "Invalid Collision Node: " + nodetype + out_file.write("\n") - out_file.write(i2+"self." + collnodeS + "_Node" + "=CollisionNode(\""+collnodeS+"\")\n") - out_file.write(i2+"self." + collnodeS + "_Node" + ".addSolid(collSolid)\n") - out_file.write(i2+"base.cTrav.addCollider(self." + collnodeS + "_Node,self.CollisionHandler)\n") - out_file.write("\n") - + out_file.write(i2+"self." + collnodeS + "_Node" + "=CollisionNode(\""+collnodeS+"\")\n") + out_file.write(i2+"self." + collnodeS + "_Node" + ".addSolid(collSolid)\n") + out_file.write(i2+"base.cTrav.addCollider(self." + collnodeS + "_Node,self.CollisionHandler)\n") + out_file.write("\n") - #################################################################################################################################################### - # Light Saving - #################################################################################################################################################### - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Code for Lighting\n") - out_file.write(i2+"# To manipulated lights:\n") - out_file.write(i2+"# Manipulate the light node in theScene.LightNodes[\'Light_Name\']\n") - out_file.write(i2+"##########################################################################################################\n\n") - LightList=AllScene.lightManager.getLightNodeList() - for light in LightList: + #################################################################################################################################################### + # Light Saving + #################################################################################################################################################### + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Code for Lighting\n") + out_file.write(i2+"# To manipulated lights:\n") + out_file.write(i2+"# Manipulate the light node in theScene.LightNodes[\'Light_Name\']\n") + out_file.write(i2+"##########################################################################################################\n\n") + + LightList=AllScene.lightManager.getLightNodeList() + for light in LightList: type = light.getType() - if type == 'ambient': - out_file.write(i2+"# Ambient Light\n") - out_file.write (i2+ "self.ambientCount += 1\n") - out_file.write (i2+ "alight = AmbientLight(\'"+ light.getName() +"\')\n") - out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") - out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+"= render.attachNewNode(alight.upcastToPandaNode())\n") - out_file.write (i2+ "self."+light.getName()+".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") - out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") - out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") - out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") - out_file.write ("\n") - elif type == 'directional': - out_file.write(i2+"# Directional Light\n") - out_file.write (i2+ "self.directionalCount += 1\n") - out_file.write (i2+ "alight = DirectionalLight(\'"+ light.getName() + "\')\n") - out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") - #out_file.write (i2+ "alight.setDirection(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") - #out_file.write (i2+ "alight.setPoint(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") - out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") - out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n") - out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") - out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") - out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") - #out_file.write (i2+ "alight.setPos - out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") - out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") - out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") - out_file.write ("\n") - elif type == 'point': - out_file.write(i2+"# Point Light\n") - out_file.write (i2+ "self.pointCount += 1\n") - out_file.write (i2+ "alight = PointLight(\'"+ light.getName() +"\')\n") - out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") - #out_file.write (i2+ "alight.setPoint(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") - out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") - out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n") - out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n") - out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") - out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") - out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") - out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") - out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") - out_file.write ("\n") - elif type == 'spot': - out_file.write(i2+"# Spot Light\n") - out_file.write (i2+ "self.spotCount += 1\n") - out_file.write (i2+ "alight = Spotlight(\'"+ light.getName() + "\')\n") - out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") - out_file.write (i2+ "alens = PerspectiveLens()\n") - out_file.write (i2+ "alight.setLens(alens)\n") - out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") - out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n") - out_file.write (i2+ "alight.setExponent(" +str(light.getExponent()) +")\n") - out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToLensNode())\n") - out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") - out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") - out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") - out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") - out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") - out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") - out_file.write ("\n") - else: - out_file.write (i2+ "print \'Invalid light type\'") - out_file.write (i2+ "return None") - out_file.write("\n") - - - - #################################################################################################################################################### - # Enable Lighting - #################################################################################################################################################### - - out_file.write(i2+ "# Enable Ligthing\n") - out_file.write(i2+ "render.node().setAttrib(self.lightAttrib)\n") - out_file.write("\n") + if type == 'ambient': + out_file.write(i2+"# Ambient Light\n") + out_file.write (i2+ "self.ambientCount += 1\n") + out_file.write (i2+ "alight = AmbientLight(\'"+ light.getName() +"\')\n") + out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") + out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") + out_file.write (i2+ "self."+light.getName()+"= render.attachNewNode(alight.upcastToPandaNode())\n") + out_file.write (i2+ "self."+light.getName()+".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") + out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") + out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") + out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") + out_file.write ("\n") + elif type == 'directional': + out_file.write(i2+"# Directional Light\n") + out_file.write (i2+ "self.directionalCount += 1\n") + out_file.write (i2+ "alight = DirectionalLight(\'"+ light.getName() + "\')\n") + out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") + #out_file.write (i2+ "alight.setDirection(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") + #out_file.write (i2+ "alight.setPoint(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") + out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") + out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") + out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n") + out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") + out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") + out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") + #out_file.write (i2+ "alight.setPos + out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") + out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") + out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") + out_file.write ("\n") + elif type == 'point': + out_file.write(i2+"# Point Light\n") + out_file.write (i2+ "self.pointCount += 1\n") + out_file.write (i2+ "alight = PointLight(\'"+ light.getName() +"\')\n") + out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") + #out_file.write (i2+ "alight.setPoint(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") + out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") + out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n") + out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") + out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n") + out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") + out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") + out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") + out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") + out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") + out_file.write ("\n") + elif type == 'spot': + out_file.write(i2+"# Spot Light\n") + out_file.write (i2+ "self.spotCount += 1\n") + out_file.write (i2+ "alight = Spotlight(\'"+ light.getName() + "\')\n") + out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") + out_file.write (i2+ "alens = PerspectiveLens()\n") + out_file.write (i2+ "alight.setLens(alens)\n") + out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") + out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n") + out_file.write (i2+ "alight.setExponent(" +str(light.getExponent()) +")\n") + out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") + out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToLensNode())\n") + out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") + out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") + out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") + out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") + out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") + out_file.write (i2+ "self.LightNodes[\'" + light.getName() + "\']=self." + light.getName() + "\n") + out_file.write ("\n") + else: + out_file.write (i2+ "print \'Invalid light type\'") + out_file.write (i2+ "return None") + out_file.write("\n") - #################################################################################################################################################### - # Initialize Particles for non scene editor mode - #################################################################################################################################################### + #################################################################################################################################################### + # Enable Lighting + #################################################################################################################################################### + + out_file.write(i2+ "# Enable Ligthing\n") + out_file.write(i2+ "render.node().setAttrib(self.lightAttrib)\n") + out_file.write("\n") + + + + #################################################################################################################################################### + # Initialize Particles for non scene editor mode + #################################################################################################################################################### out_file.write(i2+"# Load Particle Effects. The parameters to this function are to allow us to use our modified versions of the Particle Effects modules when loading this file with the level editor\n") - out_file.write(i2+"self.starteffects(self.loadmode,self.seParticleEffect,self.seParticles)\n") - out_file.write("\n") - - #################################################################################################################################################### - # Save Camera Settings - #################################################################################################################################################### + out_file.write(i2+"self.starteffects(self.loadmode,self.seParticleEffect,self.seParticles)\n") + out_file.write("\n") - out_file.write("\n") - out_file.write(i2+ "# Save Camera Settings\n") - out_file.write(i2+ "camera.setX(" + str(camera.getX()) + ")\n") - out_file.write(i2+ "camera.setY(" + str(camera.getY()) + ")\n") - out_file.write(i2+ "camera.setZ(" + str(camera.getZ()) + ")\n") - out_file.write(i2+ "camera.setH(" + str(camera.getH()) + ")\n") - out_file.write(i2+ "camera.setP(" + str(camera.getP()) + ")\n") - out_file.write(i2+ "camera.setR(" + str(camera.getR()) + ")\n") - out_file.write(i2+ "camera.getChild(0).node().getLens().setNear(" + str(camera.getChild(0).node().getLens().getNear()) + ")\n") - out_file.write(i2+ "camera.getChild(0).node().getLens().setFar(" + str(camera.getChild(0).node().getLens().getFar()) + ")\n") - out_file.write(i2+ "camera.getChild(0).node().getLens().setFov(VBase2(%.5f,%.5f))\n"% (camera.getChild(0).node().getLens().getHfov(),camera.getChild(0).node().getLens().getVfov())) - FilmSize=camera.getChild(0).node().getLens().getFilmSize() - out_file.write(i2+ "camera.getChild(0).node().getLens().setFilmSize(%.3f,%.3f)\n"%(FilmSize.getX(),FilmSize.getY())) - out_file.write(i2+ "camera.getChild(0).node().getLens().setFocalLength(" + str(camera.getChild(0).node().getLens().getFocalLength()) + ")\n") - out_file.write(i2+ "camera.setTag(\"Metadata\",\"" + camera.getTag("Metadata") + "\")\n") - out_file.write(i2+ "camera.reparentTo(render)\n") - out_file.write(i2+ "base.disableMouse()\n") - self.bgColor=base.getBackgroundColor() - out_file.write(i2+ "base.setBackgroundColor(%.3f,%.3f,%.3f)\n"%(self.bgColor.getX(),self.bgColor.getY(),self.bgColor.getZ())) - out_file.write("\n") - + #################################################################################################################################################### + # Save Camera Settings + #################################################################################################################################################### - #################################################################################################################################################### - # Mopath Saving - #################################################################################################################################################### + out_file.write("\n") + out_file.write(i2+ "# Save Camera Settings\n") + out_file.write(i2+ "camera.setX(" + str(camera.getX()) + ")\n") + out_file.write(i2+ "camera.setY(" + str(camera.getY()) + ")\n") + out_file.write(i2+ "camera.setZ(" + str(camera.getZ()) + ")\n") + out_file.write(i2+ "camera.setH(" + str(camera.getH()) + ")\n") + out_file.write(i2+ "camera.setP(" + str(camera.getP()) + ")\n") + out_file.write(i2+ "camera.setR(" + str(camera.getR()) + ")\n") + out_file.write(i2+ "camera.getChild(0).node().getLens().setNear(" + str(camera.getChild(0).node().getLens().getNear()) + ")\n") + out_file.write(i2+ "camera.getChild(0).node().getLens().setFar(" + str(camera.getChild(0).node().getLens().getFar()) + ")\n") + out_file.write(i2+ "camera.getChild(0).node().getLens().setFov(VBase2(%.5f,%.5f))\n"% (camera.getChild(0).node().getLens().getHfov(),camera.getChild(0).node().getLens().getVfov())) + FilmSize=camera.getChild(0).node().getLens().getFilmSize() + out_file.write(i2+ "camera.getChild(0).node().getLens().setFilmSize(%.3f,%.3f)\n"%(FilmSize.getX(),FilmSize.getY())) + out_file.write(i2+ "camera.getChild(0).node().getLens().setFocalLength(" + str(camera.getChild(0).node().getLens().getFocalLength()) + ")\n") + out_file.write(i2+ "camera.setTag(\"Metadata\",\"" + camera.getTag("Metadata") + "\")\n") + out_file.write(i2+ "camera.reparentTo(render)\n") + out_file.write(i2+ "base.disableMouse()\n") + self.bgColor=base.getBackgroundColor() + out_file.write(i2+ "base.setBackgroundColor(%.3f,%.3f,%.3f)\n"%(self.bgColor.getX(),self.bgColor.getY(),self.bgColor.getZ())) + out_file.write("\n") - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Motion Paths\n") - out_file.write(i2+"# Using Mopaths:\n") - out_file.write(i2+"# theScene.curveIntervals[0].start() or .loop() will play curve with index 0\n") - out_file.write(i2+"##########################################################################################################\n\n") - for node in AllScene.curveDict: - curveCollection=AllScene.curveDict[node] - curvenumber=0 - for curve in curveCollection: - filestring=dirname+ "\\" + str(node)+"_curve_"+str(curvenumber)+".egg" - f=Filename.fromOsSpecific(filestring) - #filestring=f.getFullpath()# The old absolute path way - filestring=f.getBasename() # The new relative path way - curve.writeEgg(f) - out_file.write(i2+"m=Mopath.Mopath()\n") + #################################################################################################################################################### + # Mopath Saving + #################################################################################################################################################### - out_file.write(i2+"if(self.loadmode==1):\n") - out_file.write(i2+i1+"m.loadFile(\"" + self.savepath +"/"+ filestring + "\")\n") # If just normally executed - out_file.write(i2+"else:\n") - out_file.write(i2+i1+"m.loadFile(self.executionpath + \"/"+ filestring + "\")\n") # If being invoked by level Ed + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Motion Paths\n") + out_file.write(i2+"# Using Mopaths:\n") + out_file.write(i2+"# theScene.curveIntervals[0].start() or .loop() will play curve with index 0\n") + out_file.write(i2+"##########################################################################################################\n\n") - out_file.write(i2+"mp=MopathInterval(m,self." + str(node) + ")\n") - out_file.write(i2+"self.curveIntervals.append(mp)\n") - - out_file.write(i2+"if(self.loadmode==1):\n") - out_file.write(i2+i1+"self.curveRefColl.append(\"" + self.savepath +"/"+ filestring +"\")\n") - out_file.write(i2+"else:\n") - out_file.write(i2+i1+"self.curveRefColl.append(self.executionpath + \"/"+ filestring +"\")\n") + for node in AllScene.curveDict: + curveCollection=AllScene.curveDict[node] + curvenumber=0 + for curve in curveCollection: + filestring=dirname+ "\\" + str(node)+"_curve_"+str(curvenumber)+".egg" + f=Filename.fromOsSpecific(filestring) + #filestring=f.getFullpath()# The old absolute path way + filestring=f.getBasename() # The new relative path way + curve.writeEgg(f) + out_file.write(i2+"m=Mopath.Mopath()\n") - curvenumber=curvenumber+1 - out_file.write(i2+"self.curveIntervalsDict[\"" + str(node) + "\"]=self.curveIntervals\n") - out_file.write(i2+"self.curveDict[\"" + str(node) + "\"]=self.curveRefColl\n") + out_file.write(i2+"if(self.loadmode==1):\n") + out_file.write(i2+i1+"m.loadFile(\"" + self.savepath +"/"+ filestring + "\")\n") # If just normally executed + out_file.write(i2+"else:\n") + out_file.write(i2+i1+"m.loadFile(self.executionpath + \"/"+ filestring + "\")\n") # If being invoked by level Ed + + out_file.write(i2+"mp=MopathInterval(m,self." + str(node) + ")\n") + out_file.write(i2+"self.curveIntervals.append(mp)\n") + + out_file.write(i2+"if(self.loadmode==1):\n") + out_file.write(i2+i1+"self.curveRefColl.append(\"" + self.savepath +"/"+ filestring +"\")\n") + out_file.write(i2+"else:\n") + out_file.write(i2+i1+"self.curveRefColl.append(self.executionpath + \"/"+ filestring +"\")\n") + + curvenumber=curvenumber+1 + out_file.write(i2+"self.curveIntervalsDict[\"" + str(node) + "\"]=self.curveIntervals\n") + out_file.write(i2+"self.curveDict[\"" + str(node) + "\"]=self.curveRefColl\n") - #################################################################################################################################################### - # Lets do all the reparenting here so as to make sure everything that needed to load was loaded - #################################################################################################################################################### + #################################################################################################################################################### + # Lets do all the reparenting here so as to make sure everything that needed to load was loaded + #################################################################################################################################################### - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Reparenting\n") - out_file.write(i2+"# A final pass is done on setting all the scenegraph hierarchy after all objects are laoded\n") - out_file.write(i2+"##########################################################################################################\n\n") + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Reparenting\n") + out_file.write(i2+"# A final pass is done on setting all the scenegraph hierarchy after all objects are laoded\n") + out_file.write(i2+"##########################################################################################################\n\n") - for model in AllScene.ModelDic: - modelS=str(model) - parent=AllScene.ModelDic[model].getParent().getName() - if(parent=="render" or parent=="camera"): - out_file.write(i2+ "self."+ modelS + ".reparentTo(" + parent + ")\n") - else: - if(AllScene.particleDict.has_key(parent)): - out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ".getEffect())\n") - else: - out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ")\n") - out_file.write(i2+ "self.ModelDic[\'" + modelS + "\']=self." + AllScene.ModelDic[model].getName()+"\n") - out_file.write(i2+"\n") + for model in AllScene.ModelDic: + modelS=str(model) + parent=AllScene.ModelDic[model].getParent().getName() + if(parent=="render" or parent=="camera"): + out_file.write(i2+ "self."+ modelS + ".reparentTo(" + parent + ")\n") + else: + if(AllScene.particleDict.has_key(parent)): + out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ".getEffect())\n") + else: + out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ")\n") + out_file.write(i2+ "self.ModelDic[\'" + modelS + "\']=self." + AllScene.ModelDic[model].getName()+"\n") + out_file.write(i2+"\n") - for dummy in AllScene.dummyDict: - dummyS=str(dummy) - parent=AllScene.dummyDict[dummy].getParent().getName() - if(parent=="render" or parent=="camera"): - out_file.write(i2+ "self."+ dummyS + ".reparentTo(" + parent + ")\n") - else: - if(AllScene.particleDict.has_key(parent)): - out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ".getEffect())\n") - else: - out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ")\n") + for dummy in AllScene.dummyDict: + dummyS=str(dummy) + parent=AllScene.dummyDict[dummy].getParent().getName() + if(parent=="render" or parent=="camera"): + out_file.write(i2+ "self."+ dummyS + ".reparentTo(" + parent + ")\n") + else: + if(AllScene.particleDict.has_key(parent)): + out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ".getEffect())\n") + else: + out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ")\n") - out_file.write(i2+ "self.dummyDict[\'" + dummyS + "\']=self." + AllScene.dummyDict[dummy].getName()+"\n") - out_file.write(i2+"\n") + out_file.write(i2+ "self.dummyDict[\'" + dummyS + "\']=self." + AllScene.dummyDict[dummy].getName()+"\n") + out_file.write(i2+"\n") - for actor in AllScene.ActorDic: - actorS=str(actor) - parent=AllScene.ActorDic[actor].getParent().getName() - if(parent=="render" or parent=="camera"): - out_file.write(i2+ "self."+ actorS + ".reparentTo(" + parent + ")\n") - else: - if(AllScene.particleDict.has_key(parent)): - out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ".getEffect())\n") - else: - out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ")\n") + for actor in AllScene.ActorDic: + actorS=str(actor) + parent=AllScene.ActorDic[actor].getParent().getName() + if(parent=="render" or parent=="camera"): + out_file.write(i2+ "self."+ actorS + ".reparentTo(" + parent + ")\n") + else: + if(AllScene.particleDict.has_key(parent)): + out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ".getEffect())\n") + else: + out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ")\n") out_file.write(i2+ "self.ActorDic[\'" + actorS + "\']=self." + AllScene.ActorDic[actor].getName()+"\n") - out_file.write(i2+"\n") - + out_file.write(i2+"\n") - for collnode in AllScene.collisionDict: - collnodeS=str(collnode) - solid=AllScene.collisionDict[collnode].node().getSolid(0) - nodetype=solid.getType().getName() - parentname=AllScene.collisionDict[collnode].getParent().getName() - if(parentname=="render" or parentname =="camera"): - out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]="+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") - else: - if(AllScene.particleDict.has_key(parent)): - out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + "getEffect().attachNewNode(self." + collnodeS + "_Node)\n") - else: - out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") - dictelem=AllScene.collisionDict[collnode] - out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"%(dictelem.getX(),dictelem.getY(),dictelem.getZ(),dictelem.getH(),dictelem.getP(),dictelem.getR(),dictelem.getSx(),dictelem.getSy(),dictelem.getSz())) - out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag(\"Metadata\",\"" + AllScene.collisionDict[collnode].getTag("Metadata") + "\")\n") - out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].show()\n") - if(nodetype=="CollisionPolygon"): #Save Collison Polygon... the reason we need to use setTag here is because there is no inbuilt way of saving transforms for collision polys - ax=float(AllScene.collisionDict[collnode].getTag("A_X")) - ay=float(AllScene.collisionDict[collnode].getTag("A_Y")) - az=float(AllScene.collisionDict[collnode].getTag("A_Z")) + for collnode in AllScene.collisionDict: + collnodeS=str(collnode) + solid=AllScene.collisionDict[collnode].node().getSolid(0) + nodetype=solid.getType().getName() + parentname=AllScene.collisionDict[collnode].getParent().getName() + if(parentname=="render" or parentname =="camera"): + out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]="+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") + else: + if(AllScene.particleDict.has_key(parent)): + out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + "getEffect().attachNewNode(self." + collnodeS + "_Node)\n") + else: + out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") + dictelem=AllScene.collisionDict[collnode] + out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setPosHprScale(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\n"%(dictelem.getX(),dictelem.getY(),dictelem.getZ(),dictelem.getH(),dictelem.getP(),dictelem.getR(),dictelem.getSx(),dictelem.getSy(),dictelem.getSz())) + out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag(\"Metadata\",\"" + AllScene.collisionDict[collnode].getTag("Metadata") + "\")\n") + out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].show()\n") + if(nodetype=="CollisionPolygon"): #Save Collison Polygon... the reason we need to use setTag here is because there is no inbuilt way of saving transforms for collision polys - bx=float(AllScene.collisionDict[collnode].getTag("B_X")) - by=float(AllScene.collisionDict[collnode].getTag("B_Y")) - bz=float(AllScene.collisionDict[collnode].getTag("B_Z")) + ax=float(AllScene.collisionDict[collnode].getTag("A_X")) + ay=float(AllScene.collisionDict[collnode].getTag("A_Y")) + az=float(AllScene.collisionDict[collnode].getTag("A_Z")) - cx=float(AllScene.collisionDict[collnode].getTag("C_X")) - cy=float(AllScene.collisionDict[collnode].getTag("C_Y")) - cz=float(AllScene.collisionDict[collnode].getTag("C_Z")) + bx=float(AllScene.collisionDict[collnode].getTag("B_X")) + by=float(AllScene.collisionDict[collnode].getTag("B_Y")) + bz=float(AllScene.collisionDict[collnode].getTag("B_Z")) - out_file.write(i2+"pointA=Point3(%.3f,%.3f,%.3f)\n"%(ax,ay,az)) - out_file.write(i2+"pointB=Point3(%.3f,%.3f,%.3f)\n"%(bx,by,bz)) - out_file.write(i2+"pointC=Point3(%.3f,%.3f,%.3f)\n"%(cx,cy,cz)) + cx=float(AllScene.collisionDict[collnode].getTag("C_X")) + cy=float(AllScene.collisionDict[collnode].getTag("C_Y")) + cz=float(AllScene.collisionDict[collnode].getTag("C_Z")) + + out_file.write(i2+"pointA=Point3(%.3f,%.3f,%.3f)\n"%(ax,ay,az)) + out_file.write(i2+"pointB=Point3(%.3f,%.3f,%.3f)\n"%(bx,by,bz)) + out_file.write(i2+"pointC=Point3(%.3f,%.3f,%.3f)\n"%(cx,cy,cz)) out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag('A_X','%f'%pointA.getX())\n") out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag('A_Y','%f'%pointA.getY())\n") @@ -733,181 +733,181 @@ class FileSaver: out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag('C_X','%f'%pointC.getX())\n") out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag('C_Y','%f'%pointC.getY())\n") out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"].setTag('C_Z','%f'%pointC.getZ())\n") - out_file.write(i2+"\n") + out_file.write(i2+"\n") - for effect in AllScene.particleDict: - parent=AllScene.particleNodes[effect].getParent().getName() - if(parent=="render" or parent=="camera"): - out_file.write(i2+"self.particleDict[\""+ str(effect) +"\"].reparentTo(" + parent + ")\n") - else: - out_file.write(i2+"self.particleDict[\""+ str(effect) +"\"].reparentTo(self." + parent + ")\n") - out_file.write(i2+"\n") + for effect in AllScene.particleDict: + parent=AllScene.particleNodes[effect].getParent().getName() + if(parent=="render" or parent=="camera"): + out_file.write(i2+"self.particleDict[\""+ str(effect) +"\"].reparentTo(" + parent + ")\n") + else: + out_file.write(i2+"self.particleDict[\""+ str(effect) +"\"].reparentTo(self." + parent + ")\n") + out_file.write(i2+"\n") - #################################################################################################################################################### - # Particle Saving - #################################################################################################################################################### + #################################################################################################################################################### + # Particle Saving + #################################################################################################################################################### out_file.write("\n") - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Particle Effects\n") - out_file.write(i2+"# Using Particles:\n") - out_file.write(i2+"# theScene.enableeffect(\"Effect_Name\")\n") - out_file.write(i2+"##########################################################################################################\n\n") - out_file.write(i1+"def starteffects(self,mode,seParticleEffect=None,seParticles=None):\n") - for effect in AllScene.particleDict: - effectS=str(effect) - out_file.write(i2+ "self." + effectS + "=" + effectS + "(mode,seParticleEffect,seParticles)\n") - out_file.write(i2+ "effect=self."+ effectS + ".getEffect()\n") - out_file.write(i2+ "self.particleDict[\"" + effectS + "\"]=effect\n") - out_file.write(i2+ "effect.reparentTo(render)\n") - thenode=AllScene.particleNodes[effect] - out_file.write(i2+ "self.particleDict[\"" + effectS + "\"].setPosHprScale(%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f)\n"%(thenode.getX(),thenode.getY(),thenode.getZ(),thenode.getH(),thenode.getP(),thenode.getR(),thenode.getSx(),thenode.getSy(),thenode.getSz())) - out_file.write("\n") - out_file.write(i2+"return\n") + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Particle Effects\n") + out_file.write(i2+"# Using Particles:\n") + out_file.write(i2+"# theScene.enableeffect(\"Effect_Name\")\n") + out_file.write(i2+"##########################################################################################################\n\n") + out_file.write(i1+"def starteffects(self,mode,seParticleEffect=None,seParticles=None):\n") + for effect in AllScene.particleDict: + effectS=str(effect) + out_file.write(i2+ "self." + effectS + "=" + effectS + "(mode,seParticleEffect,seParticles)\n") + out_file.write(i2+ "effect=self."+ effectS + ".getEffect()\n") + out_file.write(i2+ "self.particleDict[\"" + effectS + "\"]=effect\n") + out_file.write(i2+ "effect.reparentTo(render)\n") + thenode=AllScene.particleNodes[effect] + out_file.write(i2+ "self.particleDict[\"" + effectS + "\"].setPosHprScale(%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f)\n"%(thenode.getX(),thenode.getY(),thenode.getZ(),thenode.getH(),thenode.getP(),thenode.getR(),thenode.getSx(),thenode.getSy(),thenode.getSz())) + out_file.write("\n") + out_file.write(i2+"return\n") out_file.write("\n") - out_file.write(i1+"def enableeffect(self,effect_name):\n") + out_file.write(i1+"def enableeffect(self,effect_name):\n") out_file.write(i2+"self.particleDict[effect_name].enable()\n") out_file.write(i2+"return\n") out_file.write("\n") - out_file.write(i1+"def disableeffect(self,effect_name):\n") + out_file.write(i1+"def disableeffect(self,effect_name):\n") out_file.write(i2+"self.particleDict[effect_name].disable()\n") out_file.write(i2+"return\n") out_file.write("\n") - #################################################################################################################################################### - # Animation Blending Methods - #################################################################################################################################################### + #################################################################################################################################################### + # Animation Blending Methods + #################################################################################################################################################### + out_file.write("\n") + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Animation Blending\n") + out_file.write(i2+"# Using blending:\n") + out_file.write(i2+"# theScene.playBlendAnim(actor,blendname)\n") + out_file.write(i2+"# theScene.stopBlendAnim(actor,blendname)\n") + out_file.write(i2+"# theScene.changeBlendAnim(actor,blendname,blend_amount)\n") + out_file.write(i2+"##########################################################################################################\n\n") + out_file.write(i1+"def playBlendAnim(self,actor,blendName,loop=0):\n") + out_file.write(i2+"actor.enableBlend()\n") + out_file.write(i2+"blendDicts=self.blendAnimDict[actor.getName()]\n") + out_file.write(i2+"blendList=blendDicts[blendName]\n") + out_file.write(i2+"actor.setControlEffect(blendList[0],blendList[2])\n") + out_file.write(i2+"actor.setControlEffect(blendList[1],1.0-blendList[2])\n") + out_file.write(i2+"if(loop):\n") + out_file.write(i2+i1+"actor.loop(blendList[0])\n") + out_file.write(i2+i1+"actor.loop(blendList[1])\n") + out_file.write(i2+"else:\n") + out_file.write(i2+i1+"actor.start(blendList[0])\n") + out_file.write(i2+i1+"actor.start(blendList[1])\n") out_file.write("\n") - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Animation Blending\n") - out_file.write(i2+"# Using blending:\n") - out_file.write(i2+"# theScene.playBlendAnim(actor,blendname)\n") - out_file.write(i2+"# theScene.stopBlendAnim(actor,blendname)\n") - out_file.write(i2+"# theScene.changeBlendAnim(actor,blendname,blend_amount)\n") - out_file.write(i2+"##########################################################################################################\n\n") - out_file.write(i1+"def playBlendAnim(self,actor,blendName,loop=0):\n") - out_file.write(i2+"actor.enableBlend()\n") - out_file.write(i2+"blendDicts=self.blendAnimDict[actor.getName()]\n") - out_file.write(i2+"blendList=blendDicts[blendName]\n") - out_file.write(i2+"actor.setControlEffect(blendList[0],blendList[2])\n") - out_file.write(i2+"actor.setControlEffect(blendList[1],1.0-blendList[2])\n") - out_file.write(i2+"if(loop):\n") - out_file.write(i2+i1+"actor.loop(blendList[0])\n") - out_file.write(i2+i1+"actor.loop(blendList[1])\n") - out_file.write(i2+"else:\n") - out_file.write(i2+i1+"actor.start(blendList[0])\n") - out_file.write(i2+i1+"actor.start(blendList[1])\n") - out_file.write("\n") - out_file.write(i1+"def stopBlendAnim(self,actor,blendName):\n") - out_file.write(i2+"blendDicts=self.blendAnimDict[actor.getName()]\n") - out_file.write(i2+"blendList=blendDicts[blendName]\n") - out_file.write(i2+"actor.stop(blendList[0])\n") - out_file.write(i2+"actor.stop(blendList[1])\n") - out_file.write("\n") + out_file.write(i1+"def stopBlendAnim(self,actor,blendName):\n") + out_file.write(i2+"blendDicts=self.blendAnimDict[actor.getName()]\n") + out_file.write(i2+"blendList=blendDicts[blendName]\n") + out_file.write(i2+"actor.stop(blendList[0])\n") + out_file.write(i2+"actor.stop(blendList[1])\n") + out_file.write("\n") - out_file.write(i1+"def changeBlending(self,actor,blendName,blending):\n") - out_file.write(i2+"blendDicts=self.blendAnimDict[actor.getName()]\n") - out_file.write(i2+"blendList=blendDicts[blendName]\n") - out_file.write(i2+"blendList[2]=blending\n") - out_file.write(i2+"self.blendAnimDict[actor.getName()]={blendName:[blendList[0],blendList[1],blending]}\n") - out_file.write("\n") + out_file.write(i1+"def changeBlending(self,actor,blendName,blending):\n") + out_file.write(i2+"blendDicts=self.blendAnimDict[actor.getName()]\n") + out_file.write(i2+"blendList=blendDicts[blendName]\n") + out_file.write(i2+"blendList[2]=blending\n") + out_file.write(i2+"self.blendAnimDict[actor.getName()]={blendName:[blendList[0],blendList[1],blending]}\n") + out_file.write("\n") - #################################################################################################################################################### - # Hide and Show Methods - #################################################################################################################################################### + #################################################################################################################################################### + # Hide and Show Methods + #################################################################################################################################################### - out_file.write("\n") - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Hide and Show Methods\n") - out_file.write(i2+"# These will help you hide/show dummies, collision solids, effect nodes etc.\n") - out_file.write(i2+"##########################################################################################################\n\n") + out_file.write("\n") + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Hide and Show Methods\n") + out_file.write(i2+"# These will help you hide/show dummies, collision solids, effect nodes etc.\n") + out_file.write(i2+"##########################################################################################################\n\n") - out_file.write("\n") - out_file.write(i1+"def hideDummies(self):\n") - out_file.write("\n") - out_file.write(i2+"for dummy in self.dummyDict:\n") - out_file.write(i2+i1+"self.dummyDict[dummy].reparentTo(hidden)\n") - + out_file.write("\n") + out_file.write(i1+"def hideDummies(self):\n") + out_file.write("\n") + out_file.write(i2+"for dummy in self.dummyDict:\n") + out_file.write(i2+i1+"self.dummyDict[dummy].reparentTo(hidden)\n") + - out_file.write("\n") - out_file.write(i1+"def hideCollSolids(self):\n") - out_file.write("\n") - out_file.write(i2+"for collSolid in self.collisionDict:\n") - out_file.write(i2+i1+"self.collisionDict[collSolid].hide()\n") + out_file.write("\n") + out_file.write(i1+"def hideCollSolids(self):\n") + out_file.write("\n") + out_file.write(i2+"for collSolid in self.collisionDict:\n") + out_file.write(i2+i1+"self.collisionDict[collSolid].hide()\n") - out_file.write("\n") - out_file.write(i1+"def hideEffectNodes(self):\n") - out_file.write("\n") - out_file.write(i2+"for effectnode in self.particleNodes:\n") - out_file.write(i2+i1+"self.particleNodes[effectnode].hide()\n") + out_file.write("\n") + out_file.write(i1+"def hideEffectNodes(self):\n") + out_file.write("\n") + out_file.write(i2+"for effectnode in self.particleNodes:\n") + out_file.write(i2+i1+"self.particleNodes[effectnode].hide()\n") - out_file.write("\n") - out_file.write(i1+"def showDummies(self):\n") - out_file.write("\n") - out_file.write(i2+"for dummy in self.dummyDict:\n") - out_file.write(i2+i1+"self.dummyDict[dummy].reparentTo(hidden)\n") - + out_file.write("\n") + out_file.write(i1+"def showDummies(self):\n") + out_file.write("\n") + out_file.write(i2+"for dummy in self.dummyDict:\n") + out_file.write(i2+i1+"self.dummyDict[dummy].reparentTo(hidden)\n") + - out_file.write("\n") - out_file.write(i1+"def showCollSolids(self):\n") - out_file.write("\n") - out_file.write(i2+"for collSolid in self.collisionDict:\n") - out_file.write(i2+i1+"self.collisionDict[collSolid].show()\n") + out_file.write("\n") + out_file.write(i1+"def showCollSolids(self):\n") + out_file.write("\n") + out_file.write(i2+"for collSolid in self.collisionDict:\n") + out_file.write(i2+i1+"self.collisionDict[collSolid].show()\n") - out_file.write("\n") - out_file.write(i1+"def showEffectNodes(self):\n") - out_file.write("\n") - out_file.write(i2+"for effectnode in self.particleNodes:\n") - out_file.write(i2+i1+"self.particleNodes[effectnode].show()\n\n") + out_file.write("\n") + out_file.write(i1+"def showEffectNodes(self):\n") + out_file.write("\n") + out_file.write(i2+"for effectnode in self.particleNodes:\n") + out_file.write(i2+i1+"self.particleNodes[effectnode].show()\n\n") - ########################################################################################################## - # Saving Particle Parameters as a Class - ########################################################################################################## + ########################################################################################################## + # Saving Particle Parameters as a Class + ########################################################################################################## - out_file.write("\n") - out_file.write(i2+"##########################################################################################################\n") - out_file.write(i2+"# Particle Effects\n") - out_file.write(i2+"# This is where effect parameters are saved in a class\n") - out_file.write(i2+"# The class is then instantiated in the starteffects method and appended to the dictionaries\n") - out_file.write(i2+"##########################################################################################################\n\n") + out_file.write("\n") + out_file.write(i2+"##########################################################################################################\n") + out_file.write(i2+"# Particle Effects\n") + out_file.write(i2+"# This is where effect parameters are saved in a class\n") + out_file.write(i2+"# The class is then instantiated in the starteffects method and appended to the dictionaries\n") + out_file.write(i2+"##########################################################################################################\n\n") - for effect in AllScene.particleDict: + for effect in AllScene.particleDict: - out_file.write("\n\n") - out_file.write("class " + str(effect) + ":\n") - out_file.write(i1+"def __init__(self,mode=1,seParticleEffect=None,seParticles=None):\n") - out_file.write(i2+"if(mode==0):\n") - out_file.write(i2+i1+"self.effect=seParticleEffect.ParticleEffect()\n") - out_file.write(i2+"else:\n") - out_file.write(i2+i1+"self.effect=ParticleEffect.ParticleEffect()\n") - AllScene.particleDict[effect].AppendConfig(out_file) - #out_file.write(i2+"return self.effect\n") - out_file.write("\n\n") - out_file.write(i1+"def starteffect(self):\n") - out_file.write(i2+"pass\n") - out_file.write("\n\n") - out_file.write(i1+"def stopeffect(self):\n") - out_file.write(i2+"pass\n\n") - out_file.write(i1+"def getEffect(self):\n") - out_file.write(i2+"return self.effect\n\n") + out_file.write("\n\n") + out_file.write("class " + str(effect) + ":\n") + out_file.write(i1+"def __init__(self,mode=1,seParticleEffect=None,seParticles=None):\n") + out_file.write(i2+"if(mode==0):\n") + out_file.write(i2+i1+"self.effect=seParticleEffect.ParticleEffect()\n") + out_file.write(i2+"else:\n") + out_file.write(i2+i1+"self.effect=ParticleEffect.ParticleEffect()\n") + AllScene.particleDict[effect].AppendConfig(out_file) + #out_file.write(i2+"return self.effect\n") + out_file.write("\n\n") + out_file.write(i1+"def starteffect(self):\n") + out_file.write(i2+"pass\n") + out_file.write("\n\n") + out_file.write(i1+"def stopeffect(self):\n") + out_file.write(i2+"pass\n\n") + out_file.write(i1+"def getEffect(self):\n") + out_file.write(i2+"return self.effect\n\n") - #Un-comment the lines below to make this a stand-alone file + #Un-comment the lines below to make this a stand-alone file #out_file.write("Scene=SavedScene()\n") #out_file.write("run()\n") - out_file.close() - - + out_file.close() + + diff --git a/doc/SceneEditor/seForceGroup.py b/doc/SceneEditor/seForceGroup.py index 33e347a8d4..5b3d652307 100644 --- a/doc/SceneEditor/seForceGroup.py +++ b/doc/SceneEditor/seForceGroup.py @@ -96,8 +96,8 @@ class ForceGroup(DirectObject): def printParams(self, file = sys.stdout, targ = 'self'): """printParams(file, targ)""" - i1=" " - i2=i1+i1 + i1=" " + i2=i1+i1 file.write(i2+'# Force parameters\n') for i in range(self.node.getNumForces()): f = self.node.getForce(i) diff --git a/doc/SceneEditor/seLights.py b/doc/SceneEditor/seLights.py index 543e13d048..ade00e89ce 100644 --- a/doc/SceneEditor/seLights.py +++ b/doc/SceneEditor/seLights.py @@ -26,7 +26,7 @@ class seLight(NodePath): linear = 0.0, quadratic = 0.0, exponent = 0.0, - tag="", + tag="", lence = None): ################################################################# # __init__(self, light, parent, type, @@ -38,7 +38,7 @@ class seLight(NodePath): # linear = 0.0, # quadratic = 0.0, # exponent = 0.0, - # tag="", + # tag="", # lence = None): # This constructor will create a light node inside it and upcast # this light node to itself as a nodePath. @@ -68,24 +68,24 @@ class seLight(NodePath): node = light.upcastToPandaNode() # Attach node to self - self.LightNode=parent.attachNewNode(node) - self.LightNode.setTag("Metadata",tag) - if(self.type=='spot'): - self.LightNode.setHpr(self.orientation) - self.LightNode.setPos(self.position) - else: - self.LightNode.setHpr(self.orientation) - self.LightNode.setPos(self.position) - - - self.assign(self.LightNode) + self.LightNode=parent.attachNewNode(node) + self.LightNode.setTag("Metadata",tag) + if(self.type=='spot'): + self.LightNode.setHpr(self.orientation) + self.LightNode.setPos(self.position) + else: + self.LightNode.setHpr(self.orientation) + self.LightNode.setPos(self.position) + + + self.assign(self.LightNode) if(self.type=='spot'): self.helpModel = loader.loadModelCopy( "Spotlight" ) elif(self.type=='point'): self.helpModel = loader.loadModelCopy( "Pointlight" ) elif(self.type=='directional'): self.helpModel = loader.loadModelCopy( "Dirlight" ) - else: + else: self.helpModel = loader.loadModelCopy( "misc/Sphere" ) self.helpModel.setColor(self.lightcolor) self.helpModel.reparentTo(self) @@ -156,7 +156,7 @@ class seLight(NodePath): # Although you can call this function for all kinds of light, # it will only meanful if this light is not a ambient light. ################################################################# - return self.specularColor + return self.specularColor def setSpecColor(self,color): ################################################################# @@ -178,7 +178,7 @@ class seLight(NodePath): # It only has meaning for "point Light" and "Directional light" ################################################################# self.position = self.LightNode.getPos() - return self.position + return self.position def setPosition(self, pos): ################################################################# @@ -201,8 +201,8 @@ class seLight(NodePath): # ################################################################# self.orientation = self.LightNode.getHpr() - return self.orientation - + return self.orientation + def setOrientation(self,orient): ################################################################# # setOrientation(self, orient) @@ -228,7 +228,7 @@ class seLight(NodePath): # tyoe of lights. # ################################################################# - return Vec3(self.constant,self.linear,self.quadratic) + return Vec3(self.constant,self.linear,self.quadratic) def setConstantAttenuation(self, value): ################################################################# @@ -269,7 +269,7 @@ class seLight(NodePath): # This function will return the value of the Exponent Attenuation # of this light node. (float) ################################################################# - return self.exponent + return self.exponent def setExponent(self, value): ################################################################# @@ -291,8 +291,8 @@ class seLightManager(NodePath): # Initialize the superclass NodePath.__init__(self) # Create a node for the lights - self.lnode=render.attachNewNode('Lights') - self.assign(self.lnode) + self.lnode=render.attachNewNode('Lights') + self.assign(self.lnode) # Create a light attrib self.lightAttrib = LightAttrib.makeAllOff() self.lightDict = {} @@ -319,8 +319,8 @@ class seLightManager(NodePath): linear = 0.0, quadratic = 0.0, exponent = 0.0, - tag= "", - name='DEFAULT_NAME'): + tag= "", + name='DEFAULT_NAME'): ################################################################# # create(self, type = 'ambient', # lightcolor=VBase4(0.3,0.3,0.3,1), @@ -331,12 +331,12 @@ class seLightManager(NodePath): # linear = 0.0, # quadratic = 0.0, # exponent = 0.0, - # tag= "", - # name='DEFAULT_NAME') - # As you can see, once user call this function and specify those - # variables, this function will create a seLight node. - # In the default, the light which just has been created will be - # set to off. + # tag= "", + # name='DEFAULT_NAME') + # As you can see, once user call this function and specify those + # variables, this function will create a seLight node. + # In the default, the light which just has been created will be + # set to off. ################################################################# ### create the light @@ -344,10 +344,10 @@ class seLightManager(NodePath): if type == 'ambient': self.ambientCount += 1 - if(name=='DEFAULT_NAME'): + if(name=='DEFAULT_NAME'): light = AmbientLight('ambient_' + `self.ambientCount`) - else: - light = AmbientLight(name) + else: + light = AmbientLight(name) light.setColor(lightcolor) @@ -355,18 +355,18 @@ class seLightManager(NodePath): self.directionalCount += 1 if(name=='DEFAULT_NAME'): light = DirectionalLight('directional_' + `self.directionalCount`) - else: - light = DirectionalLight(name) + else: + light = DirectionalLight(name) light.setColor(lightcolor) light.setSpecularColor(specularColor) elif type == 'point': self.pointCount += 1 - if(name=='DEFAULT_NAME'): + if(name=='DEFAULT_NAME'): light = PointLight('point_' + `self.pointCount`) - else: - light = PointLight(name) + else: + light = PointLight(name) light.setColor(lightcolor) light.setSpecularColor(specularColor) @@ -374,10 +374,10 @@ class seLightManager(NodePath): elif type == 'spot': self.spotCount += 1 - if(name=='DEFAULT_NAME'): + if(name=='DEFAULT_NAME'): light = Spotlight('spot_' + `self.spotCount`) - else: - light = Spotlight(name) + else: + light = Spotlight(name) light.setColor(lightcolor) lence = PerspectiveLens() @@ -399,9 +399,9 @@ class seLightManager(NodePath): linear = linear, quadratic = quadratic, exponent = exponent, - tag=tag, + tag=tag, lence = lence - ) + ) self.lightDict[light.getName()] = lightNode self.setOn(lightNode) @@ -629,4 +629,4 @@ class seLightManager(NodePath): # This function actually has the same functionality with getLightList(), # but this one should be more efficient. ################################################################# - return self.lightDict.keys() + return self.lightDict.keys() diff --git a/doc/SceneEditor/seManipulation.py b/doc/SceneEditor/seManipulation.py index 2cec90079a..32e6e0b8a7 100644 --- a/doc/SceneEditor/seManipulation.py +++ b/doc/SceneEditor/seManipulation.py @@ -94,7 +94,7 @@ class DirectManipulationControl(PandaObject): return Task.cont def manipulationStop(self,xy=[]): - taskMgr.remove('manipulateObject') + taskMgr.remove('manipulateObject') taskMgr.remove('manip-move-wait') taskMgr.remove('manip-watch-mouse') # depending on flag..... diff --git a/doc/SceneEditor/seParticleEffect.py b/doc/SceneEditor/seParticleEffect.py index b47d156d2d..8d9106942d 100644 --- a/doc/SceneEditor/seParticleEffect.py +++ b/doc/SceneEditor/seParticleEffect.py @@ -209,12 +209,12 @@ class ParticleEffect(NodePath): """loadConfig(filename)""" #try: # if vfs: - print vfs.readFile(filename) + print vfs.readFile(filename) exec vfs.readFile(filename) - print "Particle Effect Reading using VFS" + print "Particle Effect Reading using VFS" # else: - # execfile(filename.toOsSpecific()) - # print "Shouldnt be wrong" + # execfile(filename.toOsSpecific()) + # print "Shouldnt be wrong" #except: # self.notify.error('loadConfig: failed to load particle file: '+ repr(filename)) @@ -222,7 +222,7 @@ class ParticleEffect(NodePath): def AppendConfig(self, f): f.write('\n') - i1=" " + i1=" " i2=i1+i1 # Make sure we start with a clean slate f.write(i2+'self.effect.reset()\n') @@ -242,9 +242,9 @@ class ParticleEffect(NodePath): for p in self.particlesDict.values(): target = 'p%d' % num num = num + 1 - f.write(i2+"if(mode==0):\n") - f.write(i2+i1+target + ' = seParticles.Particles(\'%s\')\n' % p.getName()) - f.write(i2+"else:\n") + f.write(i2+"if(mode==0):\n") + f.write(i2+i1+target + ' = seParticles.Particles(\'%s\')\n' % p.getName()) + f.write(i2+"else:\n") f.write(i2+i1+target + ' = Particles.Particles(\'%s\')\n' % p.getName()) p.printParams(f, target) f.write(i2+'self.effect.addParticles(%s)\n' % target) diff --git a/doc/SceneEditor/seParticlePanel.py b/doc/SceneEditor/seParticlePanel.py index cad5dbb70f..0f1d07469e 100644 --- a/doc/SceneEditor/seParticlePanel.py +++ b/doc/SceneEditor/seParticlePanel.py @@ -34,7 +34,7 @@ class ParticlePanel(AppShell): # Record particle effect if particleEffect != None: self.particleEffect = particleEffect - self.effectsDict = effectsDict + self.effectsDict = effectsDict else: # Or create a new one if none given particles = seParticles.Particles() @@ -47,17 +47,17 @@ class ParticlePanel(AppShell): particles.enable() pe = seParticleEffect.ParticleEffect('effect1', particles) self.particleEffect = pe - self.emitter=loader.loadModel("sphere") - pe.reparentTo(self.emitter) - self.emitter.setName("effect1") - self.emitter.reparentTo(render) + self.emitter=loader.loadModel("sphere") + pe.reparentTo(self.emitter) + self.emitter.setName("effect1") + self.emitter.reparentTo(render) pe.enable() messenger.send('ParticlePanel_Added_Effect',['effect1',pe,self.emitter]) - self.effectsDict[self.particleEffect.getName()]=self.particleEffect - + self.effectsDict[self.particleEffect.getName()]=self.particleEffect + + + messenger.send('SGE_Update Explorer',[render]) - messenger.send('SGE_Update Explorer',[render]) - # Initialize application specific info AppShell.__init__(self) @@ -1713,7 +1713,7 @@ class ParticlePanel(AppShell): name = askstring('Particle Panel', 'Effect Name:', parent = self.parent) if name: - particles = seParticles.Particles() + particles = seParticles.Particles() particles.setBirthRate(0.02) particles.setLitterSize(10) particles.setLitterSpread(0) @@ -1725,12 +1725,12 @@ class ParticlePanel(AppShell): self.effectsDict[name] = effect self.updateMenusAndLabels() self.selectEffectNamed(name) - self.emitter=loader.loadModel("sphere") - self.emitter.setName(name) - effect.reparentTo(self.emitter) - self.emitter.reparentTo(render) + self.emitter=loader.loadModel("sphere") + self.emitter.setName(name) + effect.reparentTo(self.emitter) + self.emitter.reparentTo(render) effect.enable() - messenger.send('ParticlePanel_Added_Effect',[name,effect,self.emitter]) + messenger.send('ParticlePanel_Added_Effect',[name,effect,self.emitter]) messenger.send('SGE_Update Explorer',[render]) def createNewParticles(self): diff --git a/doc/SceneEditor/seParticles.py b/doc/SceneEditor/seParticles.py index eddeea13a3..3980ed357b 100644 --- a/doc/SceneEditor/seParticles.py +++ b/doc/SceneEditor/seParticles.py @@ -223,8 +223,8 @@ class Particles(ParticleSystem.ParticleSystem): def printParams(self, file = sys.stdout, targ = 'self'): """printParams(file, targ)""" - i1=" " - i2=i1+i1 + i1=" " + i2=i1+i1 file.write(i2+'# Particles parameters\n') file.write(i2+targ + '.setFactory(\"' + self.factoryType + '\")\n') file.write(i2+targ + '.setRenderer(\"' + self.rendererType + '\")\n') diff --git a/doc/SceneEditor/seSelection.py b/doc/SceneEditor/seSelection.py index 96e4772a98..93933aa346 100644 --- a/doc/SceneEditor/seSelection.py +++ b/doc/SceneEditor/seSelection.py @@ -550,13 +550,13 @@ class SelectionRay(SelectionQueue): # No mouse in window. self.clearEntries() return - mx = base.mouseWatcherNode.getMouseX() + mx = base.mouseWatcherNode.getMouseX() my = base.mouseWatcherNode.getMouseY() #base.mouseWatcherNode.setDisplayRegion(base.win.getDisplayRegion(0)) #mx = base.mouseWatcherNode.getMouseX()+1 #my = base.mouseWatcherNode.getMouseY()+1 - #print base.camNode.getName() - #print "Arrived X" + str(mx) + " Arrived Y " + str(my) + #print base.camNode.getName() + #print "Arrived X" + str(mx) + " Arrived Y " + str(my) self.collider.setFromLens( base.camNode, mx, my ) self.ct.traverse( targetNodePath )