Exemplo n.º 1
0
 def _CreateCameraShakeCurves(self):
     shakeScaleOut = trinity.TriScalarCurve()
     shakeScaleOut.AddKey(0.0, 0.125, 0.0, 0.0, 2)
     shakeScaleOut.AddKey(0.5, 4.0, 0.0, 0.0, 2)
     shakeScaleOut.AddKey(2.5, 1.0, 0.0, 0.0, 2)
     shakeScaleOut.extrapolation = 1
     shakeScaleIn = trinity.TriScalarCurve()
     shakeScaleIn.AddKey(0.0, 1.0, 0.0, 0.0, 2)
     shakeScaleIn.AddKey(0.4, 2.0, 0.0, 0.0, 2)
     shakeScaleIn.AddKey(0.6, 4.0, 0.0, 0.0, 2)
     shakeScaleIn.AddKey(0.8, 1.0, 0.0, 0.0, 2)
     shakeScaleIn.AddKey(1.1, 0.0, 0.0, 0.0, 2)
     shakeScaleIn.extrapolation = 1
     shakeDampCurve = trinity.TriPerlinCurve()
     shakeDampCurve.offset = 0.07
     shakeDampCurve.scale = 1
     shakeDampCurve.alpha = 0.75
     shakeDampCurve.speed = 4
     shakeDampCurve.N = 4
     self.shakeJumpInit = shaker.ShakeBehavior('JumpInit')
     self.shakeJumpInit.noiseScale = 0.125
     self.shakeJumpInit.dampCurve = shakeDampCurve
     self.shakeJumpOut = shaker.ShakeBehavior('JumpOut')
     self.shakeJumpOut.scaleCurve = shakeScaleOut
     self.shakeJumpOut.dampCurve = shakeDampCurve
     self.shakeJumpIn = shaker.ShakeBehavior('JumpIn')
     self.shakeJumpIn.scaleCurve = shakeScaleIn
     self.shakeJumpIn.dampCurve = shakeDampCurve
Exemplo n.º 2
0
def CreateBehaviorFromMagnitudeAndPosition(magnitude, shakeOrigin, camera):
    timeFactor = pow(magnitude / 400.0, 0.7)
    noiseScaleCurve = trinity.TriScalarCurve()
    noiseScaleCurve.AddKey(0.0, 1.2, 0.0, 0.0, 3)
    noiseScaleCurve.AddKey(0.1, 0.1, 0.0, 0.0, 3)
    noiseScaleCurve.AddKey(1.5 * timeFactor, 0.13, 0.0, 0.0, 3)
    noiseScaleCurve.AddKey(2.0 * timeFactor, 0.0, 0.0, 0.0, 3)
    noiseScaleCurve.extrapolation = 1
    noiseDampCurve = trinity.TriScalarCurve()
    noiseDampCurve.AddKey(0.0, 80.0, 0.0, 0.0, 3)
    noiseDampCurve.AddKey(0.1, 20.0, 0.0, 0.0, 3)
    noiseDampCurve.AddKey(1.5 * timeFactor, 0.0, 0.0, 0.0, 3)
    noiseDampCurve.AddKey(2.0 * timeFactor, 0.0, 0.0, 0.0, 3)
    noiseDampCurve.extrapolation = 1
    distance = geo2.Vec3Length(geo2.Vec3Subtract(shakeOrigin, camera.pos))
    if isnan(distance):
        return
    if distance < 700.0:
        distance = 700.0
    elif distance > 2000000000:
        distance = 2000000000
    actualMagnitude = 0.7 * magnitude / pow(distance, 0.7)
    noiseScaleCurve.ScaleValue(actualMagnitude)
    noiseDampCurve.ScaleValue(actualMagnitude)
    if camera.noiseScaleCurve is not None and camera.noiseScaleCurve.value > noiseScaleCurve.keys[
            1].value:
        return
    behavior = camshake.ShakeBehavior()
    behavior.scaleCurve = noiseScaleCurve
    behavior.dampCurve = noiseDampCurve
    return behavior
Exemplo n.º 3
0
 def ResetConfiguration(self):
     self.fieldOfView = evecamera.FOV_MAX
     self.friction = evecamera.DEFAULT_FRICTION
     self.maxSpeed = evecamera.DEFAULT_MAX_SPEED
     self.frontClip = evecamera.DEFAULT_FRONT_CLIP
     self.backClip = evecamera.DEFAULT_BACK_CLIP
     self.idleScale = evecamera.DEFAULT_IDLE_SCALE
     self.translationFromParent = -30.0
     self.idleSpeed = 0.5
     self.noiseScale = -2.010956
     self.noiseScaleCurve = trinity.TriScalarCurve()
     self.noiseScaleCurve.start = 126750659610511812L
     self.noiseScaleCurve.value = -2.010956
     self.noiseScaleCurve.extrapolation = 1
     self.noiseScaleCurve.AddKey(0.0, 0.0, 0.0, 0.0, 2)
     self.noiseScaleCurve.AddKey(0.5, -2.2945609, 0.0, 0.0, 2)
     self.noiseScaleCurve.AddKey(5.0, 0.0, 0.0, 0.0, 2)
     self.zoomCurve = trinity.TriScalarCurve()
     self.zoomCurve.start = 4644652442024148992L
     self.zoomCurve.value = 1.2
     self.zoomCurve.AddKey(0.0, evecamera.FOV_MAX, 0.0, 1.0, 3)
     self.zoomCurve.AddKey(0.224, evecamera.FOV_MAX, 0.0, -7.0, 3)
     self.zoomCurve.AddKey(0.45, evecamera.FOV_MAX, 0.0, -9.0, 3)
     self.zoomCurve.AddKey(0.6, evecamera.FOV_MAX, 0.0, 20.0, 3)
     self.zoomCurve.AddKey(0.0, evecamera.FOV_MAX, 0.0, 1.0, 3)
Exemplo n.º 4
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()
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def ShakeCamera(self, ball):
     ballpark = sm.GetService('michelle').GetBallpark()
     if ballpark is None:
         return
     speedVector = trinity.TriVector(ball.vx, ball.vy, ball.vz)
     speed = speedVector.Length()
     maxSpeed = ballpark.warpSpeed * const.AU - ball.maxVelocity
     speed = (speed - ball.maxVelocity) / maxSpeed
     speed = max(0.0, speed)
     rumbleFactor = 0.5 - 0.5 * cos(6.28 * pow(speed, 0.1))
     rumbleFactor = (rumbleFactor - 0.2) / 0.8
     rumbleFactor = max(rumbleFactor, 0.0)
     rumbleFactor = pow(rumbleFactor, 0.8)
     shakeFactor = 0.7 * rumbleFactor
     cam = self.GetCamera()
     noisescaleCurve = trinity.TriScalarCurve()
     noisescaleCurve.extrapolation = trinity.TRIEXT_CONSTANT
     noisescaleCurve.AddKey(0.0, cam.noiseScale, 0.0, 0.0,
                            trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(0.5, shakeFactor * 2.0, 0.0, 0.0,
                            trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(5.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.Sort()
     behavior = shaker.ShakeBehavior('Warp')
     behavior.scaleCurve = noisescaleCurve
     cam.shakeController.DoCameraShake(behavior)
Exemplo n.º 8
0
 def ShakeCamera(self, ball):
     shakeEnabled = settings.user.ui.Get('cameraShakeEnabled', 1)
     camera = sm.GetService('sceneManager').GetRegisteredCamera('default')
     if camera is None:
         return
     if not shakeEnabled:
         camera.noise = 0
         return
     ballpark = sm.GetService('michelle').GetBallpark()
     if ballpark is None:
         return
     speedVector = trinity.TriVector(ball.vx, ball.vy, ball.vz)
     speed = speedVector.Length()
     maxSpeed = ballpark.warpSpeed * const.AU - ball.maxVelocity
     speed = (speed - ball.maxVelocity) / maxSpeed
     speed = max(0.0, speed)
     rumbleFactor = 0.5 - 0.5 * cos(6.28 * pow(speed, 0.1))
     rumbleFactor = (rumbleFactor - 0.2) / 0.8
     rumbleFactor = max(rumbleFactor, 0.0)
     rumbleFactor = pow(rumbleFactor, 0.8)
     shakeFactor = 0.7 * rumbleFactor
     if camera.noiseScaleCurve is None:
         noiseScale = 0.0
     else:
         noiseScale = camera.noiseScale
     noisescaleCurve = trinity.TriScalarCurve()
     noisescaleCurve.extrapolation = trinity.TRIEXT_CONSTANT
     noisescaleCurve.AddKey(0.0, noiseScale, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(0.5, shakeFactor * 2.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(5.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.Sort()
     camera.noiseScaleCurve = noisescaleCurve
     now = blue.os.GetSimTime()
     camera.noiseScaleCurve.start = now
     camera.noise = 1
Exemplo n.º 9
0
 def ShakeCamera(self, magnitude, position):
     if not settings.user.ui.Get('cameraShakeEnabled', 1):
         return
     camera = sm.StartService('sceneManager').GetRegisteredCamera('default')
     timeFactor = pow(magnitude / 400.0, 0.7)
     noiseScaleCurve = trinity.TriScalarCurve()
     noiseScaleCurve.AddKey(0.0, 1.2, 0.0, 0.0, 3)
     noiseScaleCurve.AddKey(0.1, 0.1, 0.0, 0.0, 3)
     noiseScaleCurve.AddKey(1.5 * timeFactor, 0.13, 0.0, 0.0, 3)
     noiseScaleCurve.AddKey(2.0 * timeFactor, 0.0, 0.0, 0.0, 3)
     noiseScaleCurve.extrapolation = 1
     noiseDampCurve = trinity.TriScalarCurve()
     noiseDampCurve.AddKey(0.0, 80.0, 0.0, 0.0, 3)
     noiseDampCurve.AddKey(0.1, 20.0, 0.0, 0.0, 3)
     noiseDampCurve.AddKey(1.5 * timeFactor, 0.0, 0.0, 0.0, 3)
     noiseDampCurve.AddKey(2.0 * timeFactor, 0.0, 0.0, 0.0, 3)
     noiseDampCurve.extrapolation = 1
     newPos = geo2.Vec3Subtract(position, camera.pos)
     distance = geo2.Vec3Length(newPos)
     if isnan(distance):
         raise RuntimeError(
             'Camera::ShakeCamera invalid(nan) distance from camera to shake position.'
         )
     elif distance < 700.0:
         distance = 700.0
     elif distance > 2000000000:
         distance = 2000000000
     actualMagnitude = 0.7 * magnitude / pow(distance, 0.7)
     noiseScaleCurve.ScaleValue(actualMagnitude)
     noiseDampCurve.ScaleValue(actualMagnitude)
     if camera.noiseScaleCurve != None and camera.noiseScaleCurve.value > noiseScaleCurve.keys[
             1].value:
         return
     now = blue.os.GetSimTime()
     noiseScaleCurve.start = now
     noiseDampCurve.start = now
     camera.noise = 1
     camera.noiseScaleCurve = noiseScaleCurve
     camera.noiseDampCurve = noiseDampCurve
Exemplo n.º 10
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
Exemplo n.º 11
0
 def __init__(self):
     spaceObject.SpaceObject.__init__(self)
     self.activeTargetID = None
     self.gainCurve = trinity.TriScalarCurve()
     self.gainCurve.value = 0.0
     self.audioEntities = []
     self.shipSpeedParameter = None
     self.fitted = False
     self.fittingThread = None
     self.turrets = []
     self.modules = {}
     self.cloakedCopy = None
     self.cloakedShaderStorage = None
     self.burning = False
     self.isTech3 = False
     self.loadingModel = False
Exemplo n.º 12
0
 def SetupScene(self):
     curveSet = trinity.TriCurveSet()
     curveSet.name = 'HighlighCurveSet'
     curveSet.playOnLoad = False
     curveSet.Stop()
     curveSet.scaledTime = 0.0
     self.rootTransform.curveSets.append(curveSet)
     curve = trinity.TriScalarCurve()
     curve.value = 0.0
     curve.extrapolation = trinity.TRIEXT_CYCLE
     curveSet.curves.append(curve)
     curve.AddKey(0.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
     curve.AddKey(1.0, 1.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
     curve.AddKey(2.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
     curve.Sort()
     self.highlightCurveSet = curveSet
     self.highlightCurve = curve
     curveSet.Play()
Exemplo n.º 13
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
Exemplo n.º 14
0
    def PrepareModelForConstruction(self, builtAlready, onlineAlready):
        self.LogInfo('  PrepareModelForConstruction - Built:', builtAlready,
                     ' Online:', onlineAlready)
        if not self.model:
            return (None, None)
        if not hasattr(self.model, 'curveSets'):
            return (None, None)
        model = self.model
        alphaParams = []
        if model.meshLod:
            self.PrepareAreasForConstruction(model.meshLod.opaqueAreas,
                                             alphaParams, 'high_opaque')
            self.PrepareAreasForConstruction(model.meshLod.decalAreas,
                                             alphaParams, 'high_decal')
            self.PrepareAreasForConstruction(model.meshLod.transparentAreas,
                                             alphaParams, 'high_transparent')
        else:
            self.PrepareAreasForConstruction(model.mesh.opaqueAreas,
                                             alphaParams, 'high_opaque')
            self.PrepareAreasForConstruction(model.mesh.decalAreas,
                                             alphaParams, 'high_decal')
            self.PrepareAreasForConstruction(model.mesh.transparentAreas,
                                             alphaParams, 'high_transparent')
        buildCurve = trinity.TriCurveSet()
        buildCurve.name = 'Build'
        buildCurve.playOnLoad = False
        buildCurve.Stop()
        buildCurve.scaledTime = 0.0
        model.curveSets.append(buildCurve)
        curve = trinity.TriScalarCurve()
        curve.value = 1.0
        curve.extrapolation = trinity.TRIEXT_CONSTANT
        buildCurve.curves.append(curve)
        curve.AddKey(0.0, 1.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
        curve.AddKey(10.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
        curve.Sort()
        for alphaParam in alphaParams:
            binding = trinity.TriValueBinding()
            binding.sourceAttribute = 'value'
            binding.destinationAttribute = 'value.x'
            binding.scale = 1.0
            binding.sourceObject = curve
            binding.destinationObject = alphaParam
            buildCurve.bindings.append(binding)

        glows = nodemanager.FindNodes(model, 'GlowColor',
                                      'trinity.Tr2Vector4Parameter')
        finalColor = (1.0, 1.0, 1.0)
        if glows:
            r, g, b, a = glows[0].value
            finalColor = (r, g, b)
        onlineCurve = trinity.TriCurveSet()
        onlineCurve.name = 'Online'
        onlineCurve.playOnLoad = False
        onlineCurve.Stop()
        onlineCurve.scaledTime = 0.0
        model.curveSets.append(onlineCurve)
        curve = trinity.TriVectorCurve()
        onlineCurve.curves.append(curve)
        curve.value = finalColor
        curve.extrapolation = trinity.TRIEXT_CONSTANT
        curve.AddKey(0.0, ONLINE_GLOW_OFF, (0.0, 0.0, 0.0), (0.0, 0.0, 0.0),
                     trinity.TRIINT_HERMITE)
        curve.AddKey(1.9, ONLINE_GLOW_MID, (0.0, 0.0, 0.0), (0.0, 0.0, 0.0),
                     trinity.TRIINT_LINEAR)
        curve.AddKey(2.0, finalColor, (0.0, 0.0, 0.0), (0.0, 0.0, 0.0),
                     trinity.TRIINT_HERMITE)
        curve.Sort()
        for each in glows:
            binding = trinity.TriValueBinding()
            binding.sourceAttribute = 'value'
            binding.destinationAttribute = 'value'
            binding.scale = 1.0
            binding.sourceObject = curve
            binding.destinationObject = each
            onlineCurve.bindings.append(binding)

        if builtAlready:
            buildCurve.Stop()
            buildCurve.scale = 0.0
            buildCurve.scaledTime = buildCurve.GetMaxCurveDuration()
            buildCurve.PlayFrom(buildCurve.scaledTime)
            self.LogInfo(
                '  PrepareModelForConstruction - Already Built, set curve to:',
                buildCurve.scaledTime)
        if onlineAlready:
            onlineCurve.Stop()
            onlineCurve.scale = 0.0
            onlineCurve.scaledTime = onlineCurve.GetMaxCurveDuration()
            onlineCurve.PlayFrom(onlineCurve.scaledTime)
            self.LogInfo(
                '  PrepareModelForConstruction - Already Online, Set curve Time to:',
                onlineCurve.scaledTime)
        trinity.WaitForResourceLoads()
        if model.meshLod:
            for each in model.meshLod.opaqueAreas:
                each.effect.PopulateParameters()

        else:
            for each in model.mesh.opaqueAreas:
                each.effect.PopulateParameters()

        return (buildCurve, onlineCurve)