Ejemplo n.º 1
0
        public Quaternion Rotation(int seed2, float rx, float ry, float rz)
        {
            var i1 = _hash1.Range(-100.0f, 100.0f, seed2);
            var i2 = _hash2.Range(-100.0f, 100.0f, seed2);
            var i3 = _hash3.Range(-100.0f, 100.0f, seed2);

            return(Quaternion.Euler(
                       Perlin.Fbm(_time + i1, _fractal) * _fbmNorm * rx,
                       Perlin.Fbm(_time + i2, _fractal) * _fbmNorm * ry,
                       Perlin.Fbm(_time + i3, _fractal) * _fbmNorm * rz));
        }
Ejemplo n.º 2
0
        public Vector3 Vector(int seed2)
        {
            var i1 = _hash1.Range(-100.0f, 100.0f, seed2);
            var i2 = _hash2.Range(-100.0f, 100.0f, seed2);
            var i3 = _hash3.Range(-100.0f, 100.0f, seed2);

            return(new Vector3(
                       Perlin.Fbm(_time + i1, _fractal) * _fbmNorm,
                       Perlin.Fbm(_time + i2, _fractal) * _fbmNorm,
                       Perlin.Fbm(_time + i3, _fractal) * _fbmNorm));
        }
Ejemplo n.º 3
0
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            if (_target == null)
            {
                return;
            }

            const float _fbmNorm = 1 / 0.75f;

            var time = (float)playable.GetTime();

            if (_positionAmplitude != Vector3.zero)
            {
                var t  = time * _positionFrequency;
                var tx = _hash.Range(-1e3f, 1e3f, 0) + t;
                var ty = _hash.Range(-1e3f, 1e3f, 1) + t;
                var tz = _hash.Range(-1e3f, 1e3f, 2) + t;

                var n = new Vector3(
                    Perlin.Fbm(tx, _positionFractalLevel),
                    Perlin.Fbm(ty, _positionFractalLevel),
                    Perlin.Fbm(tz, _positionFractalLevel)
                    );

                n = Vector3.Scale(n, _positionAmplitude) * _fbmNorm;

                _target.localPosition = n;
            }

            if (_rotationAmplitude != Vector3.zero)
            {
                var t  = time * _rotationFrequency;
                var tx = _hash.Range(-1e3f, 1e3f, 3) + t;
                var ty = _hash.Range(-1e3f, 1e3f, 4) + t;
                var tz = _hash.Range(-1e3f, 1e3f, 5) + t;

                var n = new Vector3(
                    Perlin.Fbm(tx, _rotationFractalLevel),
                    Perlin.Fbm(ty, _rotationFractalLevel),
                    Perlin.Fbm(tz, _rotationFractalLevel)
                    );

                n = Vector3.Scale(n, _rotationAmplitude) * _fbmNorm;

                _target.localRotation = Quaternion.Euler(n);
            }
        }
Ejemplo n.º 4
0
        void Update()
        {
            var dt = Time.deltaTime;

            if (_enablePositionNoise)
            {
                for (var i = 0; i < 3; i++)
                {
                    _time[i] += _positionFrequency * dt;
                }

                var n = new Vector3(
                    Perlin.Fbm(_time[0], _positionFractalLevel),
                    Perlin.Fbm(_time[1], _positionFractalLevel),
                    Perlin.Fbm(_time[2], _positionFractalLevel));

                n  = Vector3.Scale(n, _positionScale);
                n *= _positionAmplitude * _fbmNorm;

                transform.localPosition = _initialPosition + n;
            }

            if (_enableRotationNoise)
            {
                for (var i = 0; i < 3; i++)
                {
                    _time[i + 3] += _rotationFrequency * dt;
                }

                var n = new Vector3(
                    Perlin.Fbm(_time[3], _rotationFractalLevel),
                    Perlin.Fbm(_time[4], _rotationFractalLevel),
                    Perlin.Fbm(_time[5], _rotationFractalLevel));

                n  = Vector3.Scale(n, _rotationScale);
                n *= _rotationAmplitude * _fbmNorm;

                transform.localRotation =
                    Quaternion.Euler(n) * _initialRotation;
            }
        }
Ejemplo n.º 5
0
        public float Value(int seed2)
        {
            var i1 = _hash1.Range(-100.0f, 100.0f, seed2);

            return(Perlin.Fbm(_time + i1, _fractal) * _fbmNorm);
        }