コード例 #1
0
ファイル: VoxelHelper.cs プロジェクト: TehWardy/Framework
        /// <summary>
        /// Returns faces that are visible for the voxel at the given index in the given volume.
        /// </summary>
        /// <returns>The faces for.</returns>
        /// <param name="volume">Volume.</param>
        /// <param name="voxel">Voxel.</param>
        public static IEnumerable<Face> VisibleFacesFor(VoxelContainer chunk, IntVector3 voxel)
        {
            var result = new List<Face>();
            var faceVector = new IntVector3(voxel);

            if (chunk.GetVoxel(voxel).Weight > 0)
            {
                faceVector.Y += 1;
                if (chunk.GetVoxel(faceVector).Weight <= 0)
                    result.Add(Face.Top);

                faceVector.Y -= 2;
                if (chunk.GetVoxel(faceVector).Weight <= 0)
                    result.Add(Face.Bottom);

                faceVector.Y += 1;
                faceVector.X -= 1;
                if (chunk.GetVoxel(faceVector).Weight <= 0)
                    result.Add(Face.Left);

                faceVector.X += 2;
                if (chunk.GetVoxel(faceVector).Weight <= 0)
                    result.Add(Face.Right);

                faceVector.X -= 1;
                faceVector.Z -= 1;
                if (chunk.GetVoxel(faceVector).Weight <= 0)
                    result.Add(Face.Front);

                faceVector.Z += 2;
                if (chunk.GetVoxel(faceVector).Weight <= 0)
                    result.Add(Face.Back);
            }

            return result;
        }
コード例 #2
0
ファイル: MeshGenerator.cs プロジェクト: TehWardy/Framework
 public abstract Mesh GenerateMesh(VoxelContainer data, IntVector3 start, IntVector3 end);