NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

hangarCamera.py (6097B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\camera\hangarCamera.py
      2 import math
      3 from eve.client.script.ui.camera.cameraUtil import GetInitialLookAtDistance
      4 import evecamera
      5 from eve.client.script.ui.camera.baseSpaceCamera import BaseSpaceCamera
      6 import carbonui.const as uiconst
      7 import geo2
      8 from carbonui.uicore import uicore
      9 
     10 class HangarCamera(BaseSpaceCamera):
     11     cameraID = evecamera.CAM_HANGAR
     12     isBobbingCamera = False
     13     name = 'HangarCamera'
     14     kMaxPitch = math.pi / 2.0 + math.pi / 50.0
     15     minFov = 0.3
     16     maxFov = 1.0
     17     hangarMinZoom = 2050.0
     18     hangarMaxZoom = 10.0
     19 
     20     def __init__(self):
     21         BaseSpaceCamera.__init__(self)
     22         self.model = None
     23         self.HaAnimYaw = (14 * math.pi / 8, 9 * math.pi / 8)
     24         self.HaAnimPitch = (7 * math.pi / 16, self.kMaxPitch)
     25         self.HaAnimZoom = (1.2, 2.0)
     26         self.HaAnimFov = (0.7, self.default_fov)
     27 
     28     def SetShip(self, model, typeID):
     29         uicore.animations.StopAllAnimations(self)
     30         self.fov = 1.0
     31         self.model = model
     32         self.typeID = typeID
     33         self.UpdateMinMaxZoom()
     34 
     35     def PlaceShip(self, pos):
     36         self.atPosition = pos
     37 
     38     def AnimEnterHangar(self, model, startPos, endPos, duration = 5.0):
     39         self._AnimEnterHangarPitch(duration)
     40         self._AnimEnterHangarYaw(duration)
     41         self._AnimEnterHangarZoom(duration, model)
     42         self._AnimEnterHangarFOV(duration)
     43 
     44     def _AnimEnterHangarFOV(self, duration):
     45         self.fov = self.HaAnimFov[0]
     46         uicore.animations.MorphScalar(self, 'fov', self.HaAnimFov[0], self.HaAnimFov[1], duration=0.45 * duration, timeOffset=0.55 * duration)
     47 
     48     def _AnimEnterHangarZoom(self, duration, model):
     49         dist = GetInitialLookAtDistance(self.maxZoom, self.minZoom)
     50         zoom0 = self.GetZoomProportionByZoomDistance(self.HaAnimZoom[0] * dist)
     51         zoom1 = self.GetZoomProportionByZoomDistance(self.HaAnimZoom[1] * dist)
     52         self.zoom = zoom0
     53         self._AnimZoom(duration, zoom0, zoom1)
     54 
     55     def _AnimSwitchShipsZoom(self, duration, model):
     56         dist = GetInitialLookAtDistance(self.maxZoom, self.minZoom)
     57         zoom0 = self.GetZoomProportionByZoomDistance(1.0 * dist)
     58         zoom1 = self.GetZoomProportionByZoomDistance(1.2 * dist)
     59         self._AnimZoom(duration, zoom0, zoom1)
     60 
     61     def _AnimZoom(self, duration, zoom0, zoom1):
     62         zoom1 = min(zoom1, 1.0)
     63         self.zoom = zoom0
     64         cs = uicore.animations.MorphScalar(self, 'zoom', zoom0, zoom1, duration=duration, curveType=uiconst.ANIM_LINEAR)
     65         key = list(cs.curves[0].keys[0])
     66         key[3] = 0
     67         cs.curves[0].keys[0] = tuple(key)
     68 
     69     def UpdateMinMaxZoom(self):
     70         radius = self.model.boundingSphereRadius + geo2.Vec3Length(self.model.GetBoundingSphereCenter())
     71         maxZoom = max(self.hangarMaxZoom, 1.5 * radius)
     72         if maxZoom >= self.hangarMinZoom:
     73             maxZoom = 0.999 * self.hangarMinZoom
     74         minZoom = self.hangarMinZoom
     75         self.SetMinMaxZoom(minZoom, maxZoom)
     76         self.zoom = max(self.GetMinZoomProp(), min(self.zoom, 1.0))
     77 
     78     def _AnimEnterHangarYaw(self, duration):
     79         uicore.animations.MorphScalar(self, 'yaw', self.HaAnimYaw[0], self.HaAnimYaw[1], duration=duration, timeOffset=0)
     80 
     81     def _AnimEnterHangarPitch(self, duration):
     82         uicore.animations.MorphScalar(self, 'pitch', self.HaAnimPitch[0], self.HaAnimPitch[1], duration=duration)
     83 
     84     def AnimSwitchShips(self, model, startPos, endPos, duration = 5.0):
     85         self.atPosition = endPos
     86         uicore.animations.MorphScalar(self, 'yaw', 0.0, -math.pi / 10, duration=duration)
     87         uicore.animations.MorphScalar(self, 'pitch', math.pi / 2 + math.pi / 25, self.kMaxPitch, duration=duration)
     88         self._AnimSwitchShipsZoom(duration, model)
     89         uicore.animations.MorphScalar(self, 'fov', 0.7, self.default_fov, duration=duration)
     90 
     91     def Orbit(self, *args):
     92         BaseSpaceCamera.Orbit(self, *args)
     93         uicore.animations.StopAnimation(self, 'yaw')
     94         uicore.animations.StopAnimation(self, 'pitch')
     95         if uicore.animations.IsAnimating(self, 'zoom'):
     96             self.StopHangarEntryAnimation()
     97 
     98     def Zoom(self, dz):
     99         BaseSpaceCamera.Zoom(self, dz)
    100         if uicore.animations.IsAnimating(self, 'zoom'):
    101             self.StopHangarEntryAnimation()
    102 
    103     def StopHangarEntryAnimation(self):
    104         uicore.animations.StopAnimation(self, 'zoom')
    105         uicore.animations.StopAnimation(self, 'yaw')
    106         uicore.animations.StopAnimation(self, 'pitch')
    107         uicore.animations.StopAnimation(self, 'fov')
    108         uicore.animations.MorphScalar(self, 'fov', self.fov, self.HaAnimFov[1], duration=0.5)
    109 
    110     def StartIdleAnimation(self):
    111         uicore.animations.MorphScalar(self, 'yaw', self.GetYaw(), self.GetYaw() - math.pi * 2, duration=240.0, loops=uiconst.ANIM_REPEAT, curveType=uiconst.ANIM_LINEAR)
    112         uicore.animations.MorphScalar(self, 'pitch', self.GetPitch(), self.kMaxPitch - math.pi / 12, duration=16.0)
    113         uicore.animations.MorphScalar(self, 'zoom', self.zoom, 0.65, duration=16.0)
    114 
    115     def StopIdleAnimations(self):
    116         uicore.animations.StopAnimation(self, 'zoom')
    117         uicore.animations.StopAnimation(self, 'yaw')
    118         uicore.animations.StopAnimation(self, 'pitch')
    119 
    120     def OnDeactivated(self):
    121         BaseSpaceCamera.OnDeactivated(self)
    122         self.model = None
    123 
    124     def Update(self):
    125         BaseSpaceCamera.Update(self)
    126         if self.model and self.model.translationCurve:
    127             atPos = self.model.translationCurve.currentValue
    128             diff = geo2.Vec3Subtract(atPos, self._atPosition)
    129             self.atPosition = atPos
    130             self.eyePosition = geo2.Vec3Add(self.eyePosition, diff)
    131             self.EnforceMaxZoom()
    132 
    133     def SetMinMaxZoomDefaults(self, minZoom, maxZoom):
    134         self.hangarMinZoom = minZoom
    135         self.hangarMaxZoom = maxZoom
    136 
    137     def SetHangarAnimationParameters(self, yaw, pitch, zoom, fov):
    138         self.HaAnimYaw = yaw
    139         self.HaAnimPitch = pitch
    140         self.HaAnimZoom = zoom
    141         self.HaAnimFov = (fov, self.HaAnimFov[1])