コード例 #1
0
ファイル: KochTrail.cs プロジェクト: dqchess/Linyx
    private void HandleAudio()
    {
        for (int i = 0; i < _line.KochLineProperty.ShapePointAmount; i++)
        {
            Color colorLerp = Color.Lerp(_startColor, _trails[i].EmissionColor * _line.EmissionIntensity, _audioPeer.GetAudioBand(_line.KochLineProperty.KochAudioBand[i]));
            _trails[i].Trail.material.SetColor("_EmissionColor", colorLerp);

            colorLerp = Color.Lerp(_startColor, _endColor, _audioPeer.GetAudioBand(_line.KochLineProperty.KochAudioBand[i]));
            _trails[i].Trail.material.SetColor("Color", colorLerp);

            float widthLerp = Mathf.Lerp(_line.KochTrailProperty.TrailWidthMinMax.x, _line.KochTrailProperty.TrailWidthMinMax.y, _audioPeer.GetAudioBandBuffer(_line.KochLineProperty.KochAudioBand[i]));
            _trails[i].Trail.widthMultiplier = widthLerp;

            float timeLerp = Mathf.Lerp(_line.KochTrailProperty.TrailTimeMinMax.x, _line.KochTrailProperty.TrailTimeMinMax.y, _audioPeer.GetAudioBandBuffer(_line.KochLineProperty.KochAudioBand[i]));
            _trails[i].Trail.time = timeLerp;
        }
    }
コード例 #2
0
ファイル: PhyllotaxisTrail.cs プロジェクト: dqchess/Linyx
        private void HandleMovement()
        {
            if (_lineModel.PhyllotaxisProperty.UseScaling)
            {
                float valueScale;
                switch (_lineModel.PhyllotaxisProperty.ScaleFrequencyType)
                {
                case AudioFrequencyType.Band:
                    valueScale = _audioPeer.GetAudioBand(_lineModel.PhyllotaxisProperty.ScaleAudioBand);
                    break;

                case AudioFrequencyType.BandBuffer:
                    valueScale = _audioPeer.GetAudioBandBuffer(_lineModel.PhyllotaxisProperty.ScaleAudioBand);
                    break;

                case AudioFrequencyType.Amplitude:
                    valueScale = _audioPeer.GetAmplitude();
                    break;

                case AudioFrequencyType.AmplitudeBuffer:
                    valueScale = _audioPeer.GetAmplitudeBuffer();
                    break;

                case AudioFrequencyType.Frequency:
                    valueScale = _audioPeer.GetFrequencyBand(_lineModel.PhyllotaxisProperty.ScaleAudioBand);
                    break;

                case AudioFrequencyType.FrequencyBuffer:
                    valueScale = _audioPeer.GetFrequencyBandBuffer(_lineModel.PhyllotaxisProperty.ScaleAudioBand);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (_lineModel.PhyllotaxisProperty.UseScaleCurve)
                {
                    _scaleTimer += (_lineModel.PhyllotaxisProperty.InterpolationSpeed * valueScale) * Time.deltaTime;
                    if (_scaleTimer >= 1)
                    {
                        _scaleTimer -= 1;
                    }
                    _currentScale = Mathf.Lerp(_lineModel.PhyllotaxisProperty.ScaleMinMax.x, _lineModel.PhyllotaxisProperty.ScaleMinMax.y, _lineModel.PhyllotaxisProperty.ScaleInterpolationCurve.Evaluate(_scaleTimer));
                }
                else
                {
                    _currentScale = Mathf.Lerp(_lineModel.PhyllotaxisProperty.ScaleMinMax.x, _lineModel.PhyllotaxisProperty.ScaleMinMax.y, valueScale);
                }
            }


            if (_lineModel.PhyllotaxisProperty.UseLerping)
            {
                if (_isLerping)
                {
                    float valueLerping;
                    switch (_lineModel.PhyllotaxisProperty.LerpFrequencyType)
                    {
                    case AudioFrequencyType.Band:
                        valueLerping = _audioPeer.GetAudioBand(_lineModel.PhyllotaxisProperty.LerpAudioBand);
                        break;

                    case AudioFrequencyType.BandBuffer:
                        valueLerping = _audioPeer.GetAudioBandBuffer(_lineModel.PhyllotaxisProperty.LerpAudioBand);
                        break;

                    case AudioFrequencyType.Amplitude:
                        valueLerping = _audioPeer.GetAmplitude();
                        break;

                    case AudioFrequencyType.AmplitudeBuffer:
                        valueLerping = _audioPeer.GetAmplitudeBuffer();
                        break;

                    case AudioFrequencyType.Frequency:
                        valueLerping = _audioPeer.GetFrequencyBand(_lineModel.PhyllotaxisProperty.LerpAudioBand);
                        break;

                    case AudioFrequencyType.FrequencyBuffer:
                        valueLerping = _audioPeer.GetFrequencyBandBuffer(_lineModel.PhyllotaxisProperty.LerpAudioBand);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    _lerpPosSpeed           = Mathf.Lerp(_lineModel.PhyllotaxisProperty.SpeedMinMax.x, _lineModel.PhyllotaxisProperty.SpeedMinMax.y, _lineModel.PhyllotaxisProperty.LerpInterpolationCurve.Evaluate(valueLerping));
                    _lerpPosTimer          += Time.deltaTime * _lerpPosSpeed;
                    transform.localPosition = Vector3.Lerp(_startPosition, _endPosition, Mathf.Clamp01(_lerpPosTimer));
                    if (_lerpPosTimer >= 1)
                    {
                        _lerpPosTimer -= 1;
                        if (_forward)
                        {
                            _number += _lineModel.PhyllotaxisProperty.StepSize;
                            _currentIteration++;
                        }
                        else
                        {
                            _number -= _lineModel.PhyllotaxisProperty.StepSize;
                            _currentIteration--;
                        }
                        if ((_currentIteration >= 0) && (_currentIteration < _lineModel.PhyllotaxisProperty.MaxIterations))
                        {
                            SetLerpPositions();
                        }
                        else // current iteration has hit 0 or maxiteration
                        {
                            if (_lineModel.PhyllotaxisProperty.Repeat)
                            {
                                if (_lineModel.PhyllotaxisProperty.Invert)
                                {
                                    _forward = !_forward;
                                    SetLerpPositions();
                                }
                                else
                                {
                                    _number           = _lineModel.PhyllotaxisProperty.NumberStart;
                                    _currentIteration = 0;
                                    SetLerpPositions();
                                }
                            }
                            else
                            {
                                _isLerping = false;
                            }
                        }
                    }
                }
            }
            if (!_lineModel.PhyllotaxisProperty.UseLerping)
            {
                _phyllotaxisPosition    = CalculatePhyllotaxis(_lineModel.PhyllotaxisProperty.Degree, _currentScale, _number);
                transform.localPosition = new Vector3(_phyllotaxisPosition.x, _phyllotaxisPosition.y, 0);
                _number += _lineModel.PhyllotaxisProperty.StepSize;
                _currentIteration++;
            }
        }