Esempio n. 1
0
        // Start is called before the first frame update
        void Start()
        {
            Init();

            paintTool = PaintTools.Pencil; // <---- Tube is default

            ConfigureSubPanels();

            ConfigureCursors();

            paintLineRenderer = transform.gameObject.GetComponent <LineRenderer>();
            if (paintLineRenderer == null)
            {
                Debug.LogWarning("Expected a line renderer on the paintItem game object.");
            }
            else
            {
                paintLineRenderer.startWidth = 0.005f; paintLineRenderer.endWidth = 0.005f;
            }

            freeDraw        = new FreeDraw();
            volumeGenerator = new VolumeMeshGenerator();

            brushSize = mouthpiece.localScale.x;
            OnPaintColor(GlobalState.CurrentColor);

            SetTooltips();

            GlobalState.colorChangedEvent.AddListener(OnPaintColor);
        }
Esempio n. 2
0
        private void BeginPaint()
        {
            switch (paintTool)
            {
            case PaintTools.Pencil:
            case PaintTools.FlatPencil:
            case PaintTools.ConvexHull:
            {
                // Create an empty game object with a mesh
                currentPaint = Create(PaintTools.Pencil, GlobalState.CurrentColor);
                freeDraw     = new FreeDraw
                {
                    matrix = currentPaint.transform.worldToLocalMatrix
                };
            }
            break;

            case PaintTools.Volume:
                if (volumeEditionMode == VolumeEditionMode.Create)
                {
                    currentVolume = Create(PaintTools.Volume, GlobalState.CurrentColor);
                    currentVolume.transform.position = mouthpiece.position;            // real-world position
                    volumeGenerator.Reset();
                    volumeGenerator.stepSize      = stepSize / GlobalState.WorldScale; // viewer scale -> world scale.
                    volumeGenerator.toLocalMatrix = currentVolume.transform.worldToLocalMatrix;
                }
                else     // volumeEditionMode == VolumeEditionMode.Edit
                {
                    // nothing to do I guess.
                    volumeGenerator.toLocalMatrix = currentVolume.transform.worldToLocalMatrix;
                }
                break;
            }
        }