예제 #1
0
    def SetupScene(self, hangarScene):
        for obj in hangarScene.objects:
            if hasattr(obj, 'PlayAnimationEx'):
                obj.PlayAnimationEx('NormalLoop', 0, 0.0, 1.0)

        for obj in hangarScene.objects:
            if '_Traffic_' in obj.name:
                obj.RebuildBoosterSet()

        trafficStartEndArea = {}
        for obj in hangarScene.objects:
            if obj.__bluetype__ == 'trinity.EveStation2':
                for loc in obj.locators:
                    if 'Traffic_Start_' in loc.name or 'Traffic_End_' in loc.name:
                        trafficStartEndArea[loc.name] = geo2.Vec3Transform(
                            (0.0, 0.0, 0.0), loc.transform)

        if len(trafficStartEndArea) == 6:
            for obj in hangarScene.objects:
                if '_Traffic_' in obj.name:
                    obj.display = False
                    obj.translationCurve = trinity.TriVectorCurve()
                    obj.translationCurve.keys.append(trinity.TriVectorKey())
                    obj.translationCurve.keys.append(trinity.TriVectorKey())
                    obj.rotationCurve = trinity.TriRotationCurve()
                    if random.randint(0, 1) == 0:
                        obj.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll(
                            0.5 * math.pi, 0.0, 0.0)
                    else:
                        obj.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll(
                            -0.5 * math.pi, 0.0, 0.0)
                    uthreadObj = uthread.new(self.AnimateTraffic, obj,
                                             trafficStartEndArea)
                    uthreadObj.context = 'HangarTraffic::SetupScene'
                    self.threadList.append(uthreadObj)
예제 #2
0
    def GetCameraParent(self):
        cp = sm.GetService('camera').GetCameraParent(self.name)
        if cp.translationCurve is not None:
            return cp
        c = trinity.TriVectorCurve()
        c.extrapolation = trinity.TRIEXT_CONSTANT
        for t in (0.0, 1.0):
            k = trinity.TriVectorKey()
            k.time = t
            k.interpolation = trinity.TRIINT_LINEAR
            c.keys.append(k)

        c.Sort()
        cp.translationCurve = c
        return cp
예제 #3
0
    def PositionShipModel(self, model):
        trinity.WaitForResourceLoads()
        localBB = model.GetLocalBoundingBox()
        boundingCenter = model.boundingSphereCenter[1]
        radius = model.boundingSphereRadius - self.shipPositionMinSize
        val = radius / (self.shipPositionMaxSize - self.shipPositionMinSize)
        if val > 1.0:
            val = 1.0
        if val < 0:
            val = 0
        val = pow(val, 1.0 / self.shipPositionCurveRoot)
        shipDirection = (self.sceneTranslation[0], 0, self.sceneTranslation[2])
        shipDirection = geo2.Vec3Normalize(shipDirection)
        distancePosition = geo2.Lerp(
            (self.shipPositionMinDistance, self.shipPositionTargetHeightMin),
            (self.shipPositionMaxDistance, self.shipPositionTargetHeightMax),
            val)
        y = distancePosition[1] - boundingCenter
        y = y + self.sceneTranslation[1]
        if y < -localBB[0][1] + 180:
            y = -localBB[0][1] + 180
        boundingBoxZCenter = localBB[0][2] + localBB[1][2]
        boundingBoxZCenter *= 0.5
        shipPos = geo2.Vec3Scale(shipDirection, -distancePosition[0])
        shipPos = geo2.Vec3Add(shipPos, self.sceneTranslation)
        shipPosition = (shipPos[0], y, shipPos[2])
        model.translationCurve = trinity.TriVectorCurve()
        model.translationCurve.value = shipPosition
        model.rotationCurve = trinity.TriRotationCurve()
        model.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll(
            self.shipPositionRotation * math.pi / 180, 0, 0)
        model.modelTranslationCurve = blue.resMan.LoadObject(
            'res:/dx9/scene/hangar/ship_modelTranslationCurve.red')
        model.modelTranslationCurve.ZCurve.offset -= boundingBoxZCenter
        scaleMultiplier = 0.35 + 0.65 * (1 - val)
        capitalShips = [
            const.groupDreadnought, const.groupSupercarrier, const.groupTitan,
            const.groupFreighter, const.groupJumpFreighter, const.groupCarrier,
            const.groupCapitalIndustrialShip, const.groupIndustrialCommandShip
        ]
        dogmaLocation = self.clientDogmaIM.GetDogmaLocation()
        if getattr(dogmaLocation.GetDogmaItem(util.GetActiveShip()), 'groupID',
                   None) in capitalShips:
            scaleMultiplier = 0.35 + 0.25 * (1 - val)
            model.modelRotationCurve = blue.resMan.LoadObject(
                'res:/dx9/scene/hangar/ship_modelRotationCurve.red')
            model.modelRotationCurve.PitchCurve.speed *= scaleMultiplier
            model.modelRotationCurve.RollCurve.speed *= scaleMultiplier
            model.modelRotationCurve.YawCurve.speed *= scaleMultiplier
        else:
            if val > 0.6:
                val = 0.6
            scaleMultiplier = 0.35 + 0.65 * (1 - val / 0.6)
            model.modelRotationCurve = blue.resMan.LoadObject(
                'res:/dx9/scene/hangar/ship_modelRotationCurveSpinning.red')
            model.modelRotationCurve.PitchCurve.speed *= scaleMultiplier
            model.modelRotationCurve.RollCurve.speed *= scaleMultiplier
            model.modelRotationCurve.YawCurve.start = blue.os.GetSimTime()
            model.modelRotationCurve.YawCurve.ScaleTime(6 * val + 1)
        yValues = [(0, model.translationCurve.value[1] - 20.0),
                   (6.0, model.translationCurve.value[1] + 3.0),
                   (9.0, model.translationCurve.value[1])]
        for time, yValue in yValues:
            k = trinity.TriVectorKey()
            k.value = (model.translationCurve.value[0], yValue,
                       model.translationCurve.value[2])
            k.interpolation = trinity.TRIINT_HERMITE
            k.time = time
            model.translationCurve.keys.append(k)

        model.translationCurve.Sort()
        model.translationCurve.extrapolation = trinity.TRIEXT_CONSTANT
        model.translationCurve.start = blue.os.GetWallclockTimeNow()
        self.SetupFakeAudioTransformLocation(shipPosition)