gpt4 book ai didi

c# - Libnoise XNA translate perlin 导致失真

转载 作者:太空宇宙 更新时间:2023-11-03 14:05:08 25 4
gpt4 key购买 nike

我一直在研究在 XNA 中生成噪声的库。 Libnoise 似乎是最合乎逻辑的选择。该库非常易于使用并产生了一些很好的结果。不过,我在生成其他部分时遇到了一些麻烦。C++ 文档对此有一个非常好的功能:

  utils::NoiseMap heightMap;
utils::NoiseMapBuilderPlane heightMapBuilder;
heightMapBuilder.SetSourceModule (myModule);
heightMapBuilder.SetDestNoiseMap (heightMap);
heightMapBuilder.SetDestSize (256, 256);
heightMapBuilder.SetBounds (6.0, 10.0, 1.0, 5.0); //this one!
heightMapBuilder.Build ();
//http://libnoise.sourceforge.net/tutorials/tutorial3.html

XNA 版本不是这样工作的,而是使用平移函数在生成的高度图中“移动”。

翻译.cs

/// <summary>
/// Initializes a new instance of Translate.
/// </summary>
/// <param name="x">The translation on the x-axis.</param>
/// <param name="y">The translation on the y-axis.</param>
/// <param name="z">The translation on the z-axis.</param>
/// <param name="input">The input module.</param>
public Translate(double x, double y, double z, ModuleBase input)
: base(1)
{
this.m_modules[0] = input;
this.X = x;
this.Y = y;
this.Z = z;
}

用法

        perlin = new Perlin(zoom, 4, 0.2, 4, 1, QualityMode.Medium);
Translate translate = new Translate(location.X, location.Y, 0, perlin);
this.m_noiseMap = new Noise2D(200, 200, translate);
this.m_noiseMap.GeneratePlanar(-1 * zoom, 1 * zoom, -1 * zoom, 1 * zoom, true);

这就是问题所在;虽然它确实平移了高度图,但它也扭曲了高度图。这看起来很奇怪,因为 perlin 保持不变。我本可以想象改变 Z 轴会导致高度图发生变化,但我只是改变了 X 轴。

enter image description here

对此有什么想法吗?

最佳答案

看起来主要问题是高度图使用什么维度来生成结果。

因此,高度图构建器使用什么尺寸作为高程非常模糊,尤其是在应用投影之后...

在我看来,X 正在控制海拔高度(如果您观察海洋,看起来就像是在提高海平面)。虽然这可能没有多大意义,但最好检查源代码并查看其实际使用的维度。像这样的 3D 噪声通常不关心哪个维度是哪个,只要你让它与你的应用程序保持一致。

关于c# - Libnoise XNA translate perlin 导致失真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9525603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com