Jump to content

[SOLVED] Terrain node file doesn't contain reference to filepath


photo

Recommended Posts

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

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
  • 10 months later...

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

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

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

Hi,

 

You should pass path to setTerrainName instead of tile name. Instead of

terrainTile.setTerrainName(tileName);

use

terrainTile.setTerrainName(tilePath);
Link to comment
×
×
  • Create New...