home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / OnOff.py < prev    next >
Encoding:
Text File  |  2000-10-27  |  3.3 KB  |  143 lines

  1. import AuxFuncs
  2. import Bladex
  3.  
  4.  
  5.                   #################################
  6. #-------------##### Apagado y encendido de luces  #####----------------#
  7.  
  8. LightDictionary={} # dictionary of functions
  9.  
  10. LightSpeed     =   0.02
  11. LightSetInens  = 130.0 
  12. LightSetRadius =   0.03
  13. LightSetColor  = (255,165,64)
  14.  
  15. #
  16. # Adds the predefined lights values
  17. #---------------------------------------
  18. def AddLightData(objname,Inens=LightSetInens,Radius=LightSetRadius,Color=LightSetColor):
  19.    if(not LightDictionary.has_key( objname ) ):
  20.      LightDictionary[objname] = Inens,Radius,Color
  21.  
  22. def GetLightData(objname):
  23.    global LightSetRadius
  24.    global LightSetInens
  25.    global LightSetColor
  26.    
  27.    if(LightDictionary.has_key( objname ) ):
  28.      LightSetInens  = LightDictionary[objname][0]
  29.      LightSetRadius = LightDictionary[objname][1]
  30.      LightSetColor  = LightDictionary[objname][2]
  31.  
  32.  
  33.  
  34.  
  35.  
  36. def SetLightSpeed(xxx):
  37.   global LightSpeed
  38.   LightSpeed = xxx
  39.  
  40. def SetLightInens(xxx):
  41.   global LightSetInens
  42.   LightSetInens = xxx
  43.  
  44. def SetLightRadius(xxx):
  45.   global LightSetRadius
  46.   LightSetRadius = xxx
  47.  
  48.  
  49. #
  50. # Cambia la intensidad de la antorcha
  51. #------------------------------------------
  52. def SetLightIntesity(LightName,Intens):
  53.   global LightSetRadius
  54.   global LightSetInens
  55.  
  56.   o = Bladex.GetEntity(LightName)
  57.   o.Lights=[ (LightSetInens*Intens,LightSetRadius,LightSetColor) ]
  58.   o.FiresIntensity=[ 20-20*Intens ]
  59.  
  60. #
  61. # Obtiene la intensidad de la antorcha
  62. #------------------------------------------
  63. def GetLightIntesity(LightName):
  64.   global LightSetRadius
  65.   global LightSetInens
  66.   
  67.   o = Bladex.GetEntity(LightName)
  68.   spot = AuxFuncs.GetSpot(o)
  69.  
  70.   spot.SizeFactor = spot.Intensity/LightSetInens
  71.  
  72.   return spot.Intensity/LightSetInens
  73.  
  74.  
  75. Bladex.CreateTimer("LightTimer",0.2)
  76.  
  77.  
  78. def TurnOffTimer(e_name, time):
  79.   global LightSpeed
  80.   
  81.   Intesity = GetLightIntesity(e_name)-LightSpeed*4  
  82.     
  83.   if(Intesity<=0):
  84.     o = Bladex.GetEntity(e_name)
  85.     o.TimerFunc = ""    
  86.     o.RemoveFromList("LightTimer")
  87.     Intesity = 0
  88.   
  89.   SetLightIntesity(e_name,Intesity )
  90.  
  91. #
  92. # Apaga lentamente una luz
  93. #---------------------------
  94. def TurnOffLight(LightName):
  95.  
  96.   o = Bladex.GetEntity(LightName)
  97.   o.SubscribeToList("LightTimer")
  98.   o.TimerFunc=TurnOffTimer
  99.  
  100.  
  101. def TurnOnTimer(e_name, time):
  102.   global LightSpeed
  103.   global LightSetInens
  104.   global LightSetRadius  
  105.   global LightSetColor
  106.  
  107.   AuxLightSetInens  = LightSetInens
  108.   AuxLightSetRadius = LightSetRadius
  109.   GetLightData(e_name)
  110.  
  111.   Intesity = GetLightIntesity(e_name)+LightSpeed*4  
  112.     
  113.   if(Intesity>=1):
  114.     o = Bladex.GetEntity(e_name)
  115.     o.TimerFunc = ""
  116.     o.RemoveFromList("LightTimer")
  117.     Intesity = 1
  118.     
  119.   SetLightIntesity(e_name,Intesity )
  120.  
  121.   LightSetInens  = AuxLightSetInens
  122.   LightSetRadius = AuxLightSetRadius
  123.  
  124.  
  125.     
  126. #
  127. # Enciende lentamente una luz
  128. #------------------------------
  129. def TurnOnLight(LightName):
  130.   global LightSetInens
  131.   global LightSetRadius
  132.   global LightSetColor
  133.  
  134.   GetLightData(LightName)
  135.   AddLightData(LightName,LightSetInens,LightSetRadius,LightSetColor)
  136.   
  137.   o = Bladex.GetEntity(LightName)
  138.   o.SubscribeToList("LightTimer")
  139.   o.TimerFunc = TurnOnTimer
  140.  
  141. #-------------##### Apagado y encendido de luces  #####----------------#
  142.                   #################################
  143.