使用 Libnoise 生成高度图

Using Libnoise to generate a heightmap

我正在尝试实现 libnoise 库并生成高度图,然后我可以将其导入 L3DT 以使用 Perlin 噪声算法渲染基本的 3D 地形。这是我作为计算机科学本科生的最后一年项目。该主题本质上是专注于地形生成的程序内容生成。

我已经正确设置了我的 Eclipse CDT 并且 link 编辑了所有必要的头文件和库。该程序与 libnoise 教程系列中描述的完全相同,特别是我将在此处 link 的第三个教程: http://libnoise.sourceforge.net/tutorials/tutorial3.html

一切似乎工作正常,构建成功,程序运行完成,但无论我做什么输出位图文件,"output.bmp" 都没有呈现在可执行文件的目录中。

我在这里错过了什么?输出文件是否放置在默认目录中的其他位置?

这里是进一步说明的代码:

  /*
  * Noise.cpp
  *
  *  Created on: 23-Feb-2015
  *    
  */

  #include <iostream>
  #include <stdio.h>
  #include <noise.h>
  #include <noiseutils.h>

  using namespace noise; // Sets reference for usage of the the noise class objects
  using namespace std;
  void main()
  {
        // CREATION OF THE NOISE MAP

        module::Perlin Module; // Instantiates the Perlin class object to be used as the source for the noise generation.
        utils::NoiseMap heightMap; // Creation of the 2D empty noise map.
        utils::NoiseMapBuilderPlane heightMapBuilder; // Used to fill the noise map with the noise values taken from an (x,y) plane.

        heightMapBuilder.SetSourceModule (Module); // Sets the Perlin module as the source for noise generation.
        heightMapBuilder.SetDestNoiseMap (heightMap); // Sets the empty noise map as the target for the output of the planar noise map builder.

        heightMapBuilder.SetDestSize(256,256); // Sets the size of the output noise map.

        heightMapBuilder.SetBounds (2.0, 6.0, 1.0, 5.0); // Defines the vertices of the bounding rectangle from which the noise values are produced. lower x, upper x, lower y, upper y.

        heightMapBuilder.Build (); // Builds the noise map.

// RENDERING THE TERRAIN HEIGHT MAP

        utils::RendererImage renderer;
        utils::Image image;
        renderer.SetSourceNoiseMap(heightMap);
        renderer.SetDestImage(image);
        renderer.Render();
// WRITING THE HEIGHT MAP IMAGE TO AN OUTPUT FILE

        utils::WriterBMP writer;
        writer.SetSourceImage(image);
        writer.SetDestFilename("output.bmp");

        system("pause");
}

在下面的代码行中,您使用图像数据和文件名

设置了一个utils::WriterBMP实例
    utils::WriterBMP writer;
    writer.SetSourceImage(image);
    writer.SetDestFilename("output.bmp");

但是你从来没有真正调用过writer的函数来写入图像数据。我实际上无法从他们的文档中找到 class 或函数名称应该是什么。但我很确定你可以很容易地解决这个问题。