public static void GenerateIcosahedron(List <Vector3> outVerts, List <TriangleIndices> outTris, float radius, Vector3 viewCenter, float viewAngle)
        {
            float num = (float)((1.0 + Mathf.Sqrt(5f)) / 2.0);

            outVerts.Clear();
            outVerts.Add(new Vector3(-1f, num, 0f).normalized *radius);
            outVerts.Add(new Vector3(1f, num, 0f).normalized *radius);
            outVerts.Add(new Vector3(-1f, (float)(0.0 - num), 0f).normalized *radius);
            outVerts.Add(new Vector3(1f, (float)(0.0 - num), 0f).normalized *radius);
            outVerts.Add(new Vector3(0f, -1f, num).normalized *radius);
            outVerts.Add(new Vector3(0f, 1f, num).normalized *radius);
            outVerts.Add(new Vector3(0f, -1f, (float)(0.0 - num)).normalized *radius);
            outVerts.Add(new Vector3(0f, 1f, (float)(0.0 - num)).normalized *radius);
            outVerts.Add(new Vector3(num, 0f, -1f).normalized *radius);
            outVerts.Add(new Vector3(num, 0f, 1f).normalized *radius);
            outVerts.Add(new Vector3((float)(0.0 - num), 0f, -1f).normalized *radius);
            outVerts.Add(new Vector3((float)(0.0 - num), 0f, 1f).normalized *radius);
            outTris.Clear();
            int i    = 0;
            int num2 = IcosahedronGenerator.IcosahedronTris.Length;

            for (; i < num2; i++)
            {
                TriangleIndices item = IcosahedronGenerator.IcosahedronTris[i];
                if (IcosahedronGenerator.IcosahedronFaceNeeded(item.v1, item.v2, item.v3, outVerts, radius, viewCenter, viewAngle))
                {
                    outTris.Add(item);
                }
            }
            MeshUtility.RemoveUnusedVertices(outVerts, outTris);
        }
Ejemplo n.º 2
0
        public static void GenerateIcosahedron(List <Vector3> outVerts, List <TriangleIndices> outTris, float radius, Vector3 viewCenter, float viewAngle)
        {
            float num = (1f + Mathf.Sqrt(5f)) / 2f;

            outVerts.Clear();
            Vector3 vector = new Vector3(-1f, num, 0f);

            outVerts.Add(vector.normalized * radius);
            Vector3 vector2 = new Vector3(1f, num, 0f);

            outVerts.Add(vector2.normalized * radius);
            Vector3 vector3 = new Vector3(-1f, -num, 0f);

            outVerts.Add(vector3.normalized * radius);
            Vector3 vector4 = new Vector3(1f, -num, 0f);

            outVerts.Add(vector4.normalized * radius);
            Vector3 vector5 = new Vector3(0f, -1f, num);

            outVerts.Add(vector5.normalized * radius);
            Vector3 vector6 = new Vector3(0f, 1f, num);

            outVerts.Add(vector6.normalized * radius);
            Vector3 vector7 = new Vector3(0f, -1f, -num);

            outVerts.Add(vector7.normalized * radius);
            Vector3 vector8 = new Vector3(0f, 1f, -num);

            outVerts.Add(vector8.normalized * radius);
            Vector3 vector9 = new Vector3(num, 0f, -1f);

            outVerts.Add(vector9.normalized * radius);
            Vector3 vector10 = new Vector3(num, 0f, 1f);

            outVerts.Add(vector10.normalized * radius);
            Vector3 vector11 = new Vector3(-num, 0f, -1f);

            outVerts.Add(vector11.normalized * radius);
            Vector3 vector12 = new Vector3(-num, 0f, 1f);

            outVerts.Add(vector12.normalized * radius);
            outTris.Clear();
            int i    = 0;
            int num2 = IcosahedronGenerator.IcosahedronTris.Length;

            while (i < num2)
            {
                TriangleIndices item = IcosahedronGenerator.IcosahedronTris[i];
                if (IcosahedronGenerator.IcosahedronFaceNeeded(item.v1, item.v2, item.v3, outVerts, radius, viewCenter, viewAngle))
                {
                    outTris.Add(item);
                }
                i++;
            }
            MeshUtility.RemoveUnusedVertices(outVerts, outTris);
        }