Jump to content

Matching up edges of Terrain Tiles


photo

Recommended Posts

I'm wondering if someone has solved this already. I have a railroad that crosses over MANY tiles of terrain, and I'm having to adjust the terrain heights on each tile to line up with the terrain. Easy enough with the tools, but I'll no doubt soon experience mismatching values on the terrain edges once I get to them.

 

Is there a script or something someone may have written to solve this or do I need to engineer this myself? Or is there something I need to do as a post process. I'm on the 7.7.14 SDK.

Link to comment

Hi Philip!

 

You can use our Landscape plugin (https://developer.unigine.com/en/docs/1.0/tools/editor/plugins/landscape/) in order to create proper terrain tiles. You have to prepare your imagery data properly though.

 

If you're talking about cracks between different terrains then I'm afraid you can't do that properly in 1.0 without changing the engine code. However, in 2.0 we introduced a bunch of methods which allows you to connect terrains with each other via code (https://developer.unigine.com/en/docs/1.0/scripting/library/objects/class.objectterrain#setLodTerrainBottom_ObjectTerrain_void).

 

Here's how we use it in landscape plugin:

forloop(int Y = 0; size_y) {
	forloop(int X = 0; size_x) {
		int current = Y * size_x + X;
		
		ObjectTerrain terrain = node_cast(landscape.getChild(current));
		
		if(X > 0) {
			ObjectTerrain neighbor = node_cast(landscape.getChild(current - 1));
			terrain.setLodTerrainLeft(neighbor);
		}
		else if(X < (size_x - 1)) {
			ObjectTerrain neighbor = node_cast(landscape.getChild(current + 1));
			terrain.setLodTerrainRight(neighbor);
		}
		
		if(Y > 0) {
			ObjectTerrain neighbor = node_cast(landscape.getChild(current - size_x));
			terrain.setLodTerrainBottom(neighbor);
		}
		else if(Y < (size_y - 1)) {
			ObjectTerrain neighbor = node_cast(landscape.getChild(current + size_x));
			terrain.setLodTerrainTop(neighbor);
		}
	}
}

Link to comment
×
×
  • Create New...