void Build() { MakeMapDimensions(); myMap.CopyToMarching(); if (cavesque) { myMap.MakeCavesque(); } myMap.SmoothMesh(smoothness); myMap.MakeChunks(); GameObject tempChunk; MeshGenerator.MarchingMesh marchingMesh; for (int i = 0; i < myMap.chunkList.Count; i++) { tempChunk = Instantiate(chunk, transform); tempChunk.SetActive(true); tempChunk.transform.position = myMap.chunkList[i].position * transform.localScale.x; marchingMesh = new MeshGenerator.MarchingMesh(ref myMap.chunkList[i].marchingGrid); tempChunk.GetComponent <MeshFilter>().mesh = marchingMesh.GetMarchingMesh(); tempChunk.GetComponent <MeshCollider>().sharedMesh = tempChunk.GetComponent <MeshFilter>().sharedMesh; } }
void Start() { //mesh = GetComponent<MeshFilter>().mesh; map = new GameMap.Map(width); map.MakeBox(); map.CullHidden(); //MeshGenerator.CubeMesh cubeMesh = new MeshGenerator.CubeMesh(ref map); MeshGenerator.MarchingMesh marchingMesh = new MeshGenerator.MarchingMesh(ref map); //vertices = cubeMesh.vertexList; //triangles = cubeMesh.triangleList; //vertices = marchingMesh.vertexList; vertices = marchingMesh.debugList; triangles = marchingMesh.triangleList; //vertices = map.GetCubeVertices(); //mesh = map.GetCubeMesh(ref vertices, ref normals, ref triangles); //GetComponent<MeshFilter>().mesh = cubeMesh.GetCubeMesh(); GetComponent <MeshFilter>().mesh = marchingMesh.GetMarchingMesh(); //triangles = map.GetTriangleList(); //GetComponent<MeshFilter>().mesh.normals //GetComponent<MeshFilter>().mesh.vertices = vertices.ToArray(); //GetComponent<MeshFilter>().mesh.triangles = triangles.ToArray(); GetComponent <MeshCollider>().sharedMesh = GetComponent <MeshFilter>().sharedMesh; }
void BuildLevel() { switch (mapType) { case MapType.cube: myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth); myMap.MakeBox(); break; case MapType.cross: myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth); myMap.MakeCross(thickness); break; case MapType.warren: myMap = new GameMap.ClusterMap(arenaWidth); myMap.MakeCross(arenaWidth - thickness * 2); break; case MapType.sphere: myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth); myMap.MakeSphere(); break; case MapType.pillars: myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth); myMap.MakePillars(thickness); break; case MapType.tangle: myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth); myMap.MakeTangle(thickness); break; case MapType.race: myMap = new GameMap.ClusterMap(6, 6, 160); myMap.MakeBox(); break; default: break; } myMap.CopyToMarching(); if (cavesque) { myMap.MakeCavesque(); } myMap.SmoothMesh(smoothness); myMap.MakeChunks(); GameObject tempChunk; MeshGenerator.MarchingMesh marchingMesh; for (int i = 0; i < myMap.chunkList.Count; i++) { tempChunk = Instantiate(chunk, transform); tempChunk.SetActive(true); tempChunk.transform.position = myMap.chunkList[i].position * transform.localScale.x; marchingMesh = new MeshGenerator.MarchingMesh(ref myMap.chunkList[i].marchingGrid); tempChunk.GetComponent <MeshFilter>().mesh = marchingMesh.GetMarchingMesh(); tempChunk.GetComponent <MeshCollider>().sharedMesh = tempChunk.GetComponent <MeshFilter>().sharedMesh; } focalPoint = new Vector3(arenaWidth * cube.transform.localScale.x * 0.5f, arenaWidth * cube.transform.localScale.y * 0.5f, arenaWidth * cube.transform.localScale.z * 0.5f); }