C++ 使用Libnoise生成高度贴图

C++ 使用Libnoise生成高度贴图,c++,eclipse,terrain,perlin-noise,C++,Eclipse,Terrain,Perlin Noise,我正在尝试实现libnoise库,并生成一个高度贴图,然后将其导入L3DT,使用Perlin noise算法渲染基本的3D地形。这是我作为计算机科学本科生的最后一年项目。本主题本质上是以地形生成为重点的程序性内容生成 我已经正确设置了EclipseCDT,并链接了所有必要的头文件和库。该程序与libnoise教程系列中的描述完全相同,特别是我将在此处链接的第三个教程: 一切似乎都很正常,构建成功,程序运行完成,但无论我做什么,输出位图文件“output.bmp”都不会呈现在可执行文件的目录中

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

我已经正确设置了EclipseCDT,并链接了所有必要的头文件和库。该程序与libnoise教程系列中的描述完全相同,特别是我将在此处链接的第三个教程:

一切似乎都很正常,构建成功,程序运行完成,但无论我做什么,输出位图文件“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");
}
/*
*Noise.cpp
*
*创建日期:2015年2月23日
*    
*/
#包括
#包括
#包括
#包括
使用命名空间噪波;//设置噪波类对象使用的引用
使用名称空间std;
void main()
{
//噪声贴图的创建
module::Perlin module;//实例化要用作噪波生成源的Perlin类对象。
utils::NoiseMap heightMap;//创建二维空噪波贴图。
utils::NoiseMapBuilderPlane heightMapBuilder;//用于使用从(x,y)平面获取的噪波值填充噪波贴图。
heightMapBuilder.SetSourceModule(Module);//将柏林模块设置为噪声产生源。
heightMapBuilder.SetDestNoiseMap(heightMap);//将空噪波贴图设置为平面噪波贴图生成器输出的目标。
heightMapBuilder.SetDestSize(256256);//设置输出噪波贴图的大小。
heightMapBuilder.SetBounds(2.0,6.0,1.0,5.0);//定义生成噪波值的边界矩形的顶点。下x、上x、下y、上y。
heightMapBuilder.Build();//构建噪波贴图。
//渲染地形高度贴图
渲染器图像渲染器;
utils::图像;
renderer.SetSourceNoiseMap(heightMap);
渲染器.setDestinmage(图像);
Render.Render();
//将高度贴图图像写入输出文件
utils::WriterBMP writer;
writer.SetSourceImage(图像);
SetDestFilename(“output.bmp”);
系统(“暂停”);
}

在以下代码行中,您使用图像数据和文件名设置了一个
utils::WriterBMP
实例

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

但实际上,您从未调用
writer
函数来写入图像数据。我实际上无法从他们的文档中找到该类或函数名。但是我很确定你可以很容易地解决这个问题。

在创建
编写器之后,你可能错过了将数据写出来的一些步骤。我是世上最大的白痴。缺少一行执行实际写入输出的代码。这么简单的错误,这么多小时的头痛。谢谢你,伙计@赛纳拉扬:如果πάνταῥεῖ'回答你的问题,请考虑接受或投票表决。