Exemple #1
0
        // 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();
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        // 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);
        }
Exemple #4
0
 void ApplyMesh(MeshFilter inFilter, MeshGenerator.Output inMeshData)
 {
     inFilter.mesh.vertices  = inMeshData.vertices;
     inFilter.mesh.triangles = inMeshData.triangles;
     inFilter.mesh.uv2       = inMeshData.uv2;
 }