如何固定地形Z轴在末端和X轴上沿X轴的下降?
因此,我正在为液压侵蚀地形生成器重写旧代码,我在旧代码上知道这个问题,但从未问过为什么,但是现在我正在重写它,并希望使所有内容顺利进行。
地形在X轴上有一个进步
这是我在边缘的z轴上的问题, 如果您需要更多代码,只需告诉我
/I.SSTATIC.NET/U4HQG.PNG“ alt =”在此处输入图像描述”>
public void GenerateHeightMap () {
mapSizeWithBorder = mapSize + erosionBrushRadius * 2;
map = FindObjectOfType<HeightMapGenerator> ().GenerateHeightMap (mapSizeWithBorder);
terrain.terrainData = GenerateTerrain(terrain.terrainData);
}
TerrainData GenerateTerrain(TerrainData terrainData) {
Erode();
float[,] noiseMap = new float[mapSizeWithBorder,mapSizeWithBorder];
int x = 0;
int y = 0;
for (int i = 0; i < map.Length; ++i)
{
noiseMap[x, y] = map[i];
y++;
if (y == mapSizeWithBorder)
{
y = 0;
x++;
}
}
terrainData.size = new Vector3(mapSizeWithBorder * scale, elevationScale, mapSizeWithBorder * scale);
terrainData.SetHeights(0, 0, (noiseMap));
return terrainData;
}
so I'm rewriting my old code for a hydraulic erosion terrain generator, I knew about this problem on my old code but never asked why, but now I'm rewriting it and want to get everything working smoothly
this is the issue on my Z-axis at the edges the terrain has a step up and on the X-axis it goes down but it's hard to see in the photo plz tell me why
I'm using the built-in terrain generator FYI if you need more code just tell me
public void GenerateHeightMap () {
mapSizeWithBorder = mapSize + erosionBrushRadius * 2;
map = FindObjectOfType<HeightMapGenerator> ().GenerateHeightMap (mapSizeWithBorder);
terrain.terrainData = GenerateTerrain(terrain.terrainData);
}
TerrainData GenerateTerrain(TerrainData terrainData) {
Erode();
float[,] noiseMap = new float[mapSizeWithBorder,mapSizeWithBorder];
int x = 0;
int y = 0;
for (int i = 0; i < map.Length; ++i)
{
noiseMap[x, y] = map[i];
y++;
if (y == mapSizeWithBorder)
{
y = 0;
x++;
}
}
terrainData.size = new Vector3(mapSizeWithBorder * scale, elevationScale, mapSizeWithBorder * scale);
terrainData.SetHeights(0, 0, (noiseMap));
return terrainData;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论