def SetRendererStyle(self, vstyle="default"): self.chatMgr.AddChatLine(None, ">SetRendererStyle {}".format(vstyle), 3) try: xBotAge.SetRenderer(style=vstyle) self.chatMgr.AddChatLine(None, "==> done.", 3) return 1 except: return 0
def SetRendererFogLinear(self, vstart=None, vend=None, vdensity=None): self.chatMgr.AddChatLine( None, ">SetRendererFogLinear {}, {}, {}".format(vstart, vend, vdensity), 3) try: xBotAge.SetRenderer(style=None, start=vstart, end=vend, density=vdensity) self.chatMgr.AddChatLine(None, "==> done.", 3) return 1 except: return 0
def DayTime(): #SetFog(style = "default") xBotAge.SetRenderer(style="default") # objets a remettre en fonction de l'age ageFileName = PtGetAgeInfo().getAgeFilename() #for objName in Objects.dicObjectsShowHide[ageFilename]["SingleShow"]: # ToggleObject(objName, ageFileName, True) #for objName in Objects.dicObjectsShowHide[ageFilename]["GroupShow"]: # ToggleObjects(objName, True) for objName in Objects.dicObjectsShowHide[ageFileName]["SingleShow"]: print ">> DayTime: ToggleObject({}, {}, True)".format( objName, ageFileName) try: ToggleObject(objName, ageFileName, True) except NameError: print ">> DayTime: SceneObject {} not found in {}".format( objName, ageFileName) for objName in Objects.dicObjectsShowHide[ageFileName]["GroupShow"]: print ">> DayTime: ToggleObjects({}, True)".format(objName) ToggleObjects(objName, True)
def SetRendererFogColor(self, vr=None, vg=None, vb=None): self.chatMgr.AddChatLine( None, ">SetRendererFogColor {}, {}, {}".format(vr, vg, vb), 3) try: vr = float(vr) except: pass try: vg = float(vg) except: pass try: vb = float(vb) except: pass try: xBotAge.SetRenderer(style=None, r=vr, g=vg, b=vb) self.chatMgr.AddChatLine(None, "==> done. {}, {}, {}".format(vr, vg, vb), 3) return 1 except: return 0
def DayTime(masterKey): # arretons le fog a couleur changeante Fog.Stop() # arretons les rotations if autoRotationTop is not None: print "stop rot top" autoRotationTop.Stop() if autoRotationBottom is not None: print "stop rot bottom" autoRotationBottom.Stop() CloneFactory.DechargerClones(masterKey) # rendu normal de l'age xBotAge.SetRenderer(style = "default") # objets a remettre en fonction de l'age ageFileName = PtGetAgeInfo().getAgeFilename() # les objets a cacher for objName in Objects2.dicObjectsShowHide[ageFileName]["SingleShow"]["Day"]: print ">> DayTime: ToggleObject({}, {}, True)".format(objName, ageFileName) try: ToggleObject(objName, ageFileName, True) except NameError: print ">> DayTime: SceneObject {} not found in {}".format(objName, ageFileName) for objName in Objects2.dicObjectsShowHide[ageFileName]["GroupShow"]["Day"]: print ">> DayTime: ToggleObjects({}, True)".format(objName) ToggleObjects(objName, True) # les objets a montrer for objName in Objects2.dicObjectsShowHide[ageFileName]["SingleHide"]["Day"]: print ">> DayTime: ToggleObject({}, {}, False)".format(objName, ageFileName) try: ToggleObject(objName, ageFileName, False) except NameError: print ">> DayTime: SceneObject {} not found in {}".format(objName, ageFileName) for objName in Objects2.dicObjectsShowHide[ageFileName]["GroupHide"]["Day"]: print ">> DayTime: ToggleObjects({}, False)".format(objName) ToggleObjects(objName, False)
def NightTime(params=[]): print "NightTime begin" global autoRotationTop global autoRotationBottom #Verifions les parametres if len(params) > 1: scale = params[1] else: scale = 7.5 if len(params) > 0: masterKey = params[0] if not isinstance(masterKey, ptKey): print "NightTime: first paremeter must be a ptKey" return 1 if len(params) == 0: print "NightTime: needs 1 or 2 paremeters" return 1 print "NightTime params ok" soMaster = masterKey.getSceneObject() print "NightTime({}, {})".format(soMaster.getName(), scale) # Manipulons les clones cloneKeys = PtFindClones(masterKey) soTop = cloneKeys[0].getSceneObject() soBottom = cloneKeys[1].getSceneObject() pos = soMaster.getLocalToWorld() mrot = ptMatrix44() mrot.rotate(0, math.pi) mscale = ptMatrix44() mscale.makeScaleMat(ptVector3(scale, scale, scale)) mtransUp = ptMatrix44() #TODO: ajouter eventuellement des decalages en X et/ou Y si on cree la nuit dans un autre age que le Relto mtransUp.translate(ptVector3(.0, .0, 64*scale/15)) mtransDown = ptMatrix44() mtransDown.translate(ptVector3(.0, .0, -64*scale/15)) soTop.netForce(1) soBottom.netForce(1) soTop.physics.warp(pos * mtransUp * mscale * mrot) soBottom.physics.warp(pos * mtransDown * mscale) soTop.draw.enable(1) soBottom.draw.enable(1) # Arrangeons l'age pour profiter de la nuit etoilee ageFileName = PtGetAgeInfo().getAgeFilename() print ">> NightTime: ageFileName = '{}'".format(ageFileName) # le style de rendu xBotAge.SetRenderer(style = "100000", start = 0, end = 0, density = 0, r = 0.2, g = 0.2, b = 0.4, cr = 0.4, cg = 0.4, cb = 0.5) # les objets a cacher for objName in Objects2.dicObjectsShowHide[ageFileName]["SingleHide"]["Night"]: print ">> NightTime: ToggleObject({}, {}, False)".format(objName, ageFileName) try: ToggleObject(objName, ageFileName, False) except NameError: print ">> NightTime: SceneObject {} not found in {}".format(objName, ageFileName) for objName in Objects2.dicObjectsShowHide[ageFileName]["GroupHide"]["Night"]: print ">> NightTime: ToggleObjects({}, False)".format(objName) ToggleObjects(objName, False) # les objets a montrer for objName in Objects2.dicObjectsShowHide[ageFileName]["SingleShow"]["Night"]: print ">> NightTime: ToggleObject({}, {}, True)".format(objName, ageFileName) try: ToggleObject(objName, ageFileName, True) except NameError: print ">> NightTime: SceneObject {} not found in {}".format(objName, ageFileName) for objName in Objects2.dicObjectsShowHide[ageFileName]["GroupShow"]["Night"]: print ">> NightTime: ToggleObjects({}, True)".format(objName) ToggleObjects(objName, True) # Ajoutons le fog a couleur changeante #Fog.Start() Fog.Start(delay=2., start=None, end=None, density=None) # rotation du ciel posTop = soTop.getLocalToWorld() posBottom = soBottom.getLocalToWorld() m = ptMatrix44() # rotation de 45 degres en x m.rotate(0, (math.pi * float(45)) / 180) soTop.netForce(1) soBottom.netForce(1) soTop.physics.warp(posTop * m) soBottom.physics.warp(posBottom * m) #init autoRotationTop and autoRotationBottom if autoRotationTop is None: print "autoRotationTop is None" autoRotationTop = Rotation.AutoRotation(delay=1., so=soTop, stepZ=.05) #autoRotationTop = Rotation.AutoRotation(delay=4., so=soTop, stepZ=.4) if autoRotationBottom is None: print "autoRotationBottom is None" autoRotationBottom = Rotation.AutoRotation(delay=1., so=soBottom, stepZ=-.05) #autoRotationBottom = Rotation.AutoRotation(delay=4., so=soBottom, stepZ=-.4) # start rotations if autoRotationTop is not None: print "start rot top" autoRotationTop.Start() if autoRotationBottom is not None: print "start rot bottom" autoRotationBottom.Start() print "NightTime done" return 0
def NightTime2(params=[]): print "NightTime2 begin" #Verifions les parametres #if len(params) > 3: # duration = params[3] #else: # duration = 30 if len(params) > 2: style = params[2] else: style = "default" if len(params) > 1: scale = params[1] else: scale = 7.5 if len(params) > 0: masterKey = params[0] if not isinstance(masterKey, ptKey): print "NightTime2: first paremeter must be a ptKey" return 1 if len(params) == 0: print "NightTime2: needs 1 or 2 paremeters" return 1 print "NightTime2 params ok" soMaster = masterKey.getSceneObject() print "NightTime2({}, {}, {})".format(soMaster.getName(), scale, style) # Manipulons les clones cloneKeys = PtFindClones(masterKey) soTop = cloneKeys[0].getSceneObject() soBottom = cloneKeys[1].getSceneObject() pos = soMaster.getLocalToWorld() mrot = ptMatrix44() mrot.rotate(0, math.pi) mscale = ptMatrix44() mscale.makeScaleMat(ptVector3(scale, scale, scale)) mtransUp = ptMatrix44() #TODO: ajouter eventuellement des decalages en X et/ou Y si on cree la nuit dans un autre age que le Relto mtransUp.translate(ptVector3(.0, .0, 64*scale/15)) mtransDown = ptMatrix44() mtransDown.translate(ptVector3(.0, .0, -64*scale/15)) soTop.netForce(1) soBottom.netForce(1) soTop.physics.warp(pos * mtransUp * mscale * mrot) soBottom.physics.warp(pos * mtransDown * mscale) soTop.draw.enable(1) soBottom.draw.enable(1) # Arrangeons l'age pour profiter de la nuit etoilee ageFileName = PtGetAgeInfo().getAgeFilename() print ">> NightTime2: ageFileName = '{}'".format(ageFileName) # Changeons le fond ciel et le brouillard ici print ">> NightTime2: style=\"{}\"".format(style) dicParamsStyle = {"style":"100000", "start":0, "end":0, "density":0, "r":0.2, "g":0.2, "b":0.4, "cr":0.4, "cg":0.4, "cb":0.5} if style in dicStyles: dicParamsStyle = dicStyles[style] #else: # dicParamsStyle = dicStyles["default"] xBotAge.SetRenderer( style = dicParamsStyle["style"], start = dicParamsStyle["start"], end = dicParamsStyle["end"], density = dicParamsStyle["density"], r = dicParamsStyle["r"], g = dicParamsStyle["g"], b = dicParamsStyle["b"], cr = dicParamsStyle["cr"], cg = dicParamsStyle["cg"], cb = dicParamsStyle["cb"] ) # les objets a cacher for objName in Objects2.dicObjectsShowHide[ageFileName]["SingleHide"]["Night"]: print ">> NightTime2: ToggleObject({}, {}, False)".format(objName, ageFileName) try: ToggleObject(objName, ageFileName, False) except NameError: print ">> NightTime2: SceneObject {} not found in {}".format(objName, ageFileName) for objName in Objects2.dicObjectsShowHide[ageFileName]["GroupHide"]["Night"]: print ">> NightTime2: ToggleObjects({}, False)".format(objName) ToggleObjects(objName, False) # les objets a montrer for objName in Objects2.dicObjectsShowHide[ageFileName]["SingleShow"]["Night"]: print ">> NightTime2: ToggleObject({}, {}, True)".format(objName, ageFileName) try: ToggleObject(objName, ageFileName, True) except NameError: print ">> NightTime2: SceneObject {} not found in {}".format(objName, ageFileName) for objName in Objects2.dicObjectsShowHide[ageFileName]["GroupShow"]["Night"]: print ">> NightTime2: ToggleObjects({}, True)".format(objName) ToggleObjects(objName, True) print "NightTime2 done" #PtSetAlarm(duration, AlarmDayTime(masterKey), 1) return 0
def SetRendererClearColor(self, vcr=None, vcg=None, vcb=None): self.chatMgr.AddChatLine( None, ">SetRendererClearColor {}, {}, {}".format(vcr, vcg, vcb), 3) strCol = None numero = None dicColors = { "white": [1, 1, 1], "red": [1, 0, 0], "orange": [1, .5, 0], "brown": [1, .6, .15], "yellow": [1, 1, 0], "green": [0, 1, 0], "blue": [0, 0, 1], "violet": [1, 0, 1], "black": [0, 0, 0], "gold": [1, .84, 0], } if isinstance(vcr, float): vcr = float(vcr) self.chatMgr.AddChatLine(None, ">SetRendererClearColor vcr = {}".format(vcr), 3) else: strCol = str(vcr).lower() numero = 1 match = re.match(r"([a-z]+)([1-5])", strCol, re.I) if match: items = match.groups() strCol = items[0] numero = int(items[1]) self.chatMgr.AddChatLine( None, ">SetRendererClearColor match: strCol = {}, numero = {}". format(strCol, numero), 3) # nom de couleur connu? if strCol in dicColors.keys(): #vcr = float(dicColors[strCol][0]) * (6. - float(numero)) / 5. #vcg = float(dicColors[strCol][1]) * (6. - float(numero)) / 5. #vcb = float(dicColors[strCol][2]) * (6. - float(numero)) / 5 vcr = float(dicColors[strCol][0]) * ((6. - float(numero)) / 5.)**2 vcg = float(dicColors[strCol][1]) * ((6. - float(numero)) / 5.)**2 vcb = float(dicColors[strCol][2]) * ((6. - float(numero)) / 5.)**2 self.chatMgr.AddChatLine( None, ">SetRendererClearColor color found and converted: ({}, {}, {})." .format(vcr, vcg, vcb), 3) else: vcr = None vcg = None vcb = None self.chatMgr.AddChatLine( None, ">SetRendererClearColor color not found, converted in: ({}, {}, {})." .format(vcr, vcg, vcb), 3) if strCol is None: if isinstance(vcg, float): vcg = float(vcg) else: vcg = None if isinstance(vcb, float): vcb = float(vcb) else: vcb = None try: xBotAge.SetRenderer(style=None, cr=vcr, cg=vcg, cb=vcb) self.chatMgr.AddChatLine( None, "==> done. Back color changed to {} {} ==> ({}, {}, {}).".format( strCol, numero, vcr, vcg, vcb), 3) return 1 except: return 0
def NightTime(params=[]): print "NightTime begin" #Verifions les parametres if len(params) > 1: scale = params[1] else: scale = 7.5 if len(params) > 0: masterKey = params[0] if not isinstance(masterKey, ptKey): print "NightTime: first paremeter must be a ptKey" return 1 if len(params) == 0: print "NightTime: needs 1 or 2 paremeters" return 1 print "NightTime params ok" soMaster = masterKey.getSceneObject() print "NightTime({}, {})".format(soMaster.getName(), scale) # Manipulons les clones cloneKeys = PtFindClones(masterKey) soTop = cloneKeys[0].getSceneObject() soBottom = cloneKeys[1].getSceneObject() pos = soMaster.getLocalToWorld() mrot = ptMatrix44() mrot.rotate(0, math.pi) mscale = ptMatrix44() #TODO: peut-etre mettre des echelles differentes en X, Y ou Z si on cree la nuit dans un autre age que le Relto mscale.makeScaleMat(ptVector3(scale, scale, scale)) mtransUp = ptMatrix44() #TODO: ajouter eventuellement des decalages en X et/ou Y si on cree la nuit dans un autre age que le Relto mtransUp.translate(ptVector3(.0, .0, 64 * scale / 15)) mtransDown = ptMatrix44() mtransDown.translate(ptVector3(.0, .0, -64 * scale / 15)) soTop.netForce(1) soBottom.netForce(1) soTop.physics.warp(pos * mtransUp * mscale * mrot) soBottom.physics.warp(pos * mtransDown * mscale) soTop.draw.enable(1) soBottom.draw.enable(1) # Arrangeons le Relto pour profiter de la nuit etoilee """ SetFog(style = "10000", start = 0, end = 0, density = 0, r = 0.2, g = 0.2, b = 0.4, cr = 0.4, cg = 0.4, cb = 0.5) ToggleObjects("Fog", False) ToggleObjects("Surface", False) ToggleObjects("Sky", False) ToggleObjects("CameraClouds", False) #En ville, enlever CityBackDrop et CloudLayer (dans harbor) #Pour avoir avoir des etoiles bien visibles mettre du brouillard #style Personal et fogshape 0 10000 2 """ ageFileName = PtGetAgeInfo().getAgeFilename() print ">> NightTime: ageFileName = '{}'".format(ageFileName) #xBotAge.SetRenderer(style = "Personal") xBotAge.SetRenderer(style="100000", start=0, end=0, density=0, r=0.2, g=0.2, b=0.4, cr=0.4, cg=0.4, cb=0.5) for objName in Objects.dicObjectsShowHide[ageFileName]["SingleHide"]: print ">> NightTime: ToggleObject({}, {}, False)".format( objName, ageFileName) try: ToggleObject(objName, ageFileName, False) except NameError: print ">> NightTime: SceneObject {} not found in {}".format( objName, ageFileName) for objName in Objects.dicObjectsShowHide[ageFileName]["GroupHide"]: print ">> NightTime: ToggleObjects({}, False)".format(objName) ToggleObjects(objName, False) print "NightTime done" return 0
def DayTime_v1(): #SetFog(style = "default") xBotAge.SetRenderer(style="default") # objets a remettre en fonction de l'age ageFilename = PtGetAgeInfo().getAgeFilename() if ageFilename == "Personal": #TODO: jouer avec les SDL (page relto des iles) pour savoir laquelle des deux couches de brouillards remettre (FogLayer ou FogLayerBill) #ToggleObject("FogLayerBill", True) ToggleObject("FogLayer", ageFileName, True) #Sol du Relto ToggleObjects("Surface", True) #Les ciels ToggleObjects("Sky", True) #Couche de brouillard superieure ToggleObjects("CameraClouds", True) print ">> DayTime: {} is restored.".format(ageFilename) elif ageFilename == "Ahnonay": print "{} is restored.".format(ageFilename) elif ageFilename == "AhnonayCathedral": print "{} is restored.".format(ageFilename) elif ageFilename == "BahroCave": print "{} is restored.".format(ageFilename) elif ageFilename == "BaronCityOffice": print "{} is restored.".format(ageFilename) elif ageFilename == "city": #CityBackDrop et CloudLayer ToggleObject("CityBackDrop", ageFileName, True) ToggleObject("CloudLayer", ageFileName, True) print "{} is restored.".format(ageFilename) elif ageFilename == "Cleft": print "{} is restored.".format(ageFilename) elif ageFilename == "Dereno": print "{} is restored.".format(ageFilename) elif ageFilename == "Descent": print "{} is restored.".format(ageFilename) elif ageFilename == "EderDelin": print "{} is restored.".format(ageFilename) elif ageFilename == "EderTsogal": print "{} is restored.".format(ageFilename) elif ageFilename == "Ercana": print "{} is restored.".format(ageFilename) elif ageFilename == "ErcanaCitySilo": print "{} is restored.".format(ageFilename) elif ageFilename == "Garden": print "{} is restored.".format(ageFilename) elif ageFilename == "Garrison": print "{} is restored.".format(ageFilename) elif ageFilename == "Gira": print "{} is restored.".format(ageFilename) elif ageFilename == "GreatTreePub": print "{} is restored.".format(ageFilename) elif ageFilename == "GreatZero": print "{} is restored.".format(ageFilename) elif ageFilename == "GuildPub-Cartographers": print "{} is restored.".format(ageFilename) elif ageFilename == "GuildPub-Greeters": print "{} is restored.".format(ageFilename) elif ageFilename == "GuildPub-Maintainers": print "{} is restored.".format(ageFilename) elif ageFilename == "GuildPub-Messengers": print "{} is restored.".format(ageFilename) elif ageFilename == "GuildPub-Writers": print "{} is restored.".format(ageFilename) elif ageFilename == "Jalak": print "{} is restored.".format(ageFilename) elif ageFilename == "Kadish": print "{} is restored.".format(ageFilename) elif ageFilename == "Kveer": print "{} is restored.".format(ageFilename) elif ageFilename == "LiveBahroCaves": print "{} is restored.".format(ageFilename) elif ageFilename == "Minkata": print "{} is restored.".format(ageFilename) elif ageFilename == "Myst": print "{} is restored.".format(ageFilename) elif ageFilename == "Negilahn": print "{} is restored.".format(ageFilename) elif ageFilename == "Neighborhood": print "{} is restored.".format(ageFilename) elif ageFilename == "Neighborhood02": print "{} is restored.".format(ageFilename) elif ageFilename == "Payiferen": print "{} is restored.".format(ageFilename) elif ageFilename == "PelletBahroCave": print "{} is restored.".format(ageFilename) elif ageFilename == "philRelto": print "{} is restored.".format(ageFilename) elif ageFilename == "spyroom": print "{} is restored.".format(ageFilename) elif ageFilename == "Teledahn": print "{} is restored.".format(ageFilename) elif ageFilename == "Tetsonot": print "{} is restored.".format(ageFilename) else: print "Unknown age" return 0