public void DeleteGroup(TreeGroup g) { for (int i = g.nodes.Count - 1; i >= 0; i--) { this.DeleteNode(g.nodes[i], false); } if (g.GetType() == typeof(TreeGroupBranch)) { this.branchGroups = this.ArrayRemove(this.branchGroups, g as TreeGroupBranch); } else { if (g.GetType() == typeof(TreeGroupLeaf)) { this.leafGroups = this.ArrayRemove(this.leafGroups, g as TreeGroupLeaf); } } this.SetGroupParent(g, null); }
public TreeGroup DuplicateGroup(TreeGroup g) { TreeGroup treeGroup = this.AddGroup(this.GetGroup(g.parentGroupID), g.GetType()); this.CopyFields(g, treeGroup); treeGroup.childGroupIDs = new int[0]; treeGroup.nodeIDs = new int[0]; for (int i = 0; i < g.nodeIDs.Length; i++) { TreeNode node = this.GetNode(g.nodeIDs[i]); TreeNode treeNode = this.AddNode(treeGroup, this.GetNode(node.parentID)); this.CopyFields(node, treeNode); treeNode.groupID = treeGroup.uniqueID; } return(treeGroup); }
private void DrawHierachyNodes(TreeData treeData, List<HierachyNode> nodes, TreeGroup group, Vector2 offset, float alpha, float fade) { if (((this.dragNode != null) && this.isDragging) && (this.dragNode.group == group)) { alpha = 0.5f; fade = 0.75f; } Vector3 vector = new Vector3(0f, this.hierachyNodeSize.y * 0.5f, 0f); Vector3 vector2 = new Vector3(offset.x, offset.y); Handles.color = new Color(0f, 0f, 0f, 0.5f * alpha); if (EditorGUIUtility.isProSkin) { Handles.color = new Color(0.4f, 0.4f, 0.4f, 0.5f * alpha); } HierachyNode node = null; for (int i = 0; i < nodes.Count; i++) { if (group == nodes[i].group) { node = nodes[i]; break; } } if (node != null) { for (int j = 0; j < group.childGroupIDs.Length; j++) { TreeGroup group2 = treeData.GetGroup(group.childGroupIDs[j]); for (int m = 0; m < nodes.Count; m++) { if (nodes[m].group == group2) { Handles.DrawLine((node.pos + vector2) - vector, (nodes[m].pos + vector2) + vector); } } } Rect position = node.rect; position.x += offset.x; position.y += offset.y; int index = 0; if (node == this.dropNode) { index = 1; } else if (s_SelectedGroup == node.group) { if (s_SelectedNode != null) { index = 1; } else { index = 1; } } GUI.backgroundColor = new Color(1f, 1f, 1f, alpha); GUI.contentColor = new Color(1f, 1f, 1f, alpha); GUI.Label(position, GUIContent.none, styles.nodeBoxes[index]); Rect rect2 = new Rect((position.x + (position.width / 2f)) - 4f, position.y - 2f, 0f, 0f); Rect rect3 = new Rect((position.x + (position.width / 2f)) - 4f, (position.y + position.height) - 2f, 0f, 0f); Rect rect4 = new Rect(position.x + 1f, position.yMax - 36f, 32f, 32f); Rect rect5 = new Rect(position.xMax - 18f, position.yMax - 18f, 16f, 16f); Rect rect6 = new Rect(position.x, position.y, position.width - 2f, 16f); bool flag = true; int num5 = 0; GUIContent gUIContent = new GUIContent(); System.Type type = group.GetType(); if (type != typeof(TreeGroupBranch)) { if (type == typeof(TreeGroupLeaf)) { gUIContent = TreeEditorHelper.GetGUIContent("|Leaf Group"); num5 = 3; } else if (type == typeof(TreeGroupRoot)) { gUIContent = TreeEditorHelper.GetGUIContent("|Tree Root Node"); num5 = 4; flag = false; } } else { gUIContent = TreeEditorHelper.GetGUIContent("|Branch Group"); TreeGroupBranch branch = (TreeGroupBranch) group; switch (branch.geometryMode) { case TreeGroupBranch.GeometryMode.BranchFrond: num5 = 0; break; case TreeGroupBranch.GeometryMode.Branch: num5 = 1; break; case TreeGroupBranch.GeometryMode.Frond: num5 = 2; break; } } if (flag) { Rect hierachyNodeVisRect = this.GetHierachyNodeVisRect(position); GUIContent content = TreeEditorHelper.GetGUIContent("|Show / Hide Group"); content.image = styles.visibilityIcons[!group.visible ? 1 : 0].image; GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); if (GUI.Button(hierachyNodeVisRect, content, GUIStyle.none)) { group.visible = !group.visible; GUI.changed = true; } GUI.contentColor = Color.white; } gUIContent.image = styles.nodeIcons[num5].image; GUI.contentColor = new Color(1f, 1f, 1f, !group.visible ? 0.5f : 1f); if (GUI.Button(rect4, gUIContent, GUIStyle.none) || (this.dragNode == node)) { TreeGroup group3 = s_SelectedGroup; this.SelectGroup(group); if (group3 == s_SelectedGroup) { Tree target = base.target as Tree; this.FrameSelected(target); } } GUI.contentColor = Color.white; if (group.CanHaveSubGroups()) { GUI.Label(rect2, GUIContent.none, styles.pinLabel); } if (flag) { GUIContent content3 = TreeEditorHelper.GetGUIContent("|Node Count"); content3.text = group.nodeIDs.Length.ToString(); GUI.Label(rect6, content3, styles.nodeLabelTop); if (this.m_TreeEditorHelper.NodeHasWrongMaterial(group)) { GUI.DrawTexture(rect5, ConsoleWindow.iconErrorSmall); } else if (group.lockFlags != 0) { GUI.DrawTexture(rect5, styles.warningIcon.image); } GUI.Label(rect3, GUIContent.none, styles.pinLabel); } for (int k = 0; k < group.childGroupIDs.Length; k++) { TreeGroup group4 = treeData.GetGroup(group.childGroupIDs[k]); this.DrawHierachyNodes(treeData, nodes, group4, offset, alpha * fade, fade); } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; } }
public static List <float> GetAdaptiveSamples(TreeGroup group, TreeNode node, float adaptiveQuality) { List <float> list = new List <float>(); if (node.spline == null) { return(list); } float num = 1f - node.capRange; SplineNode[] array = node.spline.GetNodes(); for (int i = 0; i < array.Length; i++) { if (array[i].time >= node.breakOffset) { list.Add(node.breakOffset); break; } if (array[i].time > num) { list.Add(num); break; } list.Add(array[i].time); } list.Sort(); if (list.Count < 2) { return(list); } float num2 = 1f; if (group.GetType() == typeof(TreeGroupBranch)) { num2 = ((TreeGroupBranch)group).radius; } float num3 = Mathf.Lerp(0.999f, 0.99999f, adaptiveQuality); float num4 = Mathf.Lerp(0.5f, 0.985f, adaptiveQuality); float num5 = Mathf.Lerp(0.3f * num2, 0.1f * num2, adaptiveQuality); int num6 = 200; int j = 0; while (j < list.Count - 1) { for (int k = j; k < list.Count - 1; k++) { Quaternion rotationAtTime = node.spline.GetRotationAtTime(list[k]); Quaternion rotationAtTime2 = node.spline.GetRotationAtTime(list[k + 1]); Vector3 lhs = rotationAtTime * Vector3.up; Vector3 rhs = rotationAtTime2 * Vector3.up; Vector3 lhs2 = rotationAtTime * Vector3.right; Vector3 rhs2 = rotationAtTime2 * Vector3.right; Vector3 lhs3 = rotationAtTime * Vector3.forward; Vector3 rhs3 = rotationAtTime2 * Vector3.forward; float radiusAtTime = group.GetRadiusAtTime(node, list[k], true); float radiusAtTime2 = group.GetRadiusAtTime(node, list[k + 1], true); bool flag = false; if (Vector3.Dot(lhs, rhs) < num4) { flag = true; } if (Vector3.Dot(lhs2, rhs2) < num4) { flag = true; } if (Vector3.Dot(lhs3, rhs3) < num4) { flag = true; } if (Mathf.Abs(radiusAtTime - radiusAtTime2) > num5) { flag = true; } if (flag) { num6--; if (num6 > 0) { float item = (list[k] + list[k + 1]) * 0.5f; list.Insert(k + 1, item); break; } } j = k + 1; } } for (int l = 0; l < list.Count - 2; l++) { Vector3 positionAtTime = node.spline.GetPositionAtTime(list[l]); Vector3 positionAtTime2 = node.spline.GetPositionAtTime(list[l + 1]); Vector3 positionAtTime3 = node.spline.GetPositionAtTime(list[l + 2]); float radiusAtTime3 = group.GetRadiusAtTime(node, list[l], true); float radiusAtTime4 = group.GetRadiusAtTime(node, list[l + 1], true); float radiusAtTime5 = group.GetRadiusAtTime(node, list[l + 2], true); Vector3 normalized = (positionAtTime2 - positionAtTime).normalized; Vector3 normalized2 = (positionAtTime3 - positionAtTime).normalized; bool flag2 = false; if (Vector3.Dot(normalized, normalized2) >= num3) { flag2 = true; } if (Mathf.Abs(radiusAtTime3 - radiusAtTime4) > num5) { flag2 = false; } if (Mathf.Abs(radiusAtTime4 - radiusAtTime5) > num5) { flag2 = false; } if (flag2) { list.RemoveAt(l + 1); l--; } } if (node.capRange > 0f) { int num7 = 1 + Mathf.CeilToInt(node.capRange * 16f * adaptiveQuality); for (int m = 0; m < num7; m++) { float f = (float)(m + 1) / (float)num7 * 3.14159274f * 0.5f; float num8 = Mathf.Sin(f); float num9 = num + node.capRange * num8; if (num9 < node.breakOffset) { list.Add(num9); } } list.Sort(); } if (1f <= node.breakOffset) { if (list[list.Count - 1] < 1f) { list.Add(1f); } else { list[list.Count - 1] = 1f; } } return(list); }
public static List<float> GetAdaptiveSamples(TreeGroup group, TreeNode node, float adaptiveQuality) { List<float> list = new List<float>(); if (node.spline == null) { return list; } float num = 1f - node.capRange; SplineNode[] array = node.spline.GetNodes(); for (int i = 0; i < array.Length; i++) { if (array[i].time >= node.breakOffset) { list.Add(node.breakOffset); break; } if (array[i].time > num) { list.Add(num); break; } list.Add(array[i].time); } list.Sort(); if (list.Count < 2) { return list; } float num2 = 1f; if (group.GetType() == typeof(TreeGroupBranch)) { num2 = ((TreeGroupBranch)group).radius; } float num3 = Mathf.Lerp(0.999f, 0.99999f, adaptiveQuality); float num4 = Mathf.Lerp(0.5f, 0.985f, adaptiveQuality); float num5 = Mathf.Lerp(0.3f * num2, 0.1f * num2, adaptiveQuality); int num6 = 200; int j = 0; while (j < list.Count - 1) { for (int k = j; k < list.Count - 1; k++) { Quaternion rotationAtTime = node.spline.GetRotationAtTime(list[k]); Quaternion rotationAtTime2 = node.spline.GetRotationAtTime(list[k + 1]); Vector3 lhs = rotationAtTime * Vector3.up; Vector3 rhs = rotationAtTime2 * Vector3.up; Vector3 lhs2 = rotationAtTime * Vector3.right; Vector3 rhs2 = rotationAtTime2 * Vector3.right; Vector3 lhs3 = rotationAtTime * Vector3.forward; Vector3 rhs3 = rotationAtTime2 * Vector3.forward; float radiusAtTime = group.GetRadiusAtTime(node, list[k], true); float radiusAtTime2 = group.GetRadiusAtTime(node, list[k + 1], true); bool flag = false; if (Vector3.Dot(lhs, rhs) < num4) { flag = true; } if (Vector3.Dot(lhs2, rhs2) < num4) { flag = true; } if (Vector3.Dot(lhs3, rhs3) < num4) { flag = true; } if (Mathf.Abs(radiusAtTime - radiusAtTime2) > num5) { flag = true; } if (flag) { num6--; if (num6 > 0) { float item = (list[k] + list[k + 1]) * 0.5f; list.Insert(k + 1, item); break; } } j = k + 1; } } for (int l = 0; l < list.Count - 2; l++) { Vector3 positionAtTime = node.spline.GetPositionAtTime(list[l]); Vector3 positionAtTime2 = node.spline.GetPositionAtTime(list[l + 1]); Vector3 positionAtTime3 = node.spline.GetPositionAtTime(list[l + 2]); float radiusAtTime3 = group.GetRadiusAtTime(node, list[l], true); float radiusAtTime4 = group.GetRadiusAtTime(node, list[l + 1], true); float radiusAtTime5 = group.GetRadiusAtTime(node, list[l + 2], true); Vector3 normalized = (positionAtTime2 - positionAtTime).normalized; Vector3 normalized2 = (positionAtTime3 - positionAtTime).normalized; bool flag2 = false; if (Vector3.Dot(normalized, normalized2) >= num3) { flag2 = true; } if (Mathf.Abs(radiusAtTime3 - radiusAtTime4) > num5) { flag2 = false; } if (Mathf.Abs(radiusAtTime4 - radiusAtTime5) > num5) { flag2 = false; } if (flag2) { list.RemoveAt(l + 1); l--; } } if (node.capRange > 0f) { int num7 = 1 + Mathf.CeilToInt(node.capRange * 16f * adaptiveQuality); for (int m = 0; m < num7; m++) { float f = (float)(m + 1) / (float)num7 * 3.14159274f * 0.5f; float num8 = Mathf.Sin(f); float num9 = num + node.capRange * num8; if (num9 < node.breakOffset) { list.Add(num9); } } list.Sort(); } if (1f <= node.breakOffset) { if (list[list.Count - 1] < 1f) { list.Add(1f); } else { list[list.Count - 1] = 1f; } } return list; }
// // Updates distribution.. // public void UpdateDistribution(bool completeUpdate, bool updateSubGroups) { Profiler.BeginSample("UpdateDistribution"); // Seed Random.InitState(_internalSeed); // Distribution.. if (completeUpdate) { // needed for sampling distribution curve in non-random modes float distributionSum = 0.0f; float[] distributionSamples = new float[100]; float distributionStep = 1.0f / distributionSamples.Length; float distributionDivisor = (float)distributionSamples.Length - 1; // sample distribution curve at X locations and store values in distributionSamples // store sum of samples in distributionSum for (int i = 0; i < distributionSamples.Length; i++) { float j = i / distributionDivisor; distributionSamples[i] = Mathf.Clamp01(distributionCurve.Evaluate(j)); distributionSum += distributionSamples[i]; } for (int i = 0; i < nodes.Count; i++) { TreeNode node = nodes[i]; if (lockFlags == 0) { if ((i == 0) && (nodes.Count == 1) && ((parentGroup == null || parentGroup.GetType() == typeof(TreeGroupRoot)))) { // first child of the root is always centered.. node.offset = 0.0f; node.baseAngle = 0.0f; node.pitch = 0.0f; node.scale = Mathf.Clamp01(distributionScaleCurve.Evaluate(node.offset)) * distributionScale + (1.0f - distributionScale); } else { // Sum up number of nodes attached to the same parent as this node // and find the index of this node in relation to it's parent int nodeLocalIndex = 0; int nodeLocalCount = 0; for (int j = 0; j < nodes.Count; j++) { if (nodes[j].parentID == node.parentID) { if (i == j) { nodeLocalIndex = nodeLocalCount; } nodeLocalCount++; } } switch (distributionMode) { case DistributionMode.Random: { // create a random value between 0 and distributionSum float offset = 0.0f; float weight = 0.0f; // hack, since the random values seem to be clustered - investigate! for (int j = 0; j < 5; j++) { weight = Random.value * distributionSum; } // go through distributionSamples and subtract each from weight until // weight <= 0, which means we've hit a good spot for (int j = 0; j < distributionSamples.Length; j++) { offset = j / distributionDivisor; weight -= distributionSamples[j]; if (weight <= 0.0f) { break; } } // set the offset to the last sampled point node.baseAngle = Random.value * 360.0f; node.offset = offset; } break; case DistributionMode.Alternate: { // sample along distribution curve until we reach the next 'good' offset float offset = ComputeOffset(nodeLocalIndex, nodeLocalCount, distributionSum, distributionStep); float angle = 180.0f * nodeLocalIndex; node.baseAngle = angle + (offset * distributionTwirl * 360.0f); node.offset = offset; } break; case DistributionMode.Opposite: { // // sample along distribution curve until we reach the next 'good' offset float offset = ComputeOffset(nodeLocalIndex / 2, nodeLocalCount / 2, distributionSum, distributionStep); float angle = 90.0f * (nodeLocalIndex / 2) + ((nodeLocalIndex % 2) * 180.0f); node.baseAngle = angle + (offset * distributionTwirl * 360.0f); node.offset = offset; } break; case DistributionMode.Whorled: { int clusterCount = distributionNodes; int clusterIndex = nodeLocalIndex % clusterCount; int clusterOffset = nodeLocalIndex / clusterCount; float offset = ComputeOffset(nodeLocalIndex / clusterCount, nodeLocalCount / clusterCount, distributionSum, distributionStep); float angle = ((360.0f / clusterCount) * clusterIndex) + ((180.0f / clusterCount) * clusterOffset); node.baseAngle = angle + (offset * distributionTwirl * 360.0f); node.offset = offset; } break; } } } } } // // Distribution properties that do not change position for (int n = 0; n < nodes.Count; n++) { TreeNode node = nodes[n]; // Update individual node visibility, which has nothing to do with group visibility.. if (node.parent == null) { node.visible = true; } else { node.visible = node.parent.visible; if (node.offset > node.parent.breakOffset) { node.visible = false; } } if (lockFlags == 0) { node.angle = node.baseAngle; node.pitch = Mathf.Clamp(distributionPitchCurve.Evaluate(node.offset), -1.0f, 1.0f) * -75.0f * distributionPitch; } else { node.angle = node.baseAngle; } node.scale = Mathf.Clamp01(distributionScaleCurve.Evaluate(node.offset)) * distributionScale + (1.0f - distributionScale); } // Adjust animation props, as they rely on distribution if ((parentGroup == null) || (parentGroup.GetType() == typeof(TreeGroupRoot))) { // no parent .. or attached to the root for (int i = 0; i < nodes.Count; i++) { nodes[i].animSeed = 0.0f; } } else { for (int i = 0; i < nodes.Count; i++) { if (nodes[i].parent == null) { nodes[i].animSeed = 0.0f; } else { if (nodes[i].parent.animSeed == 0.0f) { // new seed nodes[i].animSeed = ((((float)nodes[i].seed) / 9.78f) % 1) + 0.001f; } else { // copy seed nodes[i].animSeed = nodes[i].parent.animSeed; } } } } if (updateSubGroups) { // update sub-groups for (int i = 0; i < childGroups.Count; i++) { childGroups[i].UpdateDistribution(completeUpdate, updateSubGroups); } } Profiler.EndSample(); // UpdateDistribution }
public TreeGroup DuplicateGroup(TreeGroup g) { TreeGroup treeGroup = this.AddGroup(this.GetGroup(g.parentGroupID), g.GetType()); this.CopyFields(g, treeGroup); treeGroup.childGroupIDs = new int[0]; treeGroup.nodeIDs = new int[0]; for (int i = 0; i < g.nodeIDs.Length; i++) { TreeNode node = this.GetNode(g.nodeIDs[i]); TreeNode treeNode = this.AddNode(treeGroup, this.GetNode(node.parentID)); this.CopyFields(node, treeNode); treeNode.groupID = treeGroup.uniqueID; } return treeGroup; }
public static List<float> GetAdaptiveSamples(TreeGroup group, TreeNode node, float adaptiveQuality) { List<float> list = new List<float>(); if (node.spline != null) { float item = 1f - node.capRange; SplineNode[] nodes = node.spline.GetNodes(); for (int i = 0; i < nodes.Length; i++) { if (nodes[i].time >= node.breakOffset) { list.Add(node.breakOffset); break; } if (nodes[i].time > item) { list.Add(item); break; } list.Add(nodes[i].time); } list.Sort(); if (list.Count < 2) { return list; } float radius = 1f; if (group.GetType() == typeof(TreeGroupBranch)) { radius = ((TreeGroupBranch) group).radius; } float num4 = Mathf.Lerp(0.999f, 0.99999f, adaptiveQuality); float num5 = Mathf.Lerp(0.5f, 0.985f, adaptiveQuality); float num6 = Mathf.Lerp(0.3f * radius, 0.1f * radius, adaptiveQuality); int num7 = 200; int num8 = 0; while (num8 < (list.Count - 1)) { for (int k = num8; k < (list.Count - 1); k++) { Quaternion rotationAtTime = node.spline.GetRotationAtTime(list[k]); Quaternion quaternion2 = node.spline.GetRotationAtTime(list[k + 1]); Vector3 lhs = (Vector3) (rotationAtTime * Vector3.up); Vector3 rhs = (Vector3) (quaternion2 * Vector3.up); Vector3 vector3 = (Vector3) (rotationAtTime * Vector3.right); Vector3 vector4 = (Vector3) (quaternion2 * Vector3.right); Vector3 vector5 = (Vector3) (rotationAtTime * Vector3.forward); Vector3 vector6 = (Vector3) (quaternion2 * Vector3.forward); float num10 = group.GetRadiusAtTime(node, list[k], true); float num11 = group.GetRadiusAtTime(node, list[k + 1], true); bool flag = false; if (Vector3.Dot(lhs, rhs) < num5) { flag = true; } if (Vector3.Dot(vector3, vector4) < num5) { flag = true; } if (Vector3.Dot(vector5, vector6) < num5) { flag = true; } if (Mathf.Abs((float) (num10 - num11)) > num6) { flag = true; } if (flag) { num7--; if (num7 > 0) { float num12 = (list[k] + list[k + 1]) * 0.5f; list.Insert(k + 1, num12); continue; } } num8 = k + 1; } } for (int j = 0; j < (list.Count - 2); j++) { Vector3 positionAtTime = node.spline.GetPositionAtTime(list[j]); Vector3 vector8 = node.spline.GetPositionAtTime(list[j + 1]); Vector3 vector9 = node.spline.GetPositionAtTime(list[j + 2]); float num14 = group.GetRadiusAtTime(node, list[j], true); float num15 = group.GetRadiusAtTime(node, list[j + 1], true); float num16 = group.GetRadiusAtTime(node, list[j + 2], true); Vector3 vector12 = vector8 - positionAtTime; Vector3 normalized = vector12.normalized; Vector3 vector13 = vector9 - positionAtTime; Vector3 vector11 = vector13.normalized; bool flag2 = false; if (Vector3.Dot(normalized, vector11) >= num4) { flag2 = true; } if (Mathf.Abs((float) (num14 - num15)) > num6) { flag2 = false; } if (Mathf.Abs((float) (num15 - num16)) > num6) { flag2 = false; } if (flag2) { list.RemoveAt(j + 1); j--; } } if (node.capRange > 0f) { int num17 = 1 + Mathf.CeilToInt((node.capRange * 16f) * adaptiveQuality); for (int m = 0; m < num17; m++) { float f = ((((float) (m + 1)) / ((float) num17)) * 3.141593f) * 0.5f; float num20 = Mathf.Sin(f); float num21 = item + (node.capRange * num20); if (num21 < node.breakOffset) { list.Add(num21); } } list.Sort(); } if (1f <= node.breakOffset) { if (list[list.Count - 1] < 1f) { list.Add(1f); return list; } list[list.Count - 1] = 1f; } } return list; }
public TreeGroup DuplicateGroup(TreeGroup g) { TreeGroup group = this.AddGroup(this.GetGroup(g.parentGroupID), g.GetType()); this.CopyFields(g, group); group.childGroupIDs = new int[0]; group.nodeIDs = new int[0]; for (int i = 0; i < g.nodeIDs.Length; i++) { TreeNode n = this.GetNode(g.nodeIDs[i]); TreeNode node2 = this.AddNode(group, this.GetNode(n.parentID)); this.CopyFields(n, node2); node2.groupID = group.uniqueID; } return group; }
private void DrawHierachyNodes(TreeData treeData, List<TreeEditor.HierachyNode> nodes, TreeGroup group, Vector2 offset, float alpha, float fade) { if (this.dragNode != null && this.isDragging && this.dragNode.group == group) { alpha = 0.5f; fade = 0.75f; } Vector3 b = new Vector3(0f, this.hierachyNodeSize.y * 0.5f, 0f); Vector3 b2 = new Vector3(offset.x, offset.y); Handles.color = new Color(0f, 0f, 0f, 0.5f * alpha); if (EditorGUIUtility.isProSkin) { Handles.color = new Color(0.4f, 0.4f, 0.4f, 0.5f * alpha); } TreeEditor.HierachyNode hierachyNode = null; for (int i = 0; i < nodes.Count; i++) { if (group == nodes[i].group) { hierachyNode = nodes[i]; break; } } if (hierachyNode == null) { return; } for (int j = 0; j < group.childGroupIDs.Length; j++) { TreeGroup group2 = treeData.GetGroup(group.childGroupIDs[j]); for (int k = 0; k < nodes.Count; k++) { if (nodes[k].group == group2) { Handles.DrawLine(hierachyNode.pos + b2 - b, nodes[k].pos + b2 + b); } } } Rect rect = hierachyNode.rect; rect.x += offset.x; rect.y += offset.y; int num = 0; if (hierachyNode == this.dropNode) { num = 1; } else { if (TreeEditor.s_SelectedGroup == hierachyNode.group) { if (TreeEditor.s_SelectedNode != null) { num = 1; } else { num = 1; } } } GUI.backgroundColor = new Color(1f, 1f, 1f, alpha); GUI.contentColor = new Color(1f, 1f, 1f, alpha); GUI.Label(rect, GUIContent.none, TreeEditor.styles.nodeBoxes[num]); Rect position = new Rect(rect.x + rect.width / 2f - 4f, rect.y - 2f, 0f, 0f); Rect position2 = new Rect(rect.x + rect.width / 2f - 4f, rect.y + rect.height - 2f, 0f, 0f); Rect position3 = new Rect(rect.x + 1f, rect.yMax - 36f, 32f, 32f); Rect position4 = new Rect(rect.xMax - 18f, rect.yMax - 18f, 16f, 16f); Rect position5 = new Rect(rect.x, rect.y, rect.width - 2f, 16f); bool flag = true; int num2 = 0; GUIContent gUIContent = new GUIContent(); Type type = group.GetType(); if (type == typeof(TreeGroupBranch)) { gUIContent = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.TreeGroupBranch"); TreeGroupBranch treeGroupBranch = (TreeGroupBranch)group; switch (treeGroupBranch.geometryMode) { case TreeGroupBranch.GeometryMode.Branch: num2 = 1; break; case TreeGroupBranch.GeometryMode.BranchFrond: num2 = 0; break; case TreeGroupBranch.GeometryMode.Frond: num2 = 2; break; } } else { if (type == typeof(TreeGroupLeaf)) { gUIContent = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.TreeGroupLeaf"); num2 = 3; } else { if (type == typeof(TreeGroupRoot)) { gUIContent = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.TreeGroupRoot"); num2 = 4; flag = false; } } } if (flag) { Rect hierachyNodeVisRect = this.GetHierachyNodeVisRect(rect); GUIContent gUIContent2 = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.ShowHide"); gUIContent2.image = TreeEditor.styles.visibilityIcons[(!group.visible) ? 1 : 0].image; GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); if (GUI.Button(hierachyNodeVisRect, gUIContent2, GUIStyle.none)) { group.visible = !group.visible; GUI.changed = true; } GUI.contentColor = Color.white; } gUIContent.image = TreeEditor.styles.nodeIcons[num2].image; GUI.contentColor = new Color(1f, 1f, 1f, (!group.visible) ? 0.5f : 1f); if (GUI.Button(position3, gUIContent, GUIStyle.none) || this.dragNode == hierachyNode) { TreeGroup treeGroup = TreeEditor.s_SelectedGroup; this.SelectGroup(group); if (treeGroup == TreeEditor.s_SelectedGroup) { Tree tree = this.target as Tree; this.FrameSelected(tree); } } GUI.contentColor = Color.white; if (group.CanHaveSubGroups()) { GUI.Label(position, GUIContent.none, TreeEditor.styles.pinLabel); } if (flag) { GUIContent gUIContent3 = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.NodeCount"); gUIContent3.text = group.nodeIDs.Length.ToString(); GUI.Label(position5, gUIContent3, TreeEditor.styles.nodeLabelTop); if (this.m_TreeEditorHelper.NodeHasWrongMaterial(group)) { GUI.DrawTexture(position4, ConsoleWindow.iconErrorSmall); } else { if (group.lockFlags != 0) { GUI.DrawTexture(position4, TreeEditor.styles.warningIcon.image); } } GUI.Label(position2, GUIContent.none, TreeEditor.styles.pinLabel); } for (int l = 0; l < group.childGroupIDs.Length; l++) { TreeGroup group3 = treeData.GetGroup(group.childGroupIDs[l]); this.DrawHierachyNodes(treeData, nodes, group3, offset, alpha * fade, fade); } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; }
public void InspectorAnimation(TreeData treeData, TreeGroup group) { if (group == null) { return; } this.PrepareSpacing(false); string str = "TreeEditor." + group.GetType().Name + "."; group.animationPrimary = this.GUISlider(TreeEditor.PropertyType.Normal, str + "MainWind", group.animationPrimary, 0f, 1f, false); if (treeData.GetGroup(group.parentGroupID) != treeData.root) { group.animationSecondary = this.GUISlider(TreeEditor.PropertyType.Normal, str + "MainTurbulence", group.animationSecondary, 0f, 1f, false); } GUI.enabled = true; if (!(group is TreeGroupBranch) || (group as TreeGroupBranch).geometryMode != TreeGroupBranch.GeometryMode.Branch) { group.animationEdge = this.GUISlider(TreeEditor.PropertyType.Normal, str + "EdgeTurbulence", group.animationEdge, 0f, 1f, false); } this.GUIPropBegin(); if (GUILayout.Button(TreeEditorHelper.GetGUIContent("TreeEditor.WindZone.Create"), new GUILayoutOption[0])) { TreeEditor.CreateDefaultWindZone(); } this.GUIPropEnd(); }
public void InspectorDistribution(TreeData treeData, TreeGroup group) { if (group == null) { return; } this.PrepareSpacing(true); bool enabled = true; if (group.lockFlags != 0) { enabled = false; } string str = "TreeEditor." + group.GetType().Name + "."; GUI.enabled = enabled; int num = group.seed; group.seed = this.GUIIntSlider(TreeEditor.PropertyType.Normal, str + "GroupSeed", group.seed, 0, 999999, false); if (group.seed != num) { treeData.UpdateSeed(group.uniqueID); } num = group.distributionFrequency; group.distributionFrequency = this.GUIIntSlider(TreeEditor.PropertyType.FullUndo, str + "Frequency", group.distributionFrequency, 1, 100, false); if (group.distributionFrequency != num) { treeData.UpdateFrequency(group.uniqueID); } string[] optionIDs = new string[] { "Random", "Alternate", "Opposite", "Whorled" }; num = (int)group.distributionMode; group.distributionMode = (TreeGroup.DistributionMode)this.GUIPopup(TreeEditor.PropertyType.Normal, str + "DistributionMode", "TreeEditor.DistributionModeOption", optionIDs, (int)group.distributionMode, true); if (group.distributionMode != (TreeGroup.DistributionMode)num) { treeData.UpdateDistribution(group.uniqueID); } AnimationCurve animationCurve = group.distributionCurve; if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesA)) { group.distributionCurve = animationCurve; treeData.UpdateDistribution(group.uniqueID); } if (group.distributionMode != TreeGroup.DistributionMode.Random) { float distributionTwirl = group.distributionTwirl; group.distributionTwirl = this.GUISlider(TreeEditor.PropertyType.Normal, str + "Twirl", group.distributionTwirl, -1f, 1f, false); if (group.distributionTwirl != distributionTwirl) { treeData.UpdateDistribution(group.uniqueID); } } if (group.distributionMode == TreeGroup.DistributionMode.Whorled) { num = group.distributionNodes; group.distributionNodes = this.GUIIntSlider(TreeEditor.PropertyType.Normal, str + "WhorledStep", group.distributionNodes, 1, 21, false); if (group.distributionNodes != num) { treeData.UpdateDistribution(group.uniqueID); } } group.distributionScale = this.GUISlider(TreeEditor.PropertyType.Normal, str + "GrowthScale", group.distributionScale, 0f, 1f, true); animationCurve = group.distributionScaleCurve; if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesA)) { group.distributionScaleCurve = animationCurve; } group.distributionPitch = this.GUISlider(TreeEditor.PropertyType.Normal, str + "GrowthAngle", group.distributionPitch, 0f, 1f, true); animationCurve = group.distributionPitchCurve; if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesB)) { group.distributionPitchCurve = animationCurve; } GUI.enabled = true; EditorGUILayout.Space(); }