public override void OnInspectorGUI() { EditorGUILayout.LabelField("Compute Shader", EditorStyles.boldLabel); EditorGUILayout.PropertyField(imageCompute); EditorGUILayout.PropertyField(paintCompute); EditorGUILayout.Space(5f); brush.radious = EditorGUILayout.FloatField("Radious", brush.radious); if (SubstanceTable.substances == null) { SubstanceTable.Init(); } EditorGUILayout.LabelField("Density", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); brush.dPaintStyle = (Brush.DensnityPaintStyle)EditorGUILayout.EnumPopup("Paint Style", brush.dPaintStyle); brush.set = EditorGUILayout.Slider("Strength", brush.set, brush.dPaintStyle == Brush.DensnityPaintStyle.Set ? 0.0f : -1.0f, 1.0f); brush.smoothType = (Brush.SmoothType)EditorGUILayout.EnumPopup("Smooth Type", brush.smoothType); brush.smooth = EditorGUILayout.FloatField("Smooth", brush.smooth); RenderBrushImage(EditorGUI.EndChangeCheck()); EditorGUILayout.LabelField("Substance", EditorStyles.boldLabel); brush.changeSubstance = EditorGUILayout.Toggle("change", brush.changeSubstance); brush.substance = EditorGUILayout.IntField("substance", brush.substance); if (brush.substance < 1) { brush.substance = 1; } if (brush.substance >= SubstanceTable.substances.Count) { brush.substance = SubstanceTable.substances.Count - 1; } SubstanceEditorWindow.DrawSubstance(brush.substance); serializedObject.ApplyModifiedProperties(); }
private void Start() { if (SubstanceTable.substances == null) { SubstanceTable.Init(); } LoadFromFile(); }
void StartSculpting() { if (mesh.brush.MCMesh == null) { mesh.brush.MCMesh = mesh; } if (SubstanceTable.substances == null) { SubstanceTable.Init(); } sculpt = true; Undo.RecordObject(mesh.gameObject, "Start Sculpting"); }
public void Init() { if (SubstanceTable.substances == null) { SubstanceTable.Init(); } state = new SubstanceState[SubstanceTable.substances.Count]; curves = new Curve[SubstanceTable.substances.Count]; for (int i = 0; i < curves.Length; i++) { curves[i] = Curve.line; curves[i].color = SubstanceTable.substances[i].color; } heightCurve = Curve.line; }
public void Paint(Vector3 point) { if (SubstanceTable.substances == null) { SubstanceTable.Init(); } if (MCMesh.chunks == null) { MCMesh.chunks = MCMesh.GetComponentsInChildren <Chunk>(); } float radiousSqr = radious * radious; foreach (Chunk c in MCMesh.chunks) { if (SqrDistanceFrom(c, point) <= radiousSqr) { c.Paint(this, point); } } }
public override void OnInspectorGUI() { GUIStyle left = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleLeft }; GUIStyle center = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }; GUIStyle right = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleRight }; if (SubstanceTable.substances == null) { SubstanceTable.Init(); } if (generator.state == null || generator.curves == null) { generator.Init(); } if (cList) { if (GUILayout.Button("Hide Curve List")) { cList = false; } EditorGUILayout.Space(3f); EditorGUILayout.LabelField("Height Curve", EditorStyles.boldLabel); DrawHeightCurveState(); EditorGUILayout.LabelField("Substances", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("color", "color of curve on graph"), GUILayout.Width(40f)); EditorGUILayout.LabelField("name", GUILayout.Width(Screen.width * 0.2f)); EditorGUILayout.LabelField(new GUIContent("zero", "these substances are not generated"), left, GUILayout.Width(Screen.width * 0.15f)); EditorGUILayout.LabelField(new GUIContent("shown", "these substances are generated and displayed in inspector"), center, GUILayout.Width(Screen.width * 0.15f)); EditorGUILayout.LabelField(new GUIContent("hidden", "these substances are generated, but not displayed in insector"), right, GUILayout.Width(Screen.width * 0.15f)); GUILayout.EndHorizontal(); subPos = GUILayout.BeginScrollView(subPos, GUILayout.Height(80f)); EditorGUILayout.Space(5f); for (int i = 1; i < generator.state.Length; i++) { DrawSubstanceState(i); } GUILayout.EndScrollView(); } else { if (GUILayout.Button("Show Curve List")) { cList = true; } } GUILayout.Space(5f); DrawCurvePanel(); GUILayout.Space(5f); if (GUILayout.Button("Reset")) { generator.ResetAll(); } }
private void OnGUI() { float cHeight = 85f + fieldHeight * 3f; EditorGUILayout.LabelField("Substance Inspector", EditorStyles.boldLabel, GUILayout.Height(fieldHeight)); EditorGUILayout.Space(5f); if (boxState == SubstanceBoxState.New) { DrawSubstanceEditor(); if (GUILayout.Button("Add Substance", GUILayout.Height(fieldHeight))) { SubstanceTable.Add(modifiedSubstance); boxState = SubstanceBoxState.None; } if (GUILayout.Button("Discard", GUILayout.Height(fieldHeight))) { boxState = SubstanceBoxState.None; modifiedSubstance = new Substance(); } cHeight += 4f * fieldHeight; } else if (boxState == SubstanceBoxState.Inspect) { DrawSubstanceEditor(); if (GUILayout.Button("Save", GUILayout.Height(fieldHeight))) { SubstanceTable.substances[inspectedSubstance] = modifiedSubstance; boxState = SubstanceBoxState.None; } if (GUILayout.Button("Remove", GUILayout.Height(fieldHeight))) { SubstanceTable.Remove(modifiedSubstance); boxState = SubstanceBoxState.None; } if (GUILayout.Button("Discard", GUILayout.Height(fieldHeight))) { modifiedSubstance = new Substance(); boxState = SubstanceBoxState.None; } cHeight += 5f * fieldHeight; } else { if (GUILayout.Button("Create Substance", GUILayout.Height(fieldHeight))) { boxState = SubstanceBoxState.New; modifiedSubstance = new Substance(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Inspect Substance Of Index", GUILayout.Height(fieldHeight))) { if (inspectedSubstance > 0 && inspectedSubstance < SubstanceTable.substances.Count) { boxState = SubstanceBoxState.Inspect; modifiedSubstance = new Substance(SubstanceTable.substances[inspectedSubstance]); } else { Debug.LogWarning("Inspected Substance Index must be greater than zero and less than substances count"); } } inspectedSubstance = EditorGUILayout.IntField(inspectedSubstance, GUILayout.Height(fieldHeight)); GUILayout.EndHorizontal(); if (inspectedSubstance > 0 && inspectedSubstance < SubstanceTable.substances.Count) { EditorGUILayout.LabelField(SubstanceTable.substances[inspectedSubstance].name, GUILayout.Height(fieldHeight)); } else { EditorGUILayout.LabelField("", GUILayout.Height(fieldHeight)); } cHeight += 3f * fieldHeight; } EditorGUILayout.LabelField("Substance List", EditorStyles.boldLabel, GUILayout.Height(fieldHeight)); if (showSubstances) { if (GUILayout.Button("Hide substance list", GUILayout.Height(fieldHeight))) { showSubstances = false; } scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - cHeight)); for (int i = 0; i < SubstanceTable.substances.Count; i++) { DrawSubstance(i); } EditorGUILayout.EndScrollView(); } else { if (GUILayout.Button("Show substance list", GUILayout.Height(fieldHeight))) { showSubstances = true; } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Update", GUILayout.Height(25f))) { SubstanceTable.Init(); } if (GUILayout.Button("Save To File", GUILayout.Height(25f))) { SubstanceTable.Save(); } }
public static void Initialize() { GetWindow(typeof(SubstanceEditorWindow), false, "Substances"); SubstanceTable.Init(); }
public void Generate() { if (SubstanceTable.substances == null) { SubstanceTable.Init(); } pointsPerAxis = Mathf.FloorToInt(chunkSize / vertexDistance) + 1; if (exist) { ResetChunks(); } exist = true; densityGenerator.GenerateGradient(); for (int x = 0; x < gridSize.x; x++) { for (int y = 0; y < gridSize.y; y++) { for (int z = 0; z < gridSize.z; z++) { Transform chunk = Instantiate(chunkPrefab).transform; chunk.position = new Vector3(x * chunkSize, y * chunkSize, z * chunkSize); chunk.rotation = Quaternion.identity; chunk.parent = transform; Chunk c = chunk.GetComponent <Chunk>(); c.zeroBounds = new ZeroBounds(); c.MCmesh = this; if (bounded) { if (x == 0) { c.zeroBounds.xMin = true; } if (x == gridSize.x - 1) { c.zeroBounds.xMax = true; } if (y == 0) { c.zeroBounds.yMin = true; } if (y == gridSize.y - 1) { c.zeroBounds.yMax = true; } if (z == 0) { c.zeroBounds.zMin = true; } if (z == gridSize.z - 1) { c.zeroBounds.zMax = true; } } c.GenerateMesh(isoLevel, shading == Shading.Smooth); } } } chunks = GetComponentsInChildren <Chunk>(); densityGenerator.ReleaseBuffers(); }