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


C# MeshData.CreateMesh方法代码示例

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


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

示例1: DrawMesh

	public void DrawMesh(MeshData meshData, Texture2D texture) {
		currentTexture = texture;
		//print (currentTexture.width + " " + currentTexture.height);
		
		meshFilter.sharedMesh = meshData.CreateMesh ();
		meshRenderer.sharedMaterial.mainTexture = texture;
		
		GetComponent<MeshCollider>().sharedMesh = meshFilter.sharedMesh;
	}
开发者ID:LudicrousJimblemen,项目名称:Simulacrum,代码行数:9,代码来源:MapDisplay.cs

示例2: Generate

	public void Generate(TerrainConfig config) {
		config.MapHeight += 1;
		config.MapWidth += 1;

		Config = config;

		float[,] noiseMap = Noise.GenerateNoiseMap(
			config.MapWidth,
			config.MapHeight,
			config.Seed,
			config.NoiseScale,
			config.Octaves,
			config.Persistance,
			config.Lacunarity,
			config.Offset
		);
		Color[] colorMap = new Color[config.MapWidth * config.MapHeight];
		for (int y = 0; y < config.MapHeight; y++) {
			for (int x = 0; x < config.MapWidth; x++) {
				float currentHeight = noiseMap[x, y];
				for (int i = 0; i < TerrainTypes.Length; i++) {
					if (currentHeight <= TerrainTypes[i].Height) {
						colorMap[y * config.MapWidth + x] = TerrainTypes[i].Color;
						//print (y * config.MapWidth + x);
						break;
					}
				}
			}
		}

		int width = noiseMap.GetLength(0);
		int height = noiseMap.GetLength(1);
		float topLeftX = (width - 1) / -2f;
		float topLeftZ = (height - 1) / 2f;

		MeshData meshData = new MeshData(width, height);
		int vertexIndex = 0;

		for (int y = 0; y < height; y++) {
			for (int x = 0; x < width; x++) {

				meshData.Vertices[vertexIndex] = new Vector3((topLeftX + x) / 4, 0, (topLeftZ - y) / 4);
				meshData.Uvs[vertexIndex] = new Vector2((x / (float) width), (y / (float) height));

				if (x < width - 1 && y < height - 1) {
					meshData.AddTriangle(vertexIndex, vertexIndex + width + 1, vertexIndex + width);
					meshData.AddTriangle(vertexIndex + width + 1, vertexIndex, vertexIndex + 1);
				}

				vertexIndex++;
			}
		}

		Texture = new Texture2D(width, height);
		Texture.filterMode = FilterMode.Point;
		Texture.wrapMode = TextureWrapMode.Clamp;
		Texture.SetPixels(colorMap);
		Texture.Apply();

		Mesh finalMesh = meshData.CreateMesh();

		GetComponent<MeshFilter>().sharedMesh = finalMesh;
		GetComponent<MeshRenderer>().material.mainTexture = Texture;

		GetComponent<MeshCollider>().sharedMesh = finalMesh;
	}
开发者ID:LudicrousJimblemen,项目名称:Simulacrum,代码行数:66,代码来源:TerrainGenerator.cs

示例3: OnMeshDataReceived

		void OnMeshDataReceived(MeshData meshData) {
			mesh = meshData.CreateMesh ();
			hasMesh = true;

			updateCallback ();
		}
开发者ID:SebLague,项目名称:Procedural-Landmass-Generation,代码行数:6,代码来源:EndlessTerrain.cs

示例4: DrawMesh

 public void DrawMesh(MeshData meshData, Texture2D texture)
 {
     meshFilter.sharedMesh = meshData.CreateMesh();
     //meshRenderer.sharedMaterial.mainTexture = texture;
 }
开发者ID:BaptisteMarechaux,项目名称:Blow-Game-2016,代码行数:5,代码来源:InTerrainDisplay.cs

示例5: OnMeshDataReceived

		void OnMeshDataReceived(MeshData meshData) {
			meshFilter.mesh = meshData.CreateMesh ();
		}
开发者ID:SebLague,项目名称:Procedural-Landmass-Generation,代码行数:3,代码来源:EndlessTerrain.cs

示例6: DrawMesh

    public void DrawMesh(MeshData meshData)
    {
        meshFilter.sharedMesh = meshData.CreateMesh();

        meshFilter.transform.localScale = Vector3.one * FindObjectOfType<MapGenerator>().terrainData.uniformScale;
    }
开发者ID:rense,项目名称:Procedural-Landmass-Generation,代码行数:6,代码来源:MapDisplay.cs

示例7: OnMeshDataReceived

 void OnMeshDataReceived(MeshData meshData)
 {
     mesh = meshData.CreateMesh();
     
     hasMesh = true;
 }
开发者ID:BaptisteMarechaux,项目名称:Blow-Game-2016,代码行数:6,代码来源:InEndlessTerrain.cs


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