コード例 #1
0
ファイル: MapMesh.cs プロジェクト: maikramer/Infinity-Worlds
		private IEnumerator SetMesh()
		{
			var mapParameters = _mapGenerator.parameters;
			mapParameters.noisePosition = new Vector2(transform.position.x, transform.position.z);
			var noiseGen = new ThreadedNoise {parameters = mapParameters};
			noiseGen.Start();
			yield return StartCoroutine(noiseGen.WaitFor());
			var noiseMap = noiseGen.retNoiseMap;

			var mapMeshData = new MapMeshData(noiseMap, _mapGenerator.parameters.baseHeight,
				_mapGenerator.parameters.heightCurve, _mapGenerator.parameters.levelOfDetail);
			var generator = new ThreatedMeshGenerator {mapMeshData = mapMeshData};
			generator.Start();
			yield return StartCoroutine(generator.WaitFor());
			var meshData = generator.meshData;

			var mesh = meshData.CreateMesh();
			mesh.name = "Map Mesh";
			_meshFilter.mesh = mesh;
			var meshBounds = mesh.bounds;
			var center = transform.position +
			             new Vector3(_mapGenerator.parameters.size / 2, 0, _mapGenerator.parameters.size / 2);
			bounds = new Bounds(center, meshBounds.size);

			isMeshReady = true;
		}
コード例 #2
0
ファイル: MapMesh.cs プロジェクト: maikramer/Infinity-Worlds
		//Todo: Gerar o noiseMap somente para os valores utilizados
		private IEnumerator SetCollider()
		{
			var mapParameters = _mapGenerator.parameters;
			mapParameters.noisePosition = new Vector2(transform.position.x, transform.position.z);
			mapParameters.levelOfDetail = 6;
			var noiseGen = new ThreadedNoise {parameters = mapParameters};
			noiseGen.Start();
			yield return StartCoroutine(noiseGen.WaitFor());
			var noiseMap = noiseGen.retNoiseMap;

			var mapMeshData = new MapMeshData(noiseMap, _mapGenerator.parameters.baseHeight,
				_mapGenerator.parameters.heightCurve, _mapGenerator.parameters.levelOfDetail);
			var generator = new ThreatedMeshGenerator {mapMeshData = mapMeshData};
			generator.Start();
			yield return StartCoroutine(generator.WaitFor());
			var meshData = generator.meshData;

			var mesh = meshData.CreateMesh();
			mesh.name = "Collider Mesh";
			_meshCollider.sharedMesh = mesh;
			_meshCollider.material = _mapGenerator.defaultPhysicMaterial;

			isColliderReady = true;
		}