Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        var r   = BulletTime.Noise1D(BulletTime.time * frequency + _noiseSeed) * 2f - 1f;
        var a   = ((Mathf.Abs(r) > 0.25)?Mathf.Pow(r, 1f + pullToRest) * Mathf.Sign(r): r) * maxAngle;
        var rot = (Mathf.Abs(a) > Mathf.Epsilon)? Quaternion.AngleAxis(a, aroundAxis): Quaternion.identity;

        transform.localRotation = _initialLocalRotation * rot;
    }
Beispiel #2
0
    void Update()
    {
        //float t = BulletTime.time;
        float t   = Time.time;
        float rnd = mid + BulletTime.Noise1D(t * frequency) * range;

        _rnd = rnd.ToString();
        if (propBlock != null)
        {
            propBlock.Clear();
            propBlock.AddFloat("_Intensity", rnd);
            GetComponent <Renderer>().SetPropertyBlock(propBlock);
        }
    }
    void LateUpdate()
    {
        SaveTransforms(movesFrom, movesTo);

        if (lookAt)
        {
            GetComponent <Camera>().transform.LookAt(lookAt, Vector3.up);
        }

        const float filmWidthInMM  = 36f;
        const float filmHeightInMM = filmWidthInMM / 1.5f;

        GetComponent <Camera>().fieldOfView = 2.0f * Mathf.Atan2(filmHeightInMM, 2f * focalLength) * Mathf.Rad2Deg;

        if (letterBox)
        {
            var targetAspect     = aspectHeight / Mathf.Max(aspectWidth, 1e-3f);
            var totalPixelWidth  = GetComponent <Camera>().pixelWidth / GetComponent <Camera>().rect.width;
            var totalPixelHeight = GetComponent <Camera>().pixelHeight / GetComponent <Camera>().rect.height;
            var pixelRect        = GetComponent <Camera>().pixelRect;
            pixelRect.height = pixelRect.width * targetAspect;
            if (totalPixelHeight <= pixelRect.height)
            {
                pixelRect.height = totalPixelHeight;
                pixelRect.width  = (pixelRect.height / targetAspect);
                pixelRect.x      = Mathf.Round((totalPixelWidth - pixelRect.width) * 0.5f);
                pixelRect.width  = Mathf.Round(pixelRect.width);
            }
            else
            {
                pixelRect.width = totalPixelWidth;
                pixelRect.x     = 0;
            }
            pixelRect.y      = Mathf.Round((totalPixelHeight - pixelRect.height) * 0.5f);
            pixelRect.height = Mathf.Round(pixelRect.height);
            GetComponent <Camera>().pixelRect = pixelRect;
        }
        else
        {
            GetComponent <Camera>().rect = new Rect(0, 0, 1, 1);
        }

        if (!BulletTime.isEditing)
        {
            if (lookAt)
            {
                GetComponent <Camera>().transform.localRotation *= _externalRotation;
            }
            else
            {
                GetComponent <Camera>().transform.localRotation = _initialLocalRot * _externalRotation;
            }
        }

        if ((!BulletTime.isEditing || lookAt) && jitter > 0f && Time.timeScale > 0f)
        {
            var x = BulletTime.Noise1D(BulletTime.time * jitterFrequency * 0.33f) * 2f - 1f;
            var y = BulletTime.Noise1D((BulletTime.time + 1f) * jitterFrequency * 0.33f) * 2f - 1f;
            var n = new Vector2(x, y);
            n *= (GetComponent <Camera>().fieldOfView / 70f); // normalize jitter from 70 FOV angle
            n *= jitter * 0.2f;                               //0.25f;
            var q = Quaternion.Euler(n.x, n.y, 0.0f);
            GetComponent <Camera>().transform.localRotation *= q;
        }

        RestoreTransforms(movesFrom, movesTo);
    }