Ejemplo 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
Ejemplo 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
Ejemplo n.º 3
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)