当前位置: 首页>>代码示例>>C#>>正文


C# MeshData.AddUVs方法代码示例

本文整理汇总了C#中MeshData.AddUVs方法的典型用法代码示例。如果您正苦于以下问题:C# MeshData.AddUVs方法的具体用法?C# MeshData.AddUVs怎么用?C# MeshData.AddUVs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeshData的用法示例。


在下文中一共展示了MeshData.AddUVs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BlockData

	public override MeshData BlockData(int x, int y, int z, MeshData data, int submesh, Block[,,] blocks) {
		data.useRenderDataForCol = true;

		Mesh mesh = GetCustomModel();

		//Add the verticies, triangles, and uvs
		data.AddTriangles(mesh.triangles, submesh);
		data.AddVertices(mesh.vertices, mesh.normals, new Vector3(x, y - 0.5f, z), Quaternion.Euler(-90, 90 * rotation, 0));
		data.AddUVs(mesh.uv);

		return data;
	}
开发者ID:platformed,项目名称:Platformed-Game,代码行数:12,代码来源:ModelBlock.cs

示例2: BlockData

	public override MeshData BlockData(int x, int y, int z, MeshData data, int submesh, Block[,,] blocks) {
		data.useRenderDataForCol = true;

		Vector3[] v = new Vector3[8];

		v[0] = new Vector3(-0.5f, -0.5f, -0.5f);
		v[1] = new Vector3(-0.5f, -0.5f, 0.5f);
		v[2] = new Vector3(-0.5f, -0.4f, -0.5f);
		v[3] = new Vector3(-0.5f, -0.4f, 0.5f);
		v[4] = new Vector3(0.5f, -0.5f, -0.5f);
		v[5] = new Vector3(0.5f, -0.5f, 0.5f);
		v[6] = new Vector3(0.5f, -0.4f, -0.5f);
		v[7] = new Vector3(0.5f, -0.4f, 0.5f);

		//Add floor verticies
		if (CheckSolid(blocks, x, y + 1, z, Direction.Down)) {
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.up);
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.up);
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.up);
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.up);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.Up));
		}

		if (CheckSolid(blocks, x, y - 1, z, Direction.Up)) {
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.down);
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.down);
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.down);
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.down);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.Down));
		}

		if (CheckSolid(blocks, x, y, z + 1, Direction.South)) {
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.forward);
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.forward);
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.forward);
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.forward);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.North));
		}

		if (CheckSolid(blocks, x, y, z - 1, Direction.North)) {
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.back);
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.back);
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.back);
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.back);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.South));
		}

		if (CheckSolid(blocks, x + 1, y, z, Direction.West)) {
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.right);
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.right);
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.right);
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.right);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.East));
		}

		if (CheckSolid(blocks, x - 1, y, z, Direction.East)) {
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.left);
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.left);
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.left);
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.left);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.West));
		}

		return data;
	}
开发者ID:platformed,项目名称:Platformed-Game,代码行数:71,代码来源:FloorBlock.cs

示例3: BlockData

	/// <summary>
	/// Adds the blocks to a meshdata 
	/// </summary>
	/// <param name="x">X position of the block</param>
	/// <param name="y">Y position of the block</param>
	/// <param name="z">Z position of the block</param>
	/// <param name="data">The meshdata to add to</param>
	/// <param name="submesh">The submesh to put the block on</param>
	/// <param name="ignoreChunk">If the solidity of the neighboring blocks should be checked</param>
	/// <returns>Meshdata with added block meshdata</returns>
	public virtual MeshData BlockData(int x, int y, int z, MeshData data, int submesh, Block[,,] blocks) {
		data.useRenderDataForCol = true;

		Vector3[] v = new Vector3[8];

		v[0] = new Vector3(-0.5f, -0.5f, -0.5f);
		v[1] = new Vector3(-0.5f, -0.5f, 0.5f);
		v[2] = new Vector3(-0.5f, 0.5f, -0.5f);
		v[3] = new Vector3(-0.5f, 0.5f, 0.5f);
		v[4] = new Vector3(0.5f, -0.5f, -0.5f);
		v[5] = new Vector3(0.5f, -0.5f, 0.5f);
		v[6] = new Vector3(0.5f, 0.5f, -0.5f);
		v[7] = new Vector3(0.5f, 0.5f, 0.5f);

		//Add cube verticies

		//Top
		if (!CheckSolid(blocks, x, y + 1, z, Direction.Down)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x - 1, y + 1, z    , Direction.East),
				CheckSolid(blocks, x - 1, y + 1, z + 1, Direction.East),
				CheckSolid(blocks, x    , y + 1, z + 1, Direction.South),
				CheckSolid(blocks, x + 1, y + 1, z + 1, Direction.South),
				CheckSolid(blocks, x + 1, y + 1, z    , Direction.West),
				CheckSolid(blocks, x + 1, y + 1, z - 1, Direction.West),
				CheckSolid(blocks, x    , y + 1, z - 1, Direction.North),
				CheckSolid(blocks, x - 1, y + 1, z - 1, Direction.North)
			});
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[0]));
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[1]));
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[2]));
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[3]));
			data.AddQuadTriangles(submesh, FlipQuad(ao));
			data.AddUVs(FaceUVs(Direction.Up));
		}

		//Bottom
		if (!CheckSolid(blocks, x, y - 1, z, Direction.Up)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x - 1, y - 1, z    , Direction.East),
				CheckSolid(blocks, x - 1, y - 1, z - 1, Direction.East),
				CheckSolid(blocks, x    , y - 1, z - 1, Direction.North),
				CheckSolid(blocks, x + 1, y - 1, z - 1, Direction.North),
				CheckSolid(blocks, x + 1, y - 1, z    , Direction.West),
				CheckSolid(blocks, x + 1, y - 1, z + 1, Direction.West),
				CheckSolid(blocks, x    , y - 1, z + 1, Direction.South),
				CheckSolid(blocks, x - 1, y - 1, z + 1, Direction.South)
			});
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[0]));
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[1]));
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[2]));
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[3]));
			data.AddQuadTriangles(submesh, FlipQuad(ao));
			data.AddUVs(FaceUVs(Direction.Down));
		}

		//North
		if (!CheckSolid(blocks, x, y, z + 1, Direction.South)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x    , y - 1, z + 1, Direction.Up),
				CheckSolid(blocks, x + 1, y - 1, z + 1, Direction.Up),
				CheckSolid(blocks, x + 1, y    , z + 1, Direction.East),
				CheckSolid(blocks, x + 1, y + 1, z + 1, Direction.East),
				CheckSolid(blocks, x    , y + 1, z + 1, Direction.Down),
				CheckSolid(blocks, x - 1, y + 1, z + 1, Direction.Down),
				CheckSolid(blocks, x - 1, y    , z + 1, Direction.West),
				CheckSolid(blocks, x - 1, y - 1, z + 1, Direction.West)
			});
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[0]));
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[1]));
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[2]));
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[3]));
			data.AddQuadTriangles(submesh, FlipQuad(ao));
			data.AddUVs(FaceUVs(Direction.North));
		}

		//South
		if (!CheckSolid(blocks, x, y, z - 1, Direction.North)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x    , y - 1, z - 1, Direction.Up),
				CheckSolid(blocks, x - 1, y - 1, z - 1, Direction.Up),
				CheckSolid(blocks, x - 1, y    , z - 1, Direction.East),
				CheckSolid(blocks, x - 1, y + 1, z - 1, Direction.East),
				CheckSolid(blocks, x    , y + 1, z - 1, Direction.Down),
				CheckSolid(blocks, x + 1, y + 1, z - 1, Direction.Down),
				CheckSolid(blocks, x + 1, y    , z - 1, Direction.West),
				CheckSolid(blocks, x + 1, y - 1, z - 1, Direction.West)
			});
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.back, CalculateVertexColor(ao[0]));
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.back, CalculateVertexColor(ao[1]));
//.........这里部分代码省略.........
开发者ID:platformed,项目名称:Platformed-Game,代码行数:101,代码来源:Block.cs


注:本文中的MeshData.AddUVs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。