Beispiel #1
0
 private TreeGroupLeaf[] ArrayAdd(TreeGroupLeaf[] array, TreeGroupLeaf value)
 {
     return(new List <TreeGroupLeaf>(array)
     {
         value
     }.ToArray());
 }
Beispiel #2
0
        private TreeGroupLeaf[] ArrayRemove(TreeGroupLeaf[] array, TreeGroupLeaf value)
        {
            List <TreeGroupLeaf> list = new List <TreeGroupLeaf>(array);

            list.Remove(value);
            return(list.ToArray());
        }
Beispiel #3
0
        public TreeGroup AddGroup(TreeGroup parent, Type type)
        {
            TreeGroup treeGroup;

            if (type == typeof(TreeGroupBranch))
            {
                treeGroup         = new TreeGroupBranch();
                this.branchGroups = this.ArrayAdd(this.branchGroups, treeGroup as TreeGroupBranch);
            }
            else
            {
                if (type != typeof(TreeGroupLeaf))
                {
                    return(null);
                }
                treeGroup       = new TreeGroupLeaf();
                this.leafGroups = this.ArrayAdd(this.leafGroups, treeGroup as TreeGroupLeaf);
            }
            treeGroup.uniqueID = this._uniqueID;
            this._uniqueID++;
            treeGroup.parentGroupID         = 0;
            treeGroup.distributionFrequency = 1;
            this.SetGroupParent(treeGroup, parent);
            return(treeGroup);
        }
Beispiel #4
0
 private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, TreeEditorHelper.NodeType nodeType)
 {
     if (group is TreeGroupBranch && nodeType == TreeEditorHelper.NodeType.BarkNode)
     {
         TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
         TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialBranch, shader);
         TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialBreak, shader);
         TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialFrond, shader);
     }
     else
     {
         if (group is TreeGroupLeaf && nodeType == TreeEditorHelper.NodeType.LeafNode)
         {
             TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
             TreeEditorHelper.ChangeShaderOnMaterial(treeGroupLeaf.materialLeaf, shader);
         }
     }
     int[] childGroupIDs = group.childGroupIDs;
     for (int i = 0; i < childGroupIDs.Length; i++)
     {
         int       id     = childGroupIDs[i];
         TreeGroup group2 = treeData.GetGroup(id);
         TreeEditorHelper.ChangeShaderOnMaterials(treeData, shader, group2, nodeType);
     }
 }
Beispiel #5
0
 private static void GetAllTreeShaders(TreeData treeData, List <string> barkShaders, List <string> leafShaders, TreeGroup group)
 {
     if (group is TreeGroupBranch)
     {
         TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
         TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialBranch, barkShaders, leafShaders);
         TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialBreak, barkShaders, leafShaders);
         TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialFrond, barkShaders, leafShaders);
     }
     else
     {
         if (group is TreeGroupLeaf)
         {
             TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
             TreeEditorHelper.AddShaderFromMaterial(treeGroupLeaf.materialLeaf, barkShaders, leafShaders);
         }
     }
     int[] childGroupIDs = group.childGroupIDs;
     for (int i = 0; i < childGroupIDs.Length; i++)
     {
         int       id     = childGroupIDs[i];
         TreeGroup group2 = treeData.GetGroup(id);
         TreeEditorHelper.GetAllTreeShaders(treeData, barkShaders, leafShaders, group2);
     }
 }
        public bool NodeHasWrongMaterial(TreeGroup group)
        {
            bool flag = false;

            if (group is TreeGroupBranch)
            {
                TreeGroupBranch branch = group as TreeGroupBranch;
                flag |= !IsMaterialCorrect(branch.materialBranch);
                flag |= !IsMaterialCorrect(branch.materialBreak);
                return(flag | !IsMaterialCorrect(branch.materialFrond));
            }
            if (group is TreeGroupLeaf)
            {
                TreeGroupLeaf leaf = group as TreeGroupLeaf;
                flag |= !IsMaterialCorrect(leaf.materialLeaf);
            }
            return(flag);
        }
        public bool NodeHasWrongMaterial(TreeGroup group)
        {
            bool result = false;

            if (group is TreeGroupBranch)
            {
                TreeGroupBranch tgb = group as TreeGroupBranch;
                result |= !IsMaterialCorrect(tgb.materialBranch);
                result |= !IsMaterialCorrect(tgb.materialBreak);
                result |= !IsMaterialCorrect(tgb.materialFrond);
            }
            else if (group is TreeGroupLeaf)
            {
                TreeGroupLeaf tgl = group as TreeGroupLeaf;
                result |= !IsMaterialCorrect(tgl.materialLeaf);
            }

            return(result);
        }
 private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, NodeType nodeType)
 {
     if ((group is TreeGroupBranch) && (nodeType == NodeType.BarkNode))
     {
         TreeGroupBranch branch = group as TreeGroupBranch;
         ChangeShaderOnMaterial(branch.materialBranch, shader);
         ChangeShaderOnMaterial(branch.materialBreak, shader);
         ChangeShaderOnMaterial(branch.materialFrond, shader);
     }
     else if ((group is TreeGroupLeaf) && (nodeType == NodeType.LeafNode))
     {
         TreeGroupLeaf leaf = group as TreeGroupLeaf;
         ChangeShaderOnMaterial(leaf.materialLeaf, shader);
     }
     foreach (int num in group.childGroupIDs)
     {
         TreeGroup group2 = treeData.GetGroup(num);
         ChangeShaderOnMaterials(treeData, shader, group2, nodeType);
     }
 }
 private static void GetAllTreeShaders(TreeData treeData, List <string> barkShaders, List <string> leafShaders, TreeGroup group)
 {
     if (group is TreeGroupBranch)
     {
         TreeGroupBranch branch = group as TreeGroupBranch;
         AddShaderFromMaterial(branch.materialBranch, barkShaders, leafShaders);
         AddShaderFromMaterial(branch.materialBreak, barkShaders, leafShaders);
         AddShaderFromMaterial(branch.materialFrond, barkShaders, leafShaders);
     }
     else if (group is TreeGroupLeaf)
     {
         TreeGroupLeaf leaf = group as TreeGroupLeaf;
         AddShaderFromMaterial(leaf.materialLeaf, barkShaders, leafShaders);
     }
     foreach (int num in group.childGroupIDs)
     {
         TreeGroup group2 = treeData.GetGroup(num);
         GetAllTreeShaders(treeData, barkShaders, leafShaders, group2);
     }
 }
        private static void GetAllTreeShaders(TreeData treeData, List <string> barkShaders, List <string> leafShaders, TreeGroup group)
        {
            if (group is TreeGroupBranch)
            {
                TreeGroupBranch tgb = group as TreeGroupBranch;
                AddShaderFromMaterial(tgb.materialBranch, barkShaders, leafShaders);
                AddShaderFromMaterial(tgb.materialBreak, barkShaders, leafShaders);
                AddShaderFromMaterial(tgb.materialFrond, barkShaders, leafShaders);
            }
            else if (group is TreeGroupLeaf)
            {
                TreeGroupLeaf tgl = group as TreeGroupLeaf;
                AddShaderFromMaterial(tgl.materialLeaf, barkShaders, leafShaders);
            }

            foreach (int id in group.childGroupIDs)
            {
                TreeGroup childGroup = treeData.GetGroup(id);
                GetAllTreeShaders(treeData, barkShaders, leafShaders, childGroup);
            }
        }
Beispiel #11
0
        public bool NodeHasWrongMaterial(TreeGroup group)
        {
            bool flag = false;

            if (group is TreeGroupBranch)
            {
                TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
                flag |= !TreeEditorHelper.IsMaterialCorrect(treeGroupBranch.materialBranch);
                flag |= !TreeEditorHelper.IsMaterialCorrect(treeGroupBranch.materialBreak);
                flag |= !TreeEditorHelper.IsMaterialCorrect(treeGroupBranch.materialFrond);
            }
            else
            {
                if (group is TreeGroupLeaf)
                {
                    TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
                    flag |= !TreeEditorHelper.IsMaterialCorrect(treeGroupLeaf.materialLeaf);
                }
            }
            return(flag);
        }
        private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, NodeType nodeType)
        {
            if (group is TreeGroupBranch && nodeType == NodeType.BarkNode)
            {
                TreeGroupBranch tgb = group as TreeGroupBranch;
                ChangeShaderOnMaterial(tgb.materialBranch, shader);
                ChangeShaderOnMaterial(tgb.materialBreak, shader);
                ChangeShaderOnMaterial(tgb.materialFrond, shader);
            }
            else if (group is TreeGroupLeaf && nodeType == NodeType.LeafNode)
            {
                TreeGroupLeaf tgl = group as TreeGroupLeaf;
                ChangeShaderOnMaterial(tgl.materialLeaf, shader);
            }

            foreach (int id in group.childGroupIDs)
            {
                TreeGroup childGroup = treeData.GetGroup(id);
                ChangeShaderOnMaterials(treeData, shader, childGroup, nodeType);
            }
        }
Beispiel #13
0
 public TreeGroup AddGroup(TreeGroup parent, System.Type type)
 {
     TreeGroup g = null;
     if (type == typeof(TreeGroupBranch))
     {
         g = new TreeGroupBranch();
         this.branchGroups = this.ArrayAdd(this.branchGroups, g as TreeGroupBranch);
     }
     else if (type == typeof(TreeGroupLeaf))
     {
         g = new TreeGroupLeaf();
         this.leafGroups = this.ArrayAdd(this.leafGroups, g as TreeGroupLeaf);
     }
     else
     {
         return null;
     }
     g.uniqueID = this._uniqueID;
     this._uniqueID++;
     g.parentGroupID = 0;
     g.distributionFrequency = 1;
     this.SetGroupParent(g, parent);
     return g;
 }
Beispiel #14
0
		public TreeGroup AddGroup(TreeGroup parent, Type type)
		{
			TreeGroup treeGroup;
			if (type == typeof(TreeGroupBranch))
			{
				treeGroup = new TreeGroupBranch();
				this.branchGroups = this.ArrayAdd(this.branchGroups, treeGroup as TreeGroupBranch);
			}
			else
			{
				if (type != typeof(TreeGroupLeaf))
				{
					return null;
				}
				treeGroup = new TreeGroupLeaf();
				this.leafGroups = this.ArrayAdd(this.leafGroups, treeGroup as TreeGroupLeaf);
			}
			treeGroup.uniqueID = this._uniqueID;
			this._uniqueID++;
			treeGroup.parentGroupID = 0;
			treeGroup.distributionFrequency = 1;
			this.SetGroupParent(treeGroup, parent);
			return treeGroup;
		}
Beispiel #15
0
        private void UpdateNodeMesh(TreeNode node, List <TreeMaterial> materials, List <TreeVertex> verts, List <TreeTriangle> tris, List <TreeAOSphere> aoSpheres, int buildFlags, float adaptiveQuality, float aoDensity)
        {
            node.triStart  = tris.Count;
            node.triEnd    = tris.Count;
            node.vertStart = verts.Count;
            node.vertEnd   = verts.Count;
            if (!node.visible || !this.visible)
            {
                return;
            }
            Profiler.BeginSample("TreeGroupLeaf.UpdateNodeMesh");
            Vector2 vector = base.ComputeWindFactor(node, node.offset);

            if (this.geometryMode == 4)
            {
                if (TreeGroupLeaf.cloneMesh == null)
                {
                    return;
                }
                if (TreeGroupLeaf.cloneVerts == null)
                {
                    return;
                }
                if (TreeGroupLeaf.cloneNormals == null)
                {
                    return;
                }
                if (TreeGroupLeaf.cloneTangents == null)
                {
                    return;
                }
                if (TreeGroupLeaf.cloneUVs == null)
                {
                    return;
                }
                Matrix4x4 localToWorldMatrix = this.instanceMesh.transform.localToWorldMatrix;
                Matrix4x4 matrix4x           = node.matrix * localToWorldMatrix;
                int       count = verts.Count;
                float     num   = 5f;
                for (int i = 0; i < TreeGroupLeaf.cloneVerts.Length; i++)
                {
                    TreeVertex treeVertex = new TreeVertex();
                    treeVertex.pos = matrix4x.MultiplyPoint(TreeGroupLeaf.cloneVerts[i]);
                    treeVertex.nor = matrix4x.MultiplyVector(TreeGroupLeaf.cloneNormals[i]).normalized;
                    treeVertex.uv0 = new Vector2(TreeGroupLeaf.cloneUVs[i].x, TreeGroupLeaf.cloneUVs[i].y);
                    Vector3 normalized = matrix4x.MultiplyVector(new Vector3(TreeGroupLeaf.cloneTangents[i].x, TreeGroupLeaf.cloneTangents[i].y, TreeGroupLeaf.cloneTangents[i].z)).normalized;
                    treeVertex.tangent = new Vector4(normalized.x, normalized.y, normalized.z, TreeGroupLeaf.cloneTangents[i].w);
                    float edgeFactor = TreeGroupLeaf.cloneVerts[i].magnitude / num * this.animationEdge;
                    treeVertex.SetAnimationProperties(vector.x, vector.y, edgeFactor, node.animSeed);
                    if ((buildFlags & 1) != 0)
                    {
                        treeVertex.SetAmbientOcclusion(TreeGroup.ComputeAmbientOcclusion(treeVertex.pos, treeVertex.nor, aoSpheres, aoDensity));
                    }
                    verts.Add(treeVertex);
                }
                for (int j = 0; j < TreeGroupLeaf.cloneMesh.subMeshCount; j++)
                {
                    int[] triangles = TreeGroupLeaf.cloneMesh.GetTriangles(j);
                    int   materialIndex;
                    if (this.instanceMesh.GetComponent <Renderer>() != null && j < this.instanceMesh.GetComponent <Renderer>().sharedMaterials.Length)
                    {
                        materialIndex = TreeGroup.GetMaterialIndex(this.instanceMesh.GetComponent <Renderer>().sharedMaterials[j], materials, false);
                    }
                    else
                    {
                        materialIndex = TreeGroup.GetMaterialIndex(null, materials, false);
                    }
                    for (int k = 0; k < triangles.Length; k += 3)
                    {
                        TreeTriangle item = new TreeTriangle(materialIndex, triangles[k] + count, triangles[k + 1] + count, triangles[k + 2] + count);
                        tris.Add(item);
                    }
                }
            }
            else
            {
                if (this.geometryMode == 3)
                {
                    Vector3 eulerAngles = node.rotation.eulerAngles;
                    eulerAngles.z = eulerAngles.x * 2f;
                    eulerAngles.x = 0f;
                    eulerAngles.y = 0f;
                    Quaternion quaternion  = Quaternion.Euler(eulerAngles);
                    Vector3    normalBase  = new Vector3(TreeGroup.GenerateBendBillboardNormalFactor, TreeGroup.GenerateBendBillboardNormalFactor, 1f);
                    Vector3    tangentBase = quaternion * new Vector3(1f, 0f, 0f);
                    float      normalFix   = node.scale / (TreeGroup.GenerateBendBillboardNormalFactor * TreeGroup.GenerateBendBillboardNormalFactor);
                    TreeVertex treeVertex2 = TreeGroupLeaf.CreateBillboardVertex(node, quaternion, normalBase, normalFix, tangentBase, new Vector2(0f, 1f));
                    TreeVertex treeVertex3 = TreeGroupLeaf.CreateBillboardVertex(node, quaternion, normalBase, normalFix, tangentBase, new Vector2(0f, 0f));
                    TreeVertex treeVertex4 = TreeGroupLeaf.CreateBillboardVertex(node, quaternion, normalBase, normalFix, tangentBase, new Vector2(1f, 0f));
                    TreeVertex treeVertex5 = TreeGroupLeaf.CreateBillboardVertex(node, quaternion, normalBase, normalFix, tangentBase, new Vector2(1f, 1f));
                    treeVertex2.SetAnimationProperties(vector.x, vector.y, this.animationEdge, node.animSeed);
                    treeVertex3.SetAnimationProperties(vector.x, vector.y, this.animationEdge, node.animSeed);
                    treeVertex4.SetAnimationProperties(vector.x, vector.y, this.animationEdge, node.animSeed);
                    treeVertex5.SetAnimationProperties(vector.x, vector.y, this.animationEdge, node.animSeed);
                    if ((buildFlags & 1) != 0)
                    {
                        Vector3 b    = Vector3.right * node.scale;
                        Vector3 b2   = Vector3.forward * node.scale;
                        float   num2 = TreeGroup.ComputeAmbientOcclusion(treeVertex2.pos + b, Vector3.right, aoSpheres, aoDensity);
                        num2 += TreeGroup.ComputeAmbientOcclusion(treeVertex2.pos - b, -Vector3.right, aoSpheres, aoDensity);
                        num2 += TreeGroup.ComputeAmbientOcclusion(treeVertex2.pos + b2, Vector3.forward, aoSpheres, aoDensity);
                        num2 += TreeGroup.ComputeAmbientOcclusion(treeVertex2.pos - b2, -Vector3.forward, aoSpheres, aoDensity);
                        num2 /= 4f;
                        treeVertex2.SetAmbientOcclusion(num2);
                        treeVertex3.SetAmbientOcclusion(num2);
                        treeVertex4.SetAmbientOcclusion(num2);
                        treeVertex5.SetAmbientOcclusion(num2);
                    }
                    int count2 = verts.Count;
                    verts.Add(treeVertex2);
                    verts.Add(treeVertex3);
                    verts.Add(treeVertex4);
                    verts.Add(treeVertex5);
                    int materialIndex2 = TreeGroup.GetMaterialIndex(this.materialLeaf, materials, false);
                    tris.Add(new TreeTriangle(materialIndex2, count2, count2 + 2, count2 + 1, true));
                    tris.Add(new TreeTriangle(materialIndex2, count2, count2 + 3, count2 + 2, true));
                }
                else
                {
                    int num3 = 0;
                    switch (this.geometryMode)
                    {
                    case 0:
                        num3 = 1;
                        break;

                    case 1:
                        num3 = 2;
                        break;

                    case 2:
                        num3 = 3;
                        break;
                    }
                    int       materialIndex3 = TreeGroup.GetMaterialIndex(this.materialLeaf, materials, false);
                    Vector2[] array          = new Vector2[]
                    {
                        new Vector2(0f, 1f),
                        new Vector2(0f, 0f),
                        new Vector2(1f, 0f),
                        new Vector2(1f, 1f)
                    };
                    Vector2[] array2 = this.GetPlaneHullVertices(this.materialLeaf);
                    if (array2 == null)
                    {
                        array2 = array;
                    }
                    float     scale  = node.scale;
                    Vector3[] array3 = new Vector3[]
                    {
                        new Vector3(-scale, 0f, -scale),
                        new Vector3(-scale, 0f, scale),
                        new Vector3(scale, 0f, scale),
                        new Vector3(scale, 0f, -scale)
                    };
                    Vector3   vector2        = new Vector3(TreeGroup.GenerateBendNormalFactor, 1f - TreeGroup.GenerateBendNormalFactor, TreeGroup.GenerateBendNormalFactor);
                    Vector3[] expr_788       = new Vector3[4];
                    int       arg_7B4_0_cp_1 = 0;
                    Vector3   vector3        = new Vector3(-vector2.x, vector2.y, -vector2.z);
                    expr_788[arg_7B4_0_cp_1] = vector3.normalized;
                    int     arg_7E2_0_cp_1 = 1;
                    Vector3 vector4        = new Vector3(-vector2.x, vector2.y, 0f);
                    expr_788[arg_7E2_0_cp_1] = vector4.normalized;
                    int     arg_80F_0_cp_1 = 2;
                    Vector3 vector5        = new Vector3(vector2.x, vector2.y, 0f);
                    expr_788[arg_80F_0_cp_1] = vector5.normalized;
                    int     arg_83F_0_cp_1 = 3;
                    Vector3 vector6        = new Vector3(vector2.x, vector2.y, -vector2.z);
                    expr_788[arg_83F_0_cp_1] = vector6.normalized;
                    Vector3[] array4 = expr_788;
                    for (int l = 0; l < num3; l++)
                    {
                        Quaternion quaternion2 = Quaternion.Euler(new Vector3(90f, 0f, 0f));
                        int        num4        = l;
                        if (num4 != 1)
                        {
                            if (num4 == 2)
                            {
                                quaternion2 = Quaternion.Euler(new Vector3(0f, 90f, 0f));
                            }
                        }
                        else
                        {
                            quaternion2 = Quaternion.Euler(new Vector3(90f, 90f, 0f));
                        }
                        TreeVertex[] array5 = new TreeVertex[]
                        {
                            new TreeVertex(),
                            new TreeVertex(),
                            new TreeVertex(),
                            new TreeVertex(),
                            new TreeVertex(),
                            new TreeVertex(),
                            new TreeVertex(),
                            new TreeVertex()
                        };
                        for (int m = 0; m < 4; m++)
                        {
                            array5[m].pos     = node.matrix.MultiplyPoint(quaternion2 * array3[m]);
                            array5[m].nor     = node.matrix.MultiplyVector(quaternion2 * array4[m]);
                            array5[m].tangent = TreeGroup.CreateTangent(node, quaternion2, array5[m].nor);
                            array5[m].uv0     = array2[m];
                            array5[m].SetAnimationProperties(vector.x, vector.y, this.animationEdge, node.animSeed);
                            if ((buildFlags & 1) != 0)
                            {
                                array5[m].SetAmbientOcclusion(TreeGroup.ComputeAmbientOcclusion(array5[m].pos, array5[m].nor, aoSpheres, aoDensity));
                            }
                        }
                        for (int n = 0; n < 4; n++)
                        {
                            array5[n + 4].Lerp4(array5, array2[n]);
                            array5[n + 4].uv0  = array5[n].uv0;
                            array5[n + 4].uv1  = array5[n].uv1;
                            array5[n + 4].flag = array5[n].flag;
                        }
                        int count3 = verts.Count;
                        for (int num5 = 0; num5 < 4; num5++)
                        {
                            verts.Add(array5[num5 + 4]);
                        }
                        tris.Add(new TreeTriangle(materialIndex3, count3, count3 + 1, count3 + 2));
                        tris.Add(new TreeTriangle(materialIndex3, count3, count3 + 2, count3 + 3));
                        Vector3 inNormal = node.matrix.MultiplyVector(quaternion2 * new Vector3(0f, 1f, 0f));
                        if (TreeGroup.GenerateDoubleSidedGeometry)
                        {
                            TreeVertex[] array6 = new TreeVertex[]
                            {
                                new TreeVertex(),
                                new TreeVertex(),
                                new TreeVertex(),
                                new TreeVertex(),
                                new TreeVertex(),
                                new TreeVertex(),
                                new TreeVertex(),
                                new TreeVertex()
                            };
                            for (int num6 = 0; num6 < 4; num6++)
                            {
                                array6[num6].pos       = array5[num6].pos;
                                array6[num6].nor       = Vector3.Reflect(array5[num6].nor, inNormal);
                                array6[num6].tangent   = Vector3.Reflect(array5[num6].tangent, inNormal);
                                array6[num6].tangent.w = -1f;
                                array6[num6].uv0       = array5[num6].uv0;
                                array6[num6].SetAnimationProperties(vector.x, vector.y, this.animationEdge, node.animSeed);
                                if ((buildFlags & 1) != 0)
                                {
                                    array6[num6].SetAmbientOcclusion(TreeGroup.ComputeAmbientOcclusion(array6[num6].pos, array6[num6].nor, aoSpheres, aoDensity));
                                }
                            }
                            for (int num7 = 0; num7 < 4; num7++)
                            {
                                array6[num7 + 4].Lerp4(array6, array2[num7]);
                                array6[num7 + 4].uv0  = array6[num7].uv0;
                                array6[num7 + 4].uv1  = array6[num7].uv1;
                                array6[num7 + 4].flag = array6[num7].flag;
                            }
                            int count4 = verts.Count;
                            for (int num8 = 0; num8 < 4; num8++)
                            {
                                verts.Add(array6[num8 + 4]);
                            }
                            tris.Add(new TreeTriangle(materialIndex3, count4, count4 + 2, count4 + 1));
                            tris.Add(new TreeTriangle(materialIndex3, count4, count4 + 3, count4 + 2));
                        }
                    }
                }
            }
            node.triEnd  = tris.Count;
            node.vertEnd = verts.Count;
            Profiler.EndSample();
        }
Beispiel #16
0
 private TreeGroupLeaf[] ArrayAdd(TreeGroupLeaf[] array, TreeGroupLeaf value)
 {
     List<TreeGroupLeaf> list = new List<TreeGroupLeaf>(array) {
         value
     };
     return list.ToArray();
 }
Beispiel #17
0
		private TreeGroupLeaf[] ArrayRemove(TreeGroupLeaf[] array, TreeGroupLeaf value)
		{
			List<TreeGroupLeaf> list = new List<TreeGroupLeaf>(array);
			list.Remove(value);
			return list.ToArray();
		}
Beispiel #18
0
		private TreeGroupLeaf[] ArrayAdd(TreeGroupLeaf[] array, TreeGroupLeaf value)
		{
			return new List<TreeGroupLeaf>(array)
			{
				value
			}.ToArray();
		}
Beispiel #19
0
 public void InspectorLeaf(TreeData treeData, TreeGroupLeaf group)
 {
     this.InspectorEditTools(base.target as Tree);
     GUIContent[] contentArray1 = new GUIContent[6];
     contentArray1[0] = TreeEditorHelper.GetGUIContent("Distribution|Adjusts the count and placement of leaves in the group. Use the curves to fine tune position, rotation and scale. The curves are relative to the parent branch.");
     contentArray1[1] = TreeEditorHelper.GetGUIContent("Geometry|Select what type of geometry is generated for this leaf group and which materials are applied. If you use a custom mesh, its materials will be used.");
     contentArray1[2] = TreeEditorHelper.GetGUIContent("Shape|Adjusts the shape and growth of the leaves.");
     contentArray1[5] = TreeEditorHelper.GetGUIContent("Wind|Adjusts the parameters used for animating this group of leaves. Wind zones are only active in Play Mode. If you select too high values for Main Wind and Main Turbulence the leaves may float away from the branches.");
     GUIContent[] names = contentArray1;
     bool enabled = GUI.enabled;
     if (s_SelectedGroup.lockFlags != 0)
     {
         this.GUIunlockbox(treeData);
     }
     BeginSettingsSection(0, names);
     this.InspectorDistribution(treeData, group);
     EndSettingsSection();
     BeginSettingsSection(1, names);
     this.PrepareSpacing(false);
     group.geometryMode = this.GUIPopup(PropertyType.FullUpdate, geometryModeLeafString, geometryModeOptions, group.geometryMode, false);
     if (group.geometryMode != 4)
     {
         group.materialLeaf = this.GUIMaterialField(PropertyType.FullUpdate, group.uniqueID, materialLeafString, group.materialLeaf, TreeEditorHelper.NodeType.LeafNode);
     }
     if (group.geometryMode == 4)
     {
         group.instanceMesh = this.GUIObjectField(PropertyType.FullUpdate, meshString, group.instanceMesh, typeof(GameObject), false) as GameObject;
     }
     EndSettingsSection();
     BeginSettingsSection(2, names);
     this.PrepareSpacing(false);
     group.size = this.GUIMinMaxSlider(PropertyType.Normal, sizeString, group.size, 0.1f, 2f, false);
     group.perpendicularAlign = this.GUISlider(PropertyType.Normal, perpendicularAlignString, group.perpendicularAlign, 0f, 1f, false);
     group.horizontalAlign = this.GUISlider(PropertyType.Normal, horizontalAlignString, group.horizontalAlign, 0f, 1f, false);
     EndSettingsSection();
     BeginSettingsSection(5, names);
     this.PrepareSpacing(false);
     this.InspectorAnimation(treeData, group);
     EndSettingsSection();
     GUI.enabled = enabled;
     EditorGUILayout.Space();
 }
Beispiel #20
0
		public void InspectorLeaf(TreeData treeData, TreeGroupLeaf group)
		{
			this.InspectorEditTools(this.target as Tree);
			GUIContent[] names = new GUIContent[]
			{
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupLeaf.Distribution"),
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupLeaf.Geometry"),
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupLeaf.Shape"),
				null,
				null,
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupLeaf.Animation")
			};
			string str = "TreeEditor.TreeGroupLeaf.";
			bool enabled = GUI.enabled;
			if (TreeEditor.s_SelectedGroup.lockFlags != 0)
			{
				this.GUIunlockbox(treeData);
			}
			TreeEditor.BeginSettingsSection(0, names);
			this.InspectorDistribution(treeData, group);
			TreeEditor.EndSettingsSection();
			TreeEditor.BeginSettingsSection(1, names);
			this.PrepareSpacing(false);
			string[] optionIDs = new string[]
			{
				"Plane",
				"Cross",
				"TriCross",
				"Billboard",
				"Mesh"
			};
			group.geometryMode = this.GUIPopup(TreeEditor.PropertyType.FullUpdate, str + "GeometryMode", str + "GeometryModeOption", optionIDs, group.geometryMode, false);
			if (group.geometryMode != 4)
			{
				group.materialLeaf = this.GUIMaterialField(TreeEditor.PropertyType.FullUpdate, group.uniqueID, str + "Material", group.materialLeaf, TreeEditorHelper.NodeType.LeafNode);
			}
			if (group.geometryMode == 4)
			{
				group.instanceMesh = (this.GUIObjectField(TreeEditor.PropertyType.FullUpdate, str + "Mesh", group.instanceMesh, typeof(GameObject), false) as GameObject);
			}
			TreeEditor.EndSettingsSection();
			TreeEditor.BeginSettingsSection(2, names);
			this.PrepareSpacing(false);
			group.size = this.GUIMinMaxSlider(TreeEditor.PropertyType.Normal, str + "Size", group.size, 0.1f, 2f, false);
			group.perpendicularAlign = this.GUISlider(TreeEditor.PropertyType.Normal, str + "PerpendicularAlign", group.perpendicularAlign, 0f, 1f, false);
			group.horizontalAlign = this.GUISlider(TreeEditor.PropertyType.Normal, str + "HorizontalAlign", group.horizontalAlign, 0f, 1f, false);
			TreeEditor.EndSettingsSection();
			TreeEditor.BeginSettingsSection(5, names);
			this.PrepareSpacing(false);
			this.InspectorAnimation(treeData, group);
			TreeEditor.EndSettingsSection();
			GUI.enabled = enabled;
			EditorGUILayout.Space();
		}