Jump to content

Road builder


photo

Recommended Posts

These components let your create a road and also carve the terrain under it like in Unreal or Unity.
spline_tool.zip
0111.thumb.png.75c3e69c2a165b78ddbc46267adb3560.png

1. Import the road tool constructor into your project.001.thumb.png.8ebc5cc0bc98efec8654d1b1d4a32ed7.png

2. Attach BuildRoad.cs to your camera.
3. Press play.0
4. You should see a red dot on your terrain, if not that's mean the ray don't collide with the terrain ( check terrain intersection ).
002.thumb.png.d964e67d78bb43edc7c9d6e19f534920.png
5. Create your road by clicking on the terrain, F to preview to road, R to delete last point, once you finished the road press G to save it.
003.thumb.png.729060ee862033ef5767df34c6e1373a.png
6. Close the window, now in the editor, create a new splinegraph, and place it at 0.0.0 position, select the spline you just saved, you can press edit to see it ( there is a view distance limit so you might not see it )
004.thumb.png.0e76716dfb780d3108c5d4ee81c32f4a.png

7. Now it's time to carve the terrain, but it will only work for normalized terrain, and I don't think the normalized button will actually normalize the terrain, so the terrain should be normalized before the import in Unigine. For example, in Gaea, you can export your terrain with normalized option.

8. Create a mesh that will guide the terrain carving:
Create a 32x20 plane, intersection should be enabled by default, change intersection mask from 0 to 1, place the node at 0.0.0 position, then drag and drop this mesh into the asset browser to create a .node.
005.thumb.png.0c28e3989acbbba0bfc2639cca5feb0a.png

9. Add this node as segment to the WorldSplineGraph ( click and drag the mouse to select all segments at once, push the edit spline button to see segment option ).
9.1 To actually see the road you have to add the LoadGraph.cs component to WorldSplineGraph and press play. WorldSplineGraph sometime take time to load...
9.2 If you still don't see any road your node wasn't positioned at 0.0.0.
007.thumb.png.4b3c67fbcdeb37d8e9a8a590170f775b.png 

10. Deactivate BuildRoad.cs component on your camera, and add CarveTerrain.cs to the WorldSplineGraph.

11. Configure the component, I like to have a resolution of 2k for a 10k terrain, it mean 2k*2k ray will be performed.
11.1 I like to move the SplineGraph down like 1m to have a better carving of the terrain ( position of the splinegraph = 0.0.-1).
image.thumb.png.66fc72fd4fdeb91eb13033248dfc43fa.png

12. Now click play and press F to start the process.
009.thumb.png.c76586c6a016fe5725274fe81e050613.png

13. Close the windows, Create a new terrain with the exact same size and the same height scale ( the created lmap doesn't work yet ).
Add the newHeight and the newMask to the terrain.
010.thumb.png.12a21c08d2c9ac45faa81cdc62d70b4e.png

14. Now you can add your the road node.
011.thumb.png.e6feceeb534eb55315e550c2a3410580.png

15. It look bad ! Yes, because I can only create 8 bit image for terrain heightmap. If you know how to create a 16 bit pixel please help me and the terrain will fit the road perfectly.

This is the end, next images won't delete.

006.png

008.png

Edited by _dahu_
  • Like 4
Link to comment
  • _dahu_ changed the title to Road builder
×
×
  • Create New...