예제 #1
0
        void RenderMesh(MeshData meshData)
        {
            Filter.mesh.Clear();
            Filter.mesh.vertices = meshData.Verticies.ToArray();
            Filter.mesh.triangles = meshData.Tris.ToArray();
            Filter.mesh.uv = meshData.UV.ToArray();
            Filter.mesh.RecalculateNormals();

            Coll.sharedMesh = null;
            Mesh mesh = new Mesh();
            mesh.vertices = meshData.ColVerticies.ToArray();
            mesh.triangles = meshData.ColTris.ToArray();
            mesh.RecalculateNormals();

            Coll.sharedMesh = mesh;
        }
예제 #2
0
        public virtual MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
        {
            meshData.UseRenderDataForCol = true;

            if (!chunk.GetBlock(x, y + 1, z).IsSolid(Direction.Down))
            {
                meshData = FaceDataUp(chunk, x, y, z, meshData);
            }

            if (!chunk.GetBlock(x, y - 1, z).IsSolid(Direction.Up))
            {
                meshData = FaceDataDown(chunk, x, y, z, meshData);
            }

            if (!chunk.GetBlock(x, y, z + 1).IsSolid(Direction.South))
            {
                meshData = FaceDataNorth(chunk, x, y, z, meshData);
            }

            if (!chunk.GetBlock(x, y, z - 1).IsSolid(Direction.North))
            {
                meshData = FaceDataSouth(chunk, x, y, z, meshData);
            }

            if (!chunk.GetBlock(x + 1, y, z).IsSolid(Direction.West))
            {
                meshData = FaceDataEast(chunk, x, y, z, meshData);
            }

            if (!chunk.GetBlock(x - 1, y, z).IsSolid(Direction.East))
            {
                meshData = FaceDataWest(chunk, x, y, z, meshData);
            }

            return meshData;
        }
예제 #3
0
        protected virtual MeshData FaceDataWest(Chunk chunk, int x, int y, int z, MeshData meshData)
        {
            meshData.AddVertex(new Vector3(x - 0.5f, y - 0.5f, z + 0.5f));
            meshData.AddVertex(new Vector3(x - 0.5f, y + 0.5f, z + 0.5f));
            meshData.AddVertex(new Vector3(x - 0.5f, y + 0.5f, z - 0.5f));
            meshData.AddVertex(new Vector3(x - 0.5f, y - 0.5f, z - 0.5f));
            meshData.AddQuadTriangles();

            meshData.UV.AddRange (FaceUVs (Direction.West));
            return meshData;
        }
예제 #4
0
 public override MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
 {
     return meshData;
 }
예제 #5
0
 public override MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
 {
     return(meshData);
 }
예제 #6
0
 void UpdateChunk()
 {
     MeshData meshData = new MeshData();
     for (int x = 0; x < CHUNK_SIZE; x++)
     {
         for (int y = 0; y < CHUNK_SIZE; y++)
         {
             for (int z = 0; z < CHUNK_SIZE; z++)
             {
                 meshData = Blocks[x, y, z].Blockdata(this, x, y, z, meshData);
             }
         }
     }
     RenderMesh(meshData);
 }