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

  1. import Bladex
  2. import netgame
  3. import AuxFuncs
  4.  
  5. PTS=[]
  6.  
  7. def AddNode(Source,Target,time=2):
  8.     global PTS
  9.     
  10.     PTS.append(Source,Target,time)
  11.  
  12. def ResetNode():
  13.     global PTS
  14.     global Counter
  15.     global auxi1
  16.     global auxi2
  17.     global CallBack
  18.     global LastTime
  19.     
  20.     PTS=[]
  21.     Counter = 0
  22.     auxi1 = (0,0,0)
  23.     auxi2 = (0,0,0)
  24.     CallBack = None
  25.     LastTime = 2
  26.     
  27. def SaveNode(time = 2):
  28.     global PTS
  29.     
  30.     cam=Bladex.GetEntity("Camera")
  31.     PTS.append(cam.Position, cam.TPos, time)
  32.  
  33. def ChNode(idx,time = 2):
  34.     global PTS
  35.     
  36.     cam=Bladex.GetEntity("Camera")
  37.     PTS[idx]=(cam.Position, cam.TPos, time)    
  38.  
  39. def ZoomNode(idx,Zoom=0.5):
  40.     global PTS
  41.     n = PTS[idx]
  42.     iZoom = 1.0 - Zoom
  43.     PTS[idx] = (n[0][0]*iZoom+n[1][0]*Zoom, n[0][1]*iZoom+n[1][1]*Zoom, n[0][2]*iZoom+n[1][2]*Zoom), n[1], n[2]
  44.  
  45.     
  46. Counter = 0
  47. auxi1 = (0,0,0)
  48. auxi2 = (0,0,0)
  49. CallBack = None
  50. LastTime = 2
  51.  
  52. def GetTime(tupla):
  53.     if(len(tupla)==2):
  54.         return 2
  55.     else:
  56.         if(len(tupla)!=3):
  57.             tupla[3]()
  58.         return tupla[2]
  59.     
  60. def FinalAbrePuerta():
  61.     global CallBack
  62.     # retornar la camara a su posicion inicial  
  63.     Cam = Bladex.GetEntity("Camera")
  64.     Cam.SetPersonView("Player1")
  65.     Cam.Cut()
  66.     Bladex.ActivateInput()
  67.     if netgame.GetNetState() == 0:
  68.         import Scorer
  69.         Scorer.SetVisible(1)
  70.     if CallBack:
  71.         CallBack()
  72.         CallBack = None
  73.     
  74. def LoopAbrePuerta():
  75.     global auxi1
  76.     global auxi2
  77.     global Counter
  78.     global PTS
  79.     global LastTime
  80.  
  81.     cam=Bladex.GetEntity("Camera")
  82.     opos=cam.Position
  83.     tpos=cam.TPos
  84.  
  85.     if Counter == len(PTS):
  86.         Counter = 0
  87.         if LastTime != 0:
  88.             AuxFuncs.MoveCamFromTo(opos[0], opos[1], opos[2],auxi1[0], auxi1[1], auxi1[2], tpos[0],tpos[1], tpos[2],auxi2[0], auxi2[1], auxi2[2], LastTime, FinalAbrePuerta)
  89.         else:
  90.             FinalAbrePuerta()
  91.     else:
  92.         Point   = PTS[Counter][0]
  93.         Target  = PTS[Counter][1]    
  94.         Counter = Counter + 1 
  95.         AuxFuncs.MoveCamFromTo(opos[0], opos[1], opos[2], Point[0], Point[1], Point[2], tpos[0],tpos[1], tpos[2],Target[0], Target[1], Target[2], GetTime(PTS[Counter-1]), LoopAbrePuerta)
  96.  
  97. def AbreCam():
  98.     global auxi1
  99.     global auxi2
  100.     global Counter
  101.     global PTS
  102.     
  103.     Counter = 0
  104.     
  105.     Point   = PTS[Counter][0]
  106.     Target  = PTS[Counter][1]    
  107.     Counter = Counter + 1 
  108.     
  109.     # camarita
  110.     Bladex.DeactivateInput()
  111.     if netgame.GetNetState() == 0:
  112.         import Scorer
  113.         Scorer.SetVisible(0)
  114.     cam=Bladex.GetEntity("Camera")
  115.     auxi1=cam.Position
  116.     auxi2=cam.TPos
  117.     AuxFuncs.MoveCamFromTo(auxi1[0], auxi1[1], auxi1[2], Point[0], Point[1], Point[2], auxi2[0],auxi2[1], auxi2[2],Target[0], Target[1], Target[2], GetTime(PTS[Counter-1]), LoopAbrePuerta)
  118.  
  119.  
  120. def SaveData(filename):
  121.   import cPickle
  122.  
  123.   funcfile=open(filename,"wt")
  124.   p=cPickle.Pickler(funcfile)
  125.   d=(Counter,
  126.      auxi1,
  127.      auxi2,
  128.      CallBack,
  129.      LastTime,
  130.      PTS,
  131.     )
  132.   p.dump(d)
  133.   funcfile.close()
  134.  
  135.  
  136. def LoadData(filename):
  137.   import cPickle
  138.  
  139.   funcfile=open(filename,"rt")
  140.   p=cPickle.Unpickler(funcfile)
  141.   d=p.load()
  142.   funcfile.close()
  143.   print d
  144.  
  145.   global Counter
  146.   global auxi1
  147.   global auxi2
  148.   global CallBack
  149.   global LastTime
  150.   global PTS
  151.  
  152.   Counter    = d[0]
  153.   auxi1      = d[1]
  154.   auxi2      = d[2]
  155.   CallBack   = d[3]
  156.   LastTime   = d[4]
  157.   PTS        = d[5]
  158.  
  159. import GameState
  160. GameState.ModulesToBeSaved.append(__import__(__name__))
  161.