Beispiel #1
0
        private void CreateLine()
        {
            _currentLine = Instantiate(_linePrefab, Vector3.zero, Quaternion.identity);
            _currentLine.transform.SetParent(_3dRoot.transform, false);
            _lineRenderer = _currentLine.GetComponent <LineRenderer>();
            _lineRenderer.sharedMaterial = new Material(_lineMaterial);
            _lineRenderer.sortingOrder   = 0;

            if (BrushService.IsEmissionEnabled())
            {
                _lineRenderer.sharedMaterial.EnableKeyword("_EMISSION");
                _lineRenderer.sharedMaterial.SetColor("_EmissionColor", BrushService.GetBrushEmissionColor() * BrushService.GetBrushEmissionIntensity());
            }

            _lineRenderer.colorGradient = BrushService.GetBrushGradient();

            _lineRenderer.widthCurve = BrushService.GetBrushWidthCurve();

            _fingerPositions.Clear();
            _fingerPositions.Add(_camera.ScreenToWorldPoint(Input.mousePosition));
            _fingerPositions.Add(_camera.ScreenToWorldPoint(Input.mousePosition));

            if (BrushService.GetBrushShape() == Shape.Line)
            {
                _lineRenderer.SetPosition(0, _fingerPositions[0]);
                _lineRenderer.SetPosition(1, _fingerPositions[1]);
            }
            else if (BrushService.GetBrushShape() == Shape.Phyllotaxis)
            {
                _lineRenderer.gameObject.transform.localPosition = _camera.ScreenToWorldPoint((Input.mousePosition));
            }
            else
            {
                _lineRenderer.positionCount = _shapePointAmout + 1;
                _lineRenderer.SetPositions(_shapePoints);
                _lineRenderer.SetPosition(_shapePointAmout, _shapePoints[0]);
            }
        }
Beispiel #2
0
        public override void Execute()
        {
            DialogColorPicker dialogColorPicker = DialogManager.ShowDialogColorPicker();

            dialogColorPicker.Initialize(BrushService.GetBrushEmissionColor(), OnColorSelected);
        }
Beispiel #3
0
        private void DrawCursor()
        {
            if (_lineCursorRenderer == null)
            {
                CreateCursor();
            }

            _cursorLine.gameObject.SetActive(true);

            if (BrushService.IsEmissionEnabled())
            {
                _lineCursorRenderer.sharedMaterial.EnableKeyword("_EMISSION");
                _lineCursorRenderer.sharedMaterial.SetColor("_EmissionColor", BrushService.GetBrushEmissionColor() * BrushService.GetBrushEmissionIntensity());
            }

            _lineCursorRenderer.colorGradient = BrushService.GetBrushGradient();

            _lineCursorRenderer.widthCurve = BrushService.GetBrushWidthCurve();


            switch (BrushService.GetBrushShape())
            {
            case Shape.Line:
            case Shape.Phyllotaxis:
                _lineCursorRenderer.positionCount = 2;
                _lineCursorRenderer.SetPosition(0, _camera.ScreenToWorldPoint(Input.mousePosition));
                _lineCursorRenderer.SetPosition(1, _camera.ScreenToWorldPoint(Input.mousePosition));
                return;

            case Shape.Triangle:
                _shapePointAmout = 3;
                break;

            case Shape.Square:
                _shapePointAmout = 4;
                break;

            case Shape.Pentagon:
                _shapePointAmout = 5;
                break;

            case Shape.Hexagon:
                _shapePointAmout = 6;
                break;

            case Shape.Heptagon:
                _shapePointAmout = 7;
                break;

            case Shape.Octagon:
                _shapePointAmout = 8;
                break;
            }

            _shapePoints  = new Vector3[_shapePointAmout];
            _rotateVector = Quaternion.AngleAxis(_initialRotation, new Vector3(0, 0, 1)) * new Vector3(1, 0, 0);

            for (int i = 0; i < _shapePointAmout; i++)
            {
                _shapePoints[i] = (_rotateVector *
                                   BrushService.GetBrushShapeInitSize()) + _camera.ScreenToWorldPoint(Input.mousePosition);
                _rotateVector = Quaternion.AngleAxis(360 / _shapePointAmout, new Vector3(0, 0, 1)) * _rotateVector;
            }

            _lineCursorRenderer.positionCount = _shapePointAmout + 1;
            for (int i = 0; i < _shapePointAmout; i++)
            {
                _lineCursorRenderer.SetPosition(i, _shapePoints[i]);
            }
            _lineCursorRenderer.SetPosition(_shapePointAmout, _shapePoints[0]);
        }
Beispiel #4
0
        private void ReleaseLine()
        {
            if (_lineRenderer == null)
            {
                return;
            }
            _drawing = false;
            Vector3[] originalPositions = new Vector3[_lineRenderer.positionCount];
            _lineRenderer.GetPositions(originalPositions);

            ILineModel lineModel = new LineModel
            {
                Guid              = Guid.NewGuid().ToString("N"),
                DisplayName       = BrushService.GetBrushShape().ToString(),
                Layer             = _lineRenderer.sortingOrder,
                WidthCurve        = _lineRenderer.widthCurve,
                Gradient          = _lineRenderer.colorGradient,
                IsEmissionEnabled = BrushService.IsEmissionEnabled(),
                EmissionIntensity = BrushService.GetBrushEmissionIntensity(),
                LineGameObject    = _lineRenderer,
                Shape             = BrushService.GetBrushShape(),
                EmissionColor     = BrushService.GetBrushEmissionColor(),

                EmissionProperty    = new EmissionProperty(),
                ScaleProperty       = new ScaleProperty(),
                KochLineProperty    = new KochLineProperty(),
                KochTrailProperty   = new KochTrailProperty(),
                PhyllotaxisProperty = new PhyllotaxisProperty()
            };

            lineModel.EmissionProperty.IsEmissionReactOnAudio = BrushService.GetBrushEmissionReactOnAudio();
            lineModel.EmissionProperty.EmissionBandBuffer     = BrushService.GetBrushEmissionBandBuffer();
            lineModel.EmissionProperty.EmissionThreshold      = BrushService.GetBrushEmissionThreshold();
            lineModel.EmissionProperty.EmissionFrequencyType  = BrushService.GetBrushEmissionFrequencyType();

            lineModel.ScaleProperty.IsScaleReactOnAudio = BrushService.GetBrushScaleReactOnAudio();
            lineModel.ScaleProperty.ScaleBandBuffer     = BrushService.GetBrushScaleBandBuffer();
            lineModel.ScaleProperty.ScaleMultiplier     = BrushService.GetBrushScaleMultiplier();
            lineModel.ScaleProperty.ScaleThreshold      = BrushService.GetBrushScaleThreshold();
            lineModel.ScaleProperty.ScaleFrequencyType  = BrushService.GetBrushScaleFrequencyType();

            lineModel.KochLineProperty.IsKochEnabled       = BrushService.GetBrushKochEnabled();
            lineModel.KochLineProperty.ShapePointAmount    = _shapePointAmout;
            lineModel.KochLineProperty.ListStartGeneration = BrushService.GetBrushStartGeneration();
            lineModel.KochLineProperty.AnimationCurve      = BrushService.GetBrushAnimationCurve();
            lineModel.KochLineProperty.UseBezierCurves     = BrushService.GetBrushUseBezierCurves();
            lineModel.KochLineProperty.BezierVertexCount   = BrushService.GetBrushBezierVertexCount();
            lineModel.KochLineProperty.KochAudioBand       = BrushService.GetBrushKochAudioBand();
            lineModel.KochLineProperty.OriginalPositions   = originalPositions;

            lineModel.KochTrailProperty.IsTrailEnabled   = BrushService.GetBrushTrailEnabled();
            lineModel.KochTrailProperty.TrailSpeedMinMax = BrushService.GetBrushTrailSpeedMinMax();
            lineModel.KochTrailProperty.TrailTimeMinMax  = BrushService.GetBrushTrailTimeMinMax();
            lineModel.KochTrailProperty.TrailWidthMinMax = BrushService.GetBrushTrailWidthMinMax();

            lineModel.PhyllotaxisProperty.Degree                  = BrushService.GetBrushDegree();
            lineModel.PhyllotaxisProperty.Scale                   = BrushService.GetBrushScale();
            lineModel.PhyllotaxisProperty.NumberStart             = BrushService.GetBrushNumberStart();
            lineModel.PhyllotaxisProperty.StepSize                = BrushService.GetBrushStepSize();
            lineModel.PhyllotaxisProperty.MaxIterations           = BrushService.GetBrushMaxIterations();
            lineModel.PhyllotaxisProperty.UseLerping              = BrushService.GetBrushUseLerping();
            lineModel.PhyllotaxisProperty.LerpFrequencyType       = BrushService.GetBrushLerpFrequencyType();
            lineModel.PhyllotaxisProperty.LerpAudioBand           = BrushService.GetBrushLerpAudioBand();
            lineModel.PhyllotaxisProperty.SpeedMinMax             = BrushService.GetBrushSpeedMinMax();
            lineModel.PhyllotaxisProperty.LerpInterpolationCurve  = BrushService.GetBrushLerpInterpolationCurve();
            lineModel.PhyllotaxisProperty.Repeat                  = BrushService.GetBrushRepeat();
            lineModel.PhyllotaxisProperty.Invert                  = BrushService.GetBrushInvert();
            lineModel.PhyllotaxisProperty.UseScaling              = BrushService.GetBrushUseScaling();
            lineModel.PhyllotaxisProperty.ScaleFrequencyType      = BrushService.GetBrushScalePhylloFrequencyType();
            lineModel.PhyllotaxisProperty.ScaleAudioBand          = BrushService.GetBrushScaleAudioBand();
            lineModel.PhyllotaxisProperty.ScaleMinMax             = BrushService.GetBrushScaleMinMax();
            lineModel.PhyllotaxisProperty.UseScaleCurve           = BrushService.GetBrushUseScaleCurve();
            lineModel.PhyllotaxisProperty.ScaleInterpolationCurve = BrushService.GetBrushScaleInterpolationCurve();
            lineModel.PhyllotaxisProperty.InterpolationSpeed      = BrushService.GetBrushInterpolationSpeed();

            AddLineSignal.Dispatch(lineModel);
        }