Ejemplo n.º 1
0
def SetupLotsOfIcons(parent, curveSet, n):
    for i in xrange(n):
        sprite = CreateRandomIcon()
        curve = trinity.TriPerlinCurve()
        curve.scale = 100.0
        curve.offset = 0.0
        curve.speed = random.random()
        binding = trinity.TriValueBinding()
        binding.sourceObject = curve
        binding.sourceAttribute = 'value'
        binding.destinationObject = sprite
        binding.destinationAttribute = 'displayX'
        curveSet.curves.append(curve)
        curveSet.bindings.append(binding)
        curve = trinity.TriPerlinCurve()
        curve.scale = 100.0
        curve.offset = 0.0
        curve.speed = random.random()
        binding = trinity.TriValueBinding()
        binding.sourceObject = curve
        binding.sourceAttribute = 'value'
        binding.destinationObject = sprite
        binding.destinationAttribute = 'displayY'
        curveSet.curves.append(curve)
        curveSet.bindings.append(binding)
        sprite.color = (random.random(), random.random(), random.random(), 1.0)
        parent.children.append(sprite)
Ejemplo n.º 2
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
Ejemplo n.º 3
0
 def _SetupStaticLight(self, offset, curveSet):
     light = trinity.Tr2PointLight()
     light.color = STATIC_WARP_LIGHT_COLOR
     light.position = (0, 0, offset)
     curve = trinity.TriPerlinCurve()
     curve.offset = 0.2
     curve.scale = 0.2
     curveSet.curves.append(curve)
     trinity.CreateBinding(curveSet, curve, 'value', light, 'radius')
     return light
Ejemplo n.º 4
0
 def CreatePerlinCurve(self,
                       destObject,
                       sourceAttr,
                       destAttr,
                       curveSet,
                       scale=1000.0,
                       offset=0.0,
                       N=2,
                       speed=1.0,
                       alpha=1000.0,
                       beta=5000.0):
     curve = trinity.TriPerlinCurve()
     curve.scale = scale
     curve.offset = offset
     curve.N = N
     curve.speed = speed
     curve.alpha = alpha
     curve.beta = beta
     curveSet.curves.append(curve)
     binding = self.AddBinding(curve, sourceAttr, destObject, destAttr,
                               curveSet)
     return (curve, binding)
Ejemplo n.º 5
0
    def _PlayCameraAnimation(self,
                             resPath,
                             alignToParent=False,
                             alignTargets=None,
                             loop=False,
                             parent=None,
                             reload=False):
        if self.playingClip:
            self.interrupt = True
            blue.synchro.Yield()
        self.playingClip = True

        def RemoveCurveSetByName(scene, curveSetName):
            removeList = []
            for cset in scene.curveSets:
                if cset.name == curveSetName:
                    removeList.append(cset)

            for cset in removeList:
                scene.curveSets.remove(cset)

        curveSetName = 'AnimatedCamera'
        cset = trinity.TriCurveSet()
        cset.name = curveSetName
        cameraTransformTrack = trinity.Tr2GrannyTransformTrack()
        cameraTransformTrack.grannyResPath = str(resPath)
        cameraTransformTrack.name = 'camera1'
        cameraTransformTrack.group = 'camera1'
        cameraTransformTrack.cycle = True
        cset.curves.append(cameraTransformTrack)
        if alignTargets:
            t1 = alignTargets[0].model.worldPosition
            t2 = alignTargets[1].model.worldPosition
            distVector = geo2.Vec3Subtract(t1, t2)
            dist = geo2.Vec3Length(distVector)
            shakeSeq = trinity.TriXYZScalarSequencer()
            shakeSeq.XCurve = trinity.TriPerlinCurve()
            shakeSeq.YCurve = trinity.TriPerlinCurve()
            shakeSeq.ZCurve = trinity.TriPerlinCurve()
            for pCurve in [shakeSeq.XCurve, shakeSeq.YCurve, shakeSeq.ZCurve]:
                shake = dist / 50.0
                pCurve.scale = shake
                pCurve.offset = -shake / 2.0
                pCurve.speed = 0.8
                pCurve.alpha = 1.3

            cset.curves.append(shakeSeq)
        if reload:
            cameraTransformTrack.grannyRes.Reload()
        while cameraTransformTrack.grannyRes.isLoading:
            blue.synchro.Yield()

        numVecTracks = cameraTransformTrack.grannyRes.GetVectorTrackCount(0)
        if numVecTracks:
            self.vectorTracks = {}
        for trackNr in range(numVecTracks):
            vecTrack = trinity.Tr2GrannyVectorTrack()
            vecTrack.grannyResPath = str(resPath)
            vecTrack.group = 'camera1'
            vecTrack.name = cameraTransformTrack.grannyRes.GetVectorTrackName(
                0, trackNr)
            vecTrack.cycle = True
            cset.curves.append(vecTrack)
            self.vectorTracks[vecTrack.name] = vecTrack

        scene = sm.GetService('sceneManager').GetRegisteredScene('default')
        RemoveCurveSetByName(scene, curveSetName)
        scene.curveSets.append(cset)
        cset.Play()
        uthread.new(self._UpdateCameraAnimation,
                    alignToParent,
                    alignTargets,
                    loop,
                    clipName=resPath,
                    parent=parent)
Ejemplo n.º 6
0
def _AddTarget():
    import trinity
    import uiconst
    import random
    import uicls
    par = uicls.Container(parent=uicore.desktop,
                          left=256,
                          top=random.randint(1, 500),
                          align=uiconst.RELATIVE,
                          width=300,
                          height=128)
    curveSet = par.CreateCurveSet()
    curveSet.scale = 1.0
    curve = trinity.TriPerlinCurve()
    curve.scale = 1000.0
    curve.offset = -0.0
    curve.N = 2
    curve.speed = 1.0
    curve.alpha = 1000.0
    curve.beta = 5000.0
    curveSet.curves.append(curve)
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = par
    binding.destinationAttribute = 'displayY'
    binding.scale = 1
    curveSet.bindings.append(binding)
    curve = trinity.TriPerlinCurve()
    curve.scale = 1200.0
    curve.offset = -300.0
    curve.N = 2
    curve.speed = 1.0
    curve.alpha = 1200.0
    curve.beta = 8000.0
    curveSet.curves.append(curve)
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = par
    binding.destinationAttribute = 'displayX'
    binding.scale = 1
    curveSet.bindings.append(binding)
    inTime = 0.5
    mainParent = uicls.Container(parent=par,
                                 name='mainParent',
                                 align=uiconst.RELATIVE,
                                 width=200,
                                 height=64,
                                 top=32,
                                 left=96)
    maintext = uicls.Sprite(parent=mainParent,
                            texturePath='res:/UICore/texture/text.dds',
                            left=96.0,
                            width=200,
                            height=64,
                            effect=trinity.S2D_RFX_BLUR)
    caption = uicls.Sprite(parent=mainParent,
                           texturePath='res:/UICore/texture/caption.dds',
                           left=50,
                           top=56,
                           width=160,
                           height=32,
                           effect=trinity.S2D_RFX_BLUR)
    bracket = uicls.Sprite(parent=mainParent,
                           texturePath='res:/UICore/texture/brackettext.dds',
                           left=200,
                           top=56,
                           width=100,
                           height=32,
                           effect=trinity.S2D_RFX_BLUR)
    scrolltext = uicls.Label(parent=mainParent,
                             text='0123456789',
                             align=uiconst.TOPLEFT,
                             left=237,
                             top=7,
                             fontsize=9,
                             color=(1.0, 1.0, 1.0, 0.5))
    curve, binding = CreateColorCurve(bracket,
                                      curveSet,
                                      length=0.5,
                                      startValue=(1, 1, 1, 1),
                                      endValue=(1, 1, 1, 0),
                                      cycle=True)
    curve.AddKey(0.0, (1, 1, 1, 0.0))
    curve.AddKey(0.1, (1, 1, 1, 1))
    curve.AddKey(0.5, (1, 1, 1, 0.0))
    AddBinding(curve, 'currentValue', caption, 'color', curveSet)
    curve, binding = CreateScalarCurve(mainParent,
                                       'currentValue',
                                       'displayX',
                                       curveSet,
                                       length=inTime,
                                       startValue=-500.0,
                                       endValue=0.0,
                                       endTangent=-1000.0,
                                       cycle=False)
    correction = -0.5
    curve = trinity.TriPerlinCurve()
    curve.scale = 400.0
    curve.offset = 200.0
    curveSet.curves.append(curve)
    innerTransform = trinity.Tr2Sprite2dTransform()
    innerTransform.translation = (0, 0)
    innerTransform.rotationCenter = (64, 64)
    par.children.insert(0, innerTransform)
    inner = trinity.Tr2Sprite2d()
    innerTransform.children.append(inner)
    inner.displayWidth = inner.displayHeight = 128
    inner.displayX = correction
    inner.displayY = correction
    inner.texturePrimary = trinity.Tr2Sprite2dTexture()
    inner.texturePrimary.resPath = 'res:/uicore/Texture/innercircles.dds'
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = innerTransform
    binding.destinationAttribute = 'rotation'
    binding.scale = 0.025
    curveSet.bindings.append(binding)
    curve = trinity.TriSineCurve()
    curve.scale = 500.0
    curve.offset = 300.0
    curve.speed = 0.3
    curveSet.curves.append(curve)
    outerTransform = trinity.Tr2Sprite2dTransform()
    outerTransform.translation = (0, 0)
    outerTransform.rotationCenter = (64, 64)
    par.children.insert(0, outerTransform)
    outer = trinity.Tr2Sprite2d()
    outerTransform.children.append(outer)
    outer.displayWidth = outer.displayHeight = 128
    outer.displayX = correction
    outer.displayY = correction
    outer.texturePrimary = trinity.Tr2Sprite2dTexture()
    outer.texturePrimary.resPath = 'res:/uicore/Texture/outercircles.dds'
    outer.effect = trinity.S2D_RFX_BLUR
    outer.blurFactor = 0.1
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = outerTransform
    binding.destinationAttribute = 'rotation'
    binding.scale = 0.00125
    curveSet.bindings.append(binding)
    curveSet.Play()