public LineMutator(Vector3[] globalPoints, LocalMutator child) { if (globalPoints.Length < 2) throw new System.ArgumentException("Must have at least two points specified.", "globalPoints"); this.globalPoints = globalPoints; this.child = child; }
public LineMutator(Vector3[] globalPoints, LocalMutator child) { if (globalPoints.Length < 2) { throw new System.ArgumentException("Must have at least two points specified.", "globalPoints"); } this.globalPoints = globalPoints; this.child = child; }
protected override Action checkMutation(Application app, Index pos) { BlurApp bApp = (BlurApp)app; BlurAction action = new BlurAction(); float voxelSize = LocalMutator.calculateVoxelSize(app, pos); Vector3 diff = LocalMutator.calculateDiff(bApp.position, pos, voxelSize); action.disSqr = diff.sqrMagnitude; float maxRadius = bApp.radius + voxelSize; float maxRadSqr = maxRadius * maxRadius; if (action.disSqr > maxRadSqr) { return(action); } action.doTraverse = true; action.modify = true; return(action); }
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); }
protected void doSculptGUI(Vox.VoxelEditor editor) { // brush ghost editor.ghostBrushAlpha = doSliderFloatField("Brush Ghost Opacity", editor.ghostBrushAlpha, 0, 1); editor.gridEnabled = EditorGUILayout.Toggle("Snap to Grid", editor.gridEnabled); if (editor.gridEnabled) { ++EditorGUI.indentLevel; editor.gridUseVoxelUnits = EditorGUILayout.Toggle("Use Voxel Units", editor.gridUseVoxelUnits); if (editor.gridUseVoxelUnits) { float voxelSize = editor.baseSize / (1 << editor.maxDetail); editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Voxels)", editor.gridSize / voxelSize) * voxelSize; } else { editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Meters)", editor.gridSize); } --EditorGUI.indentLevel; } // brush list GUILayout.Label("Brush", labelBigFont); editor.selectedBrush = GUILayout.Toolbar(editor.selectedBrush, brushes, GUILayout.MinHeight(20)); // brush substance type string[] substances = new string[editor.voxelSubstances.Length]; for (int i = 0; i < substances.Length; ++i) { substances[i] = editor.voxelSubstances[i].name; } // brush size switch (editor.selectedBrush) { case 0: GUILayout.Label("Hold 'Shift' to subtract."); editor.sphereBrushSize = doSliderFloatField("Sphere Radius (m)", editor.sphereBrushSize, 0, maxBrushSize(editor)); editor.sphereSubstanceOnly = GUILayout.Toggle(editor.sphereSubstanceOnly, "Change Substance Only"); GUILayout.Label("Substance", labelBigFont); editor.sphereBrushSubstance = (byte)GUILayout.SelectionGrid(editor.sphereBrushSubstance, substances, 1); break; case 1: GUILayout.Label("Hold 'Shift' to subtract."); GUILayout.BeginHorizontal(); GUILayout.Label("Dimensions (m)"); editor.cubeBrushDimensions.x = EditorGUILayout.FloatField(editor.cubeBrushDimensions.x); editor.cubeBrushDimensions.y = EditorGUILayout.FloatField(editor.cubeBrushDimensions.y); editor.cubeBrushDimensions.z = EditorGUILayout.FloatField(editor.cubeBrushDimensions.z); GUILayout.EndHorizontal(); editor.cubeSubstanceOnly = GUILayout.Toggle(editor.cubeSubstanceOnly, "Change Substance Only"); GUILayout.Label("Substance", labelBigFont); editor.cubeBrushSubstance = (byte)GUILayout.SelectionGrid(editor.cubeBrushSubstance, substances, 1); break; case 2: editor.smoothBrushSize = doSliderFloatField("Radius (m)", editor.smoothBrushSize, 0, maxBrushSize(editor)); editor.smoothBrushStrength = doSliderFloatField("Strength", editor.smoothBrushStrength, 0, 5); editor.smoothBrushBlurRadius = EditorGUILayout.IntField("Blur Radius", editor.smoothBrushBlurRadius); break; } // PATH GUI if (editor.selectedBrush != 0 && editor.selectedBrush != 1) { return; } GUILayout.Label("Path Tool", labelBigFont); if (editor.pathPoints != null && editor.pathPoints.Length > 0) { GUILayout.Label("Hold 'Control' to place another point."); editor.showPositionHandles = GUILayout.Toggle(editor.showPositionHandles, "Show drag handles (disable click to complete)."); SerializedProperty prop = serializedObject.FindProperty("pathPoints"); InspectorList.doArrayGUISimple(ref prop); serializedObject.ApplyModifiedProperties(); if (GUILayout.Button("Clear Path")) { editor.pathPoints = null; } else if (GUILayout.Button("Apply Path")) { Vox.LocalMutator mut = (Vox.LocalMutator)buildMutator(editor, editor.pathPoints[0]); if (editor.pathPoints.Length > 1) { new Vox.LineMutator(editor.pathPoints, mut).apply(editor); } else { mut.apply(editor); } } } else { GUILayout.Label("Hold 'Control' to start a path."); if (GUILayout.Button("Start Path")) { editor.addPathPoint(editor.transform.position); } } }