Esempio n. 1
0
 def LoadPlanet(self,
                itemID=None,
                forPhotoService=False,
                rotate=True,
                hiTextures=False):
     if itemID is None:
         itemID = self.id
     self.itemID = itemID
     if type(cfg.invtypes.Get(self.typeID).graphicID) != type(0):
         raise RuntimeError('NeedGraphicIDNotMoniker', itemID)
     self.modelPath = cfg.invtypes.Get(self.typeID).GraphicFile()
     if hiTextures:
         self.largeTextures = True
         self.modelPath = self.modelPath.replace('.red', '_HI.red')
     self.model = trinity.EvePlanet()
     if self.model is None:
         self.LogError('Could not create model for planet with id', itemID)
         return
     self.model.translationCurve = self
     self.model.highDetail = trinity.EveTransform()
     self.model.scaling = self.radius
     self.model.radius = self.radius
     self.model.name = '%d' % itemID
     if self.typeID != const.typePlanetEarthlike:
         if rotate:
             rotationDirection = 1
             if self.id % 2:
                 rotationDirection = -1
             random.seed(self.id)
             rotationTime = random.random() * 2000 + 3000
             yCurve = trinity.TriScalarCurve()
             yCurve.extrapolation = trinity.TRIEXT_CYCLE
             yCurve.AddKey(0.0, 1.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
             yCurve.AddKey(rotationTime, rotationDirection * 360.0, 0.0,
                           0.0, trinity.TRIINT_LINEAR)
             yCurve.Sort()
             tilt = random.random() * 60.0 - 30.0
             pCurve = trinity.TriScalarCurve()
             pCurve.extrapolation = trinity.TRIEXT_CYCLE
             pCurve.AddKey(0.0, 1.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
             pCurve.AddKey(6000.0, tilt, 0.0, 0.0, trinity.TRIINT_HERMITE)
             pCurve.AddKey(12000.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
             pCurve.Sort()
             self.model.rotationCurve = trinity.TriYPRSequencer()
             self.model.rotationCurve.YawCurve = yCurve
             self.model.rotationCurve.PitchCurve = pCurve
     if self.typeID == const.typeMoon:
         self.model.zOnlyModel = trinity.Load(
             'res:/dx9/model/worldobject/planet/planetzonly.red')
     if self.attributes is None:
         self.attributes = cfg.fsdPlanetAttributes[itemID]
     if not forPhotoService:
         self.model.resourceCallback = self.ResourceCallback
         scene = sm.GetService('sceneManager').GetRegisteredScene('default')
         if scene is not None:
             scene.planets.append(self.model)
             self.SetupAmbientAudio()
Esempio n. 2
0
 def _CreateRotationCurve(self, model):
     model.rotationCurve = trinity.TriYPRSequencer()
     model.rotationCurve.YawCurve = yawCurve = trinity.TriScalarCurve()
     yawCurve.start = blue.os.GetWallclockTime()
     yawCurve.extrapolation = trinity.TRIEXT_CONSTANT
     yawCurve.AddKey(0.0, -70.0, 0, 0, trinity.TRIINT_HERMITE)
     yawCurve.AddKey(self.duration, 70.0, 0, 0, trinity.TRIINT_HERMITE)
     model.rotationCurve.PitchCurve = pitchCurve = trinity.TriScalarCurve()
     pitchCurve.start = blue.os.GetWallclockTime()
     pitchCurve.extrapolation = trinity.TRIEXT_CONSTANT
     pitchCurve.AddKey(0.0, -10.0, 0, 0, trinity.TRIINT_HERMITE)
     pitchCurve.AddKey(self.duration, 10.0, 0, 0, trinity.TRIINT_HERMITE)
Esempio n. 3
0
 def AnimRotateFrom(self, yaw, pitch, zoom, duration):
     sequencer = trinity.TriYPRSequencer()
     self.transform.rotationCurve = sequencer
     start = blue.os.GetSimTime()
     sequencer.YawCurve = yawCurve = trinity.TriScalarCurve()
     yawCurve.start = start
     yawCurve.extrapolation = trinity.TRIEXT_CONSTANT
     yawCurve.AddKey(0.0, yaw, 0, 0, trinity.TRIINT_HERMITE)
     yawCurve.AddKey(duration, 0.0, 0, 0, trinity.TRIINT_HERMITE)
     sequencer.PitchCurve = pitchCurve = trinity.TriScalarCurve()
     pitchCurve.start = start
     pitchCurve.extrapolation = trinity.TRIEXT_CONSTANT
     pitchCurve.AddKey(0.0, pitch, 0, 0, trinity.TRIINT_HERMITE)
     pitchCurve.AddKey(duration, 0.0, 0, 0, trinity.TRIINT_HERMITE)
Esempio n. 4
0
 def _ApplyPlanetRotation(self):
     rotationDirection = 1
     if self.id % 2:
         rotationDirection = -1
     r = random.Random()
     r.seed(self.id)
     rotationTime = r.random() * 2000 + 3000
     yCurve = trinity.TriScalarCurve()
     yCurve.extrapolation = trinity.TRIEXT_CYCLE
     yCurve.AddKey(0.0, 1.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     yCurve.AddKey(rotationTime, rotationDirection * 360.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     yCurve.Sort()
     tilt = r.random() * 60.0 - 30.0
     pCurve = trinity.TriScalarCurve()
     pCurve.extrapolation = trinity.TRIEXT_CYCLE
     pCurve.AddKey(0.0, 1.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
     pCurve.AddKey(6000.0, tilt, 0.0, 0.0, trinity.TRIINT_HERMITE)
     pCurve.AddKey(12000.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
     pCurve.Sort()
     self.model.rotationCurve = trinity.TriYPRSequencer()
     self.model.rotationCurve.YawCurve = yCurve
     self.model.rotationCurve.PitchCurve = pCurve
     self.rotationApplied = True
Esempio n. 5
0
    def LoadOrbitalObjects(self, scene):
        orbitalObjects = sm.GetService('planetInfo').GetOrbitalsForPlanet(
            self.planetID, const.groupPlanetaryCustomsOffices)
        park = sm.GetService('michelle').GetBallpark()
        addedObjects = []
        for orbitalObjectID in orbitalObjects:
            invItem = park.GetInvItem(orbitalObjectID)
            fileName = None
            if evetypes.GetGraphicID(invItem.typeID) is not None:
                if type(evetypes.GetGraphicID(invItem.typeID)) != type(0):
                    raise RuntimeError('NeedGraphicIDNotMoniker',
                                       invItem.itemID)
                if inventorycommon.typeHelpers.GetGraphic(invItem.typeID):
                    fileName = inventorycommon.typeHelpers.GetGraphicFile(
                        invItem.typeID)
                    if not (fileName.lower().endswith('.red')
                            or fileName.lower().endswith('.blue')):
                        filenameAndTurretType = fileName.split(' ')
                        fileName = filenameAndTurretType[0]
            if fileName is None:
                self.LogError(
                    'Error: Object type %s has invalid graphicFile, using graphicID: %s'
                    % (invItem.typeID, evetypes.GetGraphicID(invItem.typeID)))
                continue
            tryFileName = fileName.replace(':/Model', ':/dx9/Model').replace(
                '.blue', '.red')
            tryFileName = tryFileName.replace('.red', '_UI.red')
            model = None
            if tryFileName is not None:
                try:
                    model = blue.resMan.LoadObject(tryFileName)
                except:
                    model = None

                if model is None:
                    self.LogError('Was looking for:', tryFileName,
                                  'but it does not exist!')
            if model is None:
                try:
                    model = blue.resMan.LoadObject(fileName)
                except:
                    model = None

            if not model:
                log.LogError(
                    'Could not load model for orbital object. FileName:',
                    fileName, ' id:', invItem.itemID, ' typeID:',
                    getattr(invItem, 'typeID', '?unknown?'))
                if invItem is not None and hasattr(invItem, 'typeID'):
                    log.LogError('Type is:', evetypes.GetName(invItem.typeID))
                continue
            model.name = '%s' % invItem.itemID
            model.display = 0
            model.scaling = (0.002, 0.002, 0.002)
            addedObjects.append(model)
            orbitRoot = trinity.EveTransform()
            orbitRoot.children.append(model)
            inclinationRoot = trinity.EveTransform()
            inclinationRoot.children.append(orbitRoot)
            orbitalInclination = orbitalObjectID / math.pi % (
                math.pi / 4.0) - math.pi / 8.0
            if orbitalInclination <= 0.0:
                orbitalInclination -= math.pi / 8.0
            else:
                orbitalInclination += math.pi / 8.0
            inclinationRoot.rotation = geo2.QuaternionRotationSetYawPitchRoll(
                0.0, orbitalInclination, 0.0)
            rotationCurveSet = trinity.TriCurveSet()
            rotationCurveSet.playOnLoad = False
            rotationCurveSet.Stop()
            rotationCurveSet.scaledTime = 0.0
            rotationCurveSet.scale = 0.25
            orbitRoot.curveSets.append(rotationCurveSet)
            ypr = trinity.TriYPRSequencer()
            ypr.YawCurve = trinity.TriScalarCurve()
            ypr.YawCurve.extrapolation = trinity.TRIEXT_CYCLE
            ypr.YawCurve.AddKey(0.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
            ypr.YawCurve.AddKey(200.0, 360.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
            ypr.YawCurve.Sort()
            rotationCurveSet.curves.append(ypr)
            binding = trinity.TriValueBinding()
            binding.sourceObject = ypr
            binding.sourceAttribute = 'value'
            binding.destinationObject = orbitRoot
            binding.destinationAttribute = 'rotation'
            rotationCurveSet.bindings.append(binding)
            rotationCurveSet.Play()
            model.translation = (0.0, 0.0, 1500.0)
            model.rotation = geo2.QuaternionRotationSetYawPitchRoll(
                math.pi, 0.0, 0.0)
            scene.objects.append(inclinationRoot)
            ls = trinity.EveCurveLineSet()
            ls.scaling = (1.0, 1.0, 1.0)
            tex2D1 = trinity.TriTextureParameter()
            tex2D1.name = 'TexMap'
            tex2D1.resourcePath = 'res:/UI/Texture/Planet/link.dds'
            ls.lineEffect.resources.append(tex2D1)
            tex2D2 = trinity.TriTextureParameter()
            tex2D2.name = 'OverlayTexMap'
            tex2D2.resourcePath = 'res:/UI/Texture/Planet/link.dds'
            ls.lineEffect.resources.append(tex2D2)
            lineColor = (1.0, 1.0, 1.0, 0.05)
            p1 = SurfacePoint(0.0, 0.0, -1500.0, 1000.0)
            p2 = SurfacePoint(5.0, 0.0, 1498.0, 1000.0)
            l1 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor,
                                      p2.GetAsXYZTuple(), lineColor,
                                      (0.0, 0.0, 0.0), 3.0)
            p1 = SurfacePoint(0.0, 0.0, -1500.0, 1000.0)
            p2 = SurfacePoint(-5.0, 0.0, 1498.0, 1000.0)
            l2 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor,
                                      p2.GetAsXYZTuple(), lineColor,
                                      (0.0, 0.0, 0.0), 3.0)
            animationColor = (0.3, 0.3, 0.3, 0.5)
            ls.ChangeLineAnimation(l1, animationColor, 0.25, 1.0)
            ls.ChangeLineAnimation(l2, animationColor, -0.25, 1.0)
            ls.ChangeLineSegmentation(l1, 100)
            ls.ChangeLineSegmentation(l2, 100)
            ls.SubmitChanges()
            orbitRoot.children.append(ls)

        trinity.WaitForResourceLoads()
        for model in addedObjects:
            model.display = 1