karim.salama Posted March 22, 2022 Share Posted March 22, 2022 Hi, I'm trying to generate a Unigine::LandscapeLayerMap using a Unigine::Image. According to this page, here is my current approach : Unigine::LandscapeLayerMapPtr CreateTerrainTile(const GenerationInfo& info, const TileCoordinate& coord, const TileGeometry& geom) { auto image = GeneratePerlinNoiseTerrainImage(info, coord, geom); auto create_callback = [image](Unigine::LandscapeMapFileCreatorPtr, Unigine::LandscapeImagesPtr images, int x, int y) { auto height_image = images->getHeight(); height_image->create2D(image->getWidth(), image->getHeight(), image->getFormat(), image->getNumMipmaps()); height_image->copy(image, 0, 0, 0, 0, image->getWidth(), image->getHeight()); auto albedo_image = images->getAlbedo(); albedo_image->create2D(image->getWidth(), image->getHeight(), image->getFormat(), image->getNumMipmaps()); albedo_image->copy(image, 0, 0, 0, 0, image->getWidth(), image->getHeight()); }; auto creator = Unigine::LandscapeMapFileCreator::create(); Unigine::String world_path = Unigine::World::getPath(); const auto tile_name = world_path.filename().get() + std::string("_terrain_") + std::to_string(coord.x) + "_" + std::to_string(coord.y); auto lmap_path = info.save_path + "/" + tile_name + ".lmap"; creator->setPath(lmap_path.c_str()); creator->setGrid({1, 1}); creator->setResolution({info.size_x, info.size_y}); creator->addCreateCallback(Unigine::MakeCallback(create_callback)); creator->run(); auto layer_map = Unigine::LandscapeLayerMap::create(); layer_map->setPath(lmap_path.c_str()); layer_map->setName(tile_name.c_str()); return layer_map; } For now, I'm using the same image for both height and albedo, the image has a R32F format. This results in an empty LandscapeLayerMap (with no geometry). Is there something I'm missing here? Thanks in advance 1 Link to comment
silent Posted March 23, 2022 Share Posted March 23, 2022 Hi Karim, Do you have any errors in console after launching this code? You can also check built-in C++ LT samples in SDK Browser -> Samples -> Demos -> CPP Samples -> Landscape Creation. Maybe you will have a better understanding after reading these samples code. Thanks! 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
karim.salama Posted March 23, 2022 Author Share Posted March 23, 2022 Hi silent. No there are not any errors during the terrain generation. Sure I will check out the samples and tell you how it went. Thanks Link to comment
karim.salama Posted March 23, 2022 Author Share Posted March 23, 2022 Found the issue! I did not apply any LandscapeMapFileSettings. Added the same settings as in the sample and now it's working. Thank you! 1 Link to comment
Recommended Posts