Beispiel #1
0
        public override async void Execute()
        {
            RTAnimationCurve rtAnimationCurve = CurveService.GetAnimationCurve();

            rtAnimationCurve.ShowCurveEditor();
            rtAnimationCurve.NewWindow();

            AnimationCurve animationCurve = BrushService.GetBrushWidthCurve();

            rtAnimationCurve.Add(ref animationCurve);

            rtAnimationCurve.SetGradXRange(0, 1f);
            rtAnimationCurve.SetGradYRange(0, 0.5f);

            await TaskEx.WaitWhile(CurveService.IsEditorOpen);

            BrushService.SetBrushWidthCurve(animationCurve);
        }
Beispiel #2
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 #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]);
        }