Ejemplo n.º 1
0
    protected static void applyBrush(Vox.VoxelEditor editor, Ray mouseLocation)
    {
        byte opacity = byte.MaxValue;

        if (UnityEngine.Event.current.shift)
        {
            opacity = byte.MinValue;
        }
        Vector3 point = editor.getBrushPoint(mouseLocation);

        switch (editor.selectedBrush)
        {
        case 0:
            Vox.SphereModifier sphereMod = new Vox.SphereModifier(editor, point, editor.sphereBrushSize, new Vox.Voxel(editor.sphereBrushSubstance, opacity), true);
            sphereMod.overwriteShape = !editor.sphereSubstanceOnly;
            sphereMod.apply();
            break;

        case 1:
            Vox.CubeModifier cubeMod = new Vox.CubeModifier(editor, point, editor.cubeBrushDimensions, new Vox.Voxel(editor.cubeBrushSubstance, opacity), true);
            cubeMod.overwriteShape = !editor.cubeSubstanceOnly;
            cubeMod.apply();
            break;

        case 2:
            Vox.BlurModifier blur = new Vox.BlurModifier(editor, point, editor.smoothBrushSize, editor.smoothBrushStrength, true);
            blur.blurRadius = editor.smoothBrushBlurRadius;
            blur.apply();
            break;
        }
    }
Ejemplo n.º 2
0
    protected void applyBrush(Vox.VoxelEditor editor, Ray mouseLocation)
    {
        // get point clicked on
        System.Nullable <Vector3> point = editor.getBrushPoint(mouseLocation);
        if (point == null)
        {
            return;
        }

        // check if control pressed.  If so, add point to pathList
        if (editor.isPathing())
        {
            editor.addPathPoint(point.Value);
            return;
        }

        // check for showPositionHandles
        if (editor.showPositionHandles && editor.isSelectedBrushPathable() &&
            editor.pathPoints != null && editor.pathPoints.Length > 0)
        {
            return;
        }

        // create mutator
        Vox.Mutator mutator = buildMutator(editor, point.Value);

        // apply mutator
        if (mutator == null)
        {
            return;
        }
        Vox.LocalMutator localMutator = mutator as Vox.LocalMutator;
        if (localMutator != null && editor.pathPoints != null && editor.pathPoints.Length > 0)
        {
            editor.addPathPoint(point.Value);
            mutator           = new Vox.LineMutator(editor.pathPoints, localMutator);
            editor.pathPoints = null;
        }
        mutator.apply(editor);
    }