philip.atha Posted May 14, 2014 Share Posted May 14, 2014 I'm automating the process of creating tiled terrains through code and I have an unusual problem when saving the node files. <?xml version="1.0" encoding="utf-8"?> <nodes version="1.19"> <node type="ObjectTerrain" id="575191784" name="Terrain_x7_y11"> <terrain/> <lod_distance>20</lod_distance> <lod_progression>2</lod_progression> <flatness_threshold>3</flatness_threshold> <visible_distance>8000</visible_distance> Basically my terrain tag is completely empty. I'm not sure that my script has any knowledge of the terrain filepath being saved at all. Should I: 1. Generate the terrain. 2. Save it to a node file. 3. Load the terrain node file ?? Or is there some other/better method for this Link to comment
sebastianbah Posted May 15, 2014 Share Posted May 15, 2014 Hello, If I understand you correctly, you create terrain from code so you'll get *.ter files only after Save() function call. If you want to create terrain from existing files you can try to load it from the script. For more detailed instruction, I'm afraid we need your code sample. Link to comment
philip.atha Posted March 19, 2015 Author Share Posted March 19, 2015 I need to revive this thread since I discovered I didn't quite solve my problem in the way that I thought. string rootPath = "area1/terrain/tile_x0_y0" string tilePath = rootPath + ".ter"; terrainTile.create(hMap, stepSize, maxHeight); terrainTile.setName(tileName); terrainTile.setLodDistance(lods); terrainTile.setFlatnessThreshold(flatten); terrainTile.setVisibleDistance(vDistance); terrainTile.setMaterial("terrain_base", "*"); terrainTile.setDiffuseTextureName(diffuseFileName); terrainTile.setNormalTextureName(normalFileName); terrainTile.setMaskTextureName(maskFileName); terrainTile.save(tilePath); string nodePath = rootPath + ".node"; engine.world.saveNode(nodePath, terrainTile); //Here I expect saveNode() to store a reference to the .ter file. log.message("Saving terrain file: " + nodePath +"\n"); terrainTile.setPosition(dvec3(posX, posY, 0)); engine.editor.addNode(terrainTile); The resulting nodefile from the above has no link to the .ter file inside it. So when I go to load this node file into the editor, I get: World::loadNode(): can't load node Link to comment
silent Posted March 20, 2015 Share Posted March 20, 2015 Hi Philip, Please, check our terrain creator inside <SDK>/data/editor/editor_creator_terrain.h and <SDK>/editor/editor_objects_terrain.h files. Probably, you will need to call saveTerrain() also. Thanks! 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
philip.atha Posted March 20, 2015 Author Share Posted March 20, 2015 That's not particularly helpful. I can generate terrains and save .ter files just fine. The issue is that I cannot reload them into a scene from a node file. In addition I'm using Version: 2014-07-07, so saveTerrain() is not a part of that API. The referenced information in the above XML is all I see, but nowhere in the document does it reference the .ter file to load, and when I go to manually add the node into the scene I get the error above. Link to comment
unclebob Posted March 21, 2015 Share Posted March 21, 2015 Hey Philip, Before saving terrain you have to call setTerrainName as well in order to save link to .ter file. Link to comment
philip.atha Posted March 23, 2015 Author Share Posted March 23, 2015 As you can see from the code segment above, I've done that for the terrain node. Now I've just added terrainTile.SetTerrainName(tileName); and it does seem to propogate to the terrain node file, but still nothing loads... Link to comment
unclebob Posted March 24, 2015 Share Posted March 24, 2015 Hi, You should pass path to setTerrainName instead of tile name. Instead of terrainTile.setTerrainName(tileName); use terrainTile.setTerrainName(tilePath); Link to comment
philip.atha Posted March 24, 2015 Author Share Posted March 24, 2015 That did it! However that function name is a very poor representation of what it does. I assume that saveTerrain replaces setTerrainName ?? Link to comment
silent Posted March 24, 2015 Share Posted March 24, 2015 saveTerrainName() was added Unigine 2.0 (and save() was renamed to saveTerrain()): https://developer.unigine.com/en/docs/1.0/start/migration_guide/cpp_api_migration/api_objectterrain_class_migration 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
Recommended Posts