Ejemplo n.º 1
0
        public static void Generate(int subdivisionsCount, float radius, Vector3 viewCenter, float viewAngle, out List <Vector3> outVerts, out List <int> outIndices)
        {
            middlePointsCache.Clear();
            outVerts = new List <Vector3>();
            IcosahedronGenerator.GenerateIcosahedron(outVerts, tris, radius, viewCenter, viewAngle);
            for (int i = 0; i < subdivisionsCount; i++)
            {
                newTris.Clear();
                int j = 0;
                for (int count = tris.Count; j < count; j++)
                {
                    TriangleIndices triangleIndices = tris[j];
                    int             middlePoint     = GetMiddlePoint(triangleIndices.v1, triangleIndices.v2, outVerts, radius);
                    int             middlePoint2    = GetMiddlePoint(triangleIndices.v2, triangleIndices.v3, outVerts, radius);
                    int             middlePoint3    = GetMiddlePoint(triangleIndices.v3, triangleIndices.v1, outVerts, radius);
                    newTris.Add(new TriangleIndices(triangleIndices.v1, middlePoint, middlePoint3));
                    newTris.Add(new TriangleIndices(triangleIndices.v2, middlePoint2, middlePoint));
                    newTris.Add(new TriangleIndices(triangleIndices.v3, middlePoint3, middlePoint2));
                    newTris.Add(new TriangleIndices(middlePoint, middlePoint2, middlePoint3));
                }
                tris.Clear();
                tris.AddRange(newTris);
            }
            MeshUtility.RemoveVertices(outVerts, tris, (Vector3 x) => !MeshUtility.Visible(x, radius, viewCenter, viewAngle));
            outIndices = new List <int>();
            int k = 0;

            for (int count2 = tris.Count; k < count2; k++)
            {
                TriangleIndices triangleIndices2 = tris[k];
                outIndices.Add(triangleIndices2.v1);
                outIndices.Add(triangleIndices2.v2);
                outIndices.Add(triangleIndices2.v3);
            }
        }
Ejemplo n.º 2
0
 private static void DoGenerate()
 {
     ClearOrCreateMeshStaticData();
     CreateTileInfoStaticData();
     IcosahedronGenerator.GenerateIcosahedron(verts, tris, radius, viewCenter, viewAngle);
     for (int i = 0; i < subdivisionsCount + 1; i++)
     {
         Subdivide(i == subdivisionsCount);
     }
     CalculateTileNeighbors();
     ClearAndDeallocateWorkingLists();
 }
Ejemplo n.º 3
0
 private static void DoGenerate()
 {
     PlanetShapeGenerator.ClearOrCreateMeshStaticData();
     PlanetShapeGenerator.CreateTileInfoStaticData();
     IcosahedronGenerator.GenerateIcosahedron(PlanetShapeGenerator.verts, PlanetShapeGenerator.tris, PlanetShapeGenerator.radius, PlanetShapeGenerator.viewCenter, PlanetShapeGenerator.viewAngle);
     for (int i = 0; i < PlanetShapeGenerator.subdivisionsCount + 1; i++)
     {
         bool lastPass = i == PlanetShapeGenerator.subdivisionsCount;
         PlanetShapeGenerator.Subdivide(lastPass);
     }
     PlanetShapeGenerator.CalculateTileNeighbors();
     PlanetShapeGenerator.ClearAndDeallocateWorkingLists();
 }