// Internal void ApplyMesh(MeshFilter inFilter, MeshGenerator.Output inMeshData) { inFilter.mesh.vertices = inMeshData.vertices; inFilter.mesh.triangles = inMeshData.triangles; inFilter.mesh.uv2 = inMeshData.uv2; inFilter.mesh.RecalculateNormals(); }
public GameObject Generate(Vector2DInt inPosition, Chunk.Data inChunkData) { GameObject newChunkView = new GameObject("Chunk"); MeshFilter meshFilter = newChunkView.AddComponent <MeshFilter>(); MeshRenderer meshRenderer = newChunkView.AddComponent <MeshRenderer>(); meshRenderer.material = _chunkMaterial; newChunkView.transform.position = new Vector3(inPosition.x, 0, inPosition.y) * Constants.TerrainGeneration.CHUNK_SIZE; MeshGenerator.Output meshData = _meshGenerator.Generate(inChunkData); ApplyMesh(meshFilter, meshData); return(newChunkView); }
// External public Chunk.View Generate(Vector2DI inPosition, Chunk.Data inChunkData) { GameObject newChunkGO = new GameObject("Chunk"); MeshFilter meshFilter = newChunkGO.AddComponent <MeshFilter>(); MeshRenderer meshRenderer = newChunkGO.AddComponent <MeshRenderer>(); meshRenderer.material = _chunkMaterial; newChunkGO.transform.position = new Vector3(inPosition.x, 0, inPosition.y); MeshGenerator.Output meshData = _meshGenerator.Generate(inChunkData); ApplyMesh(meshFilter, meshData); Chunk.View newChunkView = new Chunk.View(newChunkGO); return(newChunkView); }
void ApplyMesh(MeshFilter inFilter, MeshGenerator.Output inMeshData) { inFilter.mesh.vertices = inMeshData.vertices; inFilter.mesh.triangles = inMeshData.triangles; inFilter.mesh.uv2 = inMeshData.uv2; }