如何固定地形Z轴在末端和X轴上沿X轴的下降?

发布于 2025-02-01 10:04:58 字数 1138 浏览 1 评论 0原文

因此,我正在为液压侵蚀地形生成器重写旧代码,我在旧代码上知道这个问题,但从未问过为什么,但是现在我正在重写它,并希望使所有内容顺利进行。

地形在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

enter image description here

enter image description here

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 技术交流群。

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

发布评论

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