void GenerateMesh() { PlanetMeshGenerator.CreatePlanetMesh(Settings.PlanetRadius, Settings.Subdivisions); foreach (MeshFilter mf in DelaunayTrianglesPlane) { mf.sharedMesh = null; } foreach (MeshFilter mf in DelaunayTrianglesSphere) { mf.sharedMesh = null; } List <Mesh> sphereTriangleMeshes = PlanetMeshGenerator.GetIcosahedronTriangles(); List <Mesh> sphereHexagonMeshes = PlanetMeshGenerator.GetIcosahedronHexagons(); /* * List<Mesh> planeTriangleMeshes = PlanetMeshGenerator.GetPlaneDelaunayTriangles(); * List<Mesh> sphereTriangleMeshes = PlanetMeshGenerator.GetSphereDelaunayTriangles(); * * //Debug.Log(planeTriangleMeshes.Count); * for(int i = 0; i < planeTriangleMeshes.Count; i++) * DelaunayTrianglesPlane[i].sharedMesh = planeTriangleMeshes[i]; */ for (int i = 0; i < sphereHexagonMeshes.Count; i++) { DelaunayTrianglesSphere[i].sharedMesh = sphereHexagonMeshes[i]; } }
// function found at https://stackoverflow.com/questions/9600801/evenly-distributing-n-points-on-a-sphere /*public void GenerateSpherePoints() { * this.points = PlanetMeshGenerator.TestGenerateSpherePoints(density, planetRadius); * } * * public void Projection() { * this.points = PlanetMeshGenerator.TestProjection(density, planetRadius); * }*/ public void GenerateSphere() { SphereMeshData meshData = PlanetMeshGenerator.GenerateSphere(density, planetRadius); MeshFilter mesh = renderObject.GetComponent <MeshFilter>(); mesh.sharedMesh = meshData.CreateMesh(); }
public void GenerateSphere() { System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch(); time.Start(); SphereMeshData meshData = PlanetMeshGenerator.GenerateSphere(subdivisions, planetRadius); MeshFilter mesh = renderObject.GetComponent <MeshFilter>(); Mesh planetMesh = meshData.CreateMesh(); planetMesh = PlanetLandscapeGenerator.generateNoise(planetMesh, maxHeight, seed, scale, lacunarity, persistance, octaves, warpAmplitude); planetMesh = PlanetLandscapeGenerator.generateCraters(planetMesh, craterDensity, rimWidth, rimHeight, rimSteepness, maxRadius); mesh.sharedMesh = planetMesh; time.Stop(); print("carried out " + time.Elapsed.TotalSeconds + " second"); }
public void OnEnable() { targetPlanetMeshGenerator = (PlanetMeshGenerator)target; }
private void Start() { planetMeshGenerator = GameManager.GetInstance().GetPlanet().GetComponent <PlanetMeshGenerator>(); }