示例#1
0
文件: Block.cs 项目: Quixotic7/VR-Vox
		public virtual MeshData Blockdata(Chunk chunk, int x, int y, int z, float scale, float worldScale, MeshData meshData)
		{
			if (BlockType == VoxBlockType.Empty) return meshData;

			meshData.UseRenderDataForCol = true;

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

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

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

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

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

			return meshData;
		}
示例#2
0
文件: Chunk.cs 项目: Quixotic7/VR-Vox
		//Sends the calculated mesh information
		//to the mesh and collision components
		protected void RenderMesh(MeshData meshData)
		{
			Filter.mesh.Clear();
			Filter.mesh.vertices = meshData.vertices.ToArray();
			Filter.mesh.triangles = meshData.triangles.ToArray();
			Filter.mesh.colors = meshData.colors.ToArray();

			Filter.mesh.uv = meshData.uv.ToArray();
			Filter.mesh.RecalculateNormals();

			Coll.sharedMesh = null;
			var mesh = new Mesh
			{
				vertices = meshData.colVertices.ToArray(),
				triangles = meshData.colTriangles.ToArray()
			};
			mesh.RecalculateNormals();

			Coll.sharedMesh = mesh;
		}
示例#3
0
文件: Chunk.cs 项目: Quixotic7/VR-Vox
		//Updates the chunk based on its contents
		protected void Reconstruct()
		{
			Rendered = true;
			var meshData = new MeshData();

			for (var x = 0; x < World.ChunkSize; x++)
			{
				for (var y = 0; y < World.ChunkSize; y++)
				{
					for (var z = 0; z < World.ChunkSize; z++)
					{
						Blocks[x, y, z].JustCreated = false;
						meshData = Blocks[x, y, z].Blockdata(this, x, y, z, BlockScale * World.UnitScale, World.UnitScale, meshData);
						//if (Blocks[x, y, z] != null)
						//{
							
						//}
						//else
						//{
						//	Blocks[x, y, z] = new Block(Color.white) {BlockType = VoxBlockType.Empty};
						//}
					}
				}
			}
			RenderMesh(meshData);
		}
示例#4
0
文件: Block.cs 项目: Quixotic7/VR-Vox
		protected virtual MeshData FaceDataWest(Chunk chunk, int x, int y, int z, float scale, float worldScale, MeshData meshData)
		{
			meshData.AddVertex(new Vector3(x * worldScale - scale, y * worldScale - scale, z * worldScale + scale), BlockColor);
			meshData.AddVertex(new Vector3(x * worldScale - scale, y * worldScale + scale, z * worldScale + scale), BlockColor);
			meshData.AddVertex(new Vector3(x * worldScale - scale, y * worldScale + scale, z * worldScale - scale), BlockColor);
			meshData.AddVertex(new Vector3(x * worldScale - scale, y * worldScale - scale, z * worldScale - scale), BlockColor);

			meshData.AddQuadTriangles();
			meshData.uv.AddRange(FaceUVs(Direction.West));

			return meshData;
		}