Beispiel #1
0
        private static Vector3 GetMirroredPosition(SculptState state)
        {
            var p = state.position;

            p    = state.worldToLocal.MultiplyPoint(p);
            p.x *= -1;
            return(state.worldToLocal.inverse.MultiplyPoint(p));
        }
Beispiel #2
0
        private void Update()
        {
            currentState = GetState(currentState);
            currentState.worldToLocal = MeshWrapper.MeshTransform.worldToLocalMatrix;
            currentState.menuState    = Menu.GetState();

            var mat = MeshWrapper.Material;

            mat.SetVector($"_BrushPos", currentState.position);
            mat.SetFloat($"_BrushRadius", Menu.ToolSize.Value / 2);
            mat.SetFloat($"_BrushHardness", Menu.ToolHardness.Value);
            mat.SetFloat($"_MenuEnabled", Menu.AppMenuEnabled.Value ? 1 : 0);

            mat.SetFloat($"_SymmetryEnabled", Menu.SymmetryEnabled.Value ? 1 : 0);
            mat.SetVector($"_BrushPosMirrored", GetMirroredPosition(currentState));

            stateStack.Push(currentState);
        }
Beispiel #3
0
        private void Sculpt(SculptState state)
        {
            if (state.menuState.appMenuEnabled)
            {
                return;
            }

            if (state.drawing)
            {
                tools[state.menuState.tool].Use(state, deformer);
                if (state.menuState.symmetryEnabled)
                {
                    state.position = GetMirroredPosition(state);
                    mirrorTools[state.menuState.tool].Use(state, mirrorDeformer);
                }
            }
            else if (state.drawingUp)
            {
                deformer.Unmask();
                mirrorDeformer.Unmask();
            }

            MeshWrapper.SculptMesh.ApplyDeformation();
        }
Beispiel #4
0
 protected abstract SculptState GetState(SculptState prev);