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

route.py (3892B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\maps\route.py
      2 import blue
      3 import trinity
      4 import geo2
      5 from eve.client.script.ui.shared.maps.mapcommon import STARMAP_SCALE
      6 LINESET_EFFECT = 'res:/Graphics/Effect/Managed/Space/SpecialFX/LinesAdditive.fx'
      7 TIME_BASE = 0.25
      8 BALL_SCALE = 30.0
      9 
     10 class MapRoute(object):
     11     __persistvars__ = ['sr']
     12 
     13     def __init__(self):
     14         self.destinations = None
     15         self.model = None
     16         self.scale = STARMAP_SCALE
     17         self.ballScale = BALL_SCALE
     18         self.timeBase = TIME_BASE
     19         self.lineColor = None
     20         self.resPath = 'res:/dx9/model/Sprite/MapRouteSprite.red'
     21 
     22     def DrawRoute(self, destinations, usePoints = False, drawLines = False, blinking = True, flattened = False, rotationQuaternion = None):
     23         if not len(destinations):
     24             self.destinations = []
     25             if self.model:
     26                 self.model.diplay = False
     27             return
     28         if self.model:
     29             self.model.display = True
     30         else:
     31             self.model = trinity.Load(self.resPath)
     32             self.model.name = '__mapRoute'
     33             self.model.scaling = (self.ballScale, self.ballScale, self.ballScale)
     34             if not blinking:
     35                 self.model.curveSets.removeAt(0)
     36             if drawLines:
     37                 self.lineSet = trinity.EveLineSet()
     38                 self.lineSet.effect = trinity.Tr2Effect()
     39                 self.lineSet.effect.effectFilePath = LINESET_EFFECT
     40         transCurve = trinity.Tr2CurveVector3()
     41         transCurve.SetExtrapolation(trinity.Tr2CurveExtrapolation.CYCLE)
     42         if type(rotationQuaternion) != trinity.TriQuaternion and rotationQuaternion is not None:
     43             rotationQuaternion = trinity.TriQuaternion(*rotationQuaternion)
     44         emptyVector = (0.0, 0.0, 0.0)
     45         if usePoints:
     46             for index, point in enumerate(destinations):
     47                 pos = trinity.TriVector(*point)
     48                 if flattened:
     49                     pos.y = 0.0
     50                 if rotationQuaternion is not None:
     51                     pos.TransformQuaternion(rotationQuaternion)
     52                 pos.Scale(self.scale)
     53                 pythonPos = (pos.x, pos.y, pos.z)
     54                 transCurve.AddKey(index * self.timeBase, pythonPos, trinity.Tr2CurveInterpolation.LINEAR)
     55 
     56             if drawLines:
     57                 numPoints = len(destinations)
     58                 for index in xrange(numPoints):
     59                     index2 = (index + 1) % numPoints
     60                     p1 = geo2.Vector(*destinations[index]) * self.scale
     61                     p2 = geo2.Vector(*destinations[index2]) * self.scale
     62                     self.lineSet.AddLine(p1, self.lineColor, p2, self.lineColor)
     63 
     64                 self.lineSet.SubmitChanges()
     65         else:
     66             map = sm.StartService('map')
     67             for index, destinationID in enumerate(destinations):
     68                 destination = cfg.evelocations.Get(destinationID)
     69                 pos = trinity.TriVector(destination.x, destination.y, destination.z)
     70                 if flattened:
     71                     pos.y = 0.0
     72                 if rotationQuaternion is not None:
     73                     pos.TransformQuaternion(rotationQuaternion)
     74                 pos.Scale(self.scale)
     75                 pythonPos = (pos.x, pos.y, pos.z)
     76                 transCurve.AddKey(index * 2 * self.timeBase, pythonPos, trinity.Tr2CurveInterpolation.LINEAR)
     77                 transCurve.AddKey((index * 2 + 1.0) * self.timeBase, pythonPos, trinity.Tr2CurveInterpolation.LINEAR)
     78 
     79         now = blue.os.GetSimTime()
     80         self.model.translationCurve = trinity.Tr2TranslationAdapter()
     81         self.model.translationCurve.curve = transCurve
     82         if blinking:
     83             self.model.curveSets[0].scale = 2.0
     84             self.model.curveSets[0].PlayFrom(float(now / const.SEC))
     85         self.destinations = destinations