返回介绍

TerrainData.GetDetailLayer 获取细节层

发布于 2019-12-18 15:38:37 字数 2768 浏览 1394 评论 0 收藏 0

JavaScript => public function GetDetailLayer(xBase: int, yBase: int, width: int, height: int, layer: int): int[,];
C# =>public int[,] GetDetailLayer(int xBase, int yBase, int width, int height, int layer);

Parameters 参数

Description 描述

Returns a 2D array of the detail object density in the specific location.
在特定位置,返回物体细节密度的2D数组。

The Terrain system uses detail layer density maps. Each map is essentially a grayscale image where each pixel value denotes the number of detail objects that will be procedurally placed terrain area. That corresponds to the pixel. Since several different detail types may be used, the map is arranged into “layers” - the array indices of the layers are determined by the order of the detail types defined in the Terrain inspector (ie, when the Paint Details tool is selected).
地形系统使用细节层密度图。每贴图实际上是每像素值表示的地形区域中程序放置的细节对象数量的灰度图。对应的像素。可能被几个不同的细节类型使用,贴图被排列成‘层’,数组的索引的层是由地形面板中细节类型的定义的顺序决定的(即当油漆细节工具被选中)。

JavaScript:

// Set all pixels in a detail map below a certain threshold to zero.
	function DetailMapCutoff(t: Terrain, threshold: float) {
		// Get all of layer zero.
		var map = t.terrainData.GetDetailLayer(0, 0, t.terrainData.detailWidth, t.terrainData.detailHeight, 0);
 
		// For each pixel in the detail map...
		for (var y = 0; y < t.terrainData.detailHeight; y++) {
			for (var x = 0; x < t.terrainData.detailWidth; x++) {
				// If the pixel value is below the threshold then
				// set it to zero.
				if (map[x, y] < threshold) {
					map[x, y] = 0.0;
				}
			}
		}
 
		// Assign the modified map back.
		t.terrainData.SetDetailLayer(0, 0, 0, map);
	}

C#:

// Set all pixels in a detail map below a certain threshold to zero.
	function DetailMapCutoff(t: Terrain, threshold: float) {
		// Get all of layer zero.
		var map = t.terrainData.GetDetailLayer(0, 0, t.terrainData.detailWidth, t.terrainData.detailHeight, 0);
 
		// For each pixel in the detail map...
		for (var y = 0; y < t.terrainData.detailHeight; y++) {
			for (var x = 0; x < t.terrainData.detailWidth; x++) {
				// If the pixel value is below the threshold then
				// set it to zero.
				if (map[x, y] < threshold) {
					map[x, y] = 0.0;
				}
			}
		}
 
		// Assign the modified map back.
		t.terrainData.SetDetailLayer(0, 0, 0, map);
	}

terraindata

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文