gamecreator Posted July 20, 2017 Share Posted July 20, 2017 Leadwerks Road To Terrain Snapper (with source code) I decided to write this tool after seeing a few members inquiring about roads in Leadwerks. I thought it might be easy to code and a good way to stretch my coding muscles as a break from game coding. The tool uses the information you provide in settings.txt to locate a map file and a road file and allows you to move and rotate the road on the terrain until you find a place you like. You can then snap the road to it so that every vertex of the road snaps to the terrain below it. When you quit the program, the program exports an OBJ file you can import into your 3D modeling program. Unfortunately the program doesn't keep your texturing information but since the source is included, you're welcome to add that in. The program also keeps track of the position of the road so that when you import it back into Leadwerks, you can type it in to the position boxes to put the road right where you snapped it (you'll probably need to multiply by 100 to match the editor format). You may be wondering why the road looks bad and the terrain is sticking through it. This is a combination of two things: 1. I didn't include any space between the road and the terrain. You can place the road as high off the ground as you feel is right once you put it back into the editor or your code. 2. The road in the screenshot is only 180 triangles. I suggest using more depending on your scene. The entire project with source code:http://www.mediafire.com/file/y1743umgg0q75x9/Road_To_Terrain_Snapper_project_and_source.zip Just the program:http://www.mediafire.com/file/xhbfy8hn7x5nr5i/Road_To_Terrain_Snapper.zip Enjoy! (The settings.txt file also lets you specify the resolution you would like to run your program at and fullscreen or windowed.) Thank you to macklebee for his help with this on the forums. 9 Quote Link to comment Share on other sites More sharing options...
reepblue Posted July 20, 2017 Share Posted July 20, 2017 Looks cool, I'd put the source on a git so people can fork/pull request changes and fixes. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Marcousik Posted July 20, 2017 Share Posted July 20, 2017 Great Idea, I miss a lot a Road maker but I think I don't undertand how it works... That's what I obtained as export.obj, but I can't use this as road: If the result contains all the curves of the terrain, well that's the same work as it requires the terrain to be smoothed ? Maybe I did not correct use it.. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 20, 2017 Author Share Posted July 20, 2017 9 hours ago, reepblue said: I'd put the source on a git so people can fork/pull request changes and fixes I don't use it but you're absolutely welcome to. No need to credit me in any way. 7 hours ago, Marcousik said: If the result contains all the curves of the terrain, well that's the same work as it requires the terrain to be smoothed ? If your terrain is flat/flattened, you won't need this tool. But if you have roads going up and down hills, I think it may be easier to just snap the road to it instead of trying to adjust the terrain spot by spot. But I think a combination of the two may be best. 2 hours ago, jen said: How accurate are the exported roads? Are they 1:1 with the surface the road is patched on on the terrain? Yes. There are no adjustments after you snap the terrain. Vertices are saved as they are. Edit: correction/clarity: the road is actually lowered uniformly to 0 height so that it's at the origin and that it's not way up in the air when you import it into your modeling program. However, the vertices will match terrain height exactly. All you need to do is drag it back up once you import it into the editor. If you prefer to keep the road at the terrain height during export, you can remove +lowestpoint from the below code. // "Subtract" lowestpoint from all vetex heights to put road closer to origin fprintf(f, "v %f %f %f\n", vpos.x, -vpos.z+lowestpoint, vpos.y); Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted July 20, 2017 Share Posted July 20, 2017 Great tool! Lots of potential for expansion too, it would be really cool to do some automatic terrain smoothing/leveling/grading in the future so the roads are minimally angled even if they're going up a hill, etc. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 21, 2017 Author Share Posted July 21, 2017 That's a good idea. I gave it a shot just out of curiosity but either SetElevation / SetHeight don't work on terrain or I used it incorrectly. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted July 21, 2017 Share Posted July 21, 2017 You can't level the terrain but maybe you can level/smooth the extracted .obj ? Terrain could be in a second time in a classic way be corrected... Customizable roads preset models would be very great too Quote Link to comment Share on other sites More sharing options...
Charrua Posted July 22, 2017 Share Posted July 22, 2017 thanks for sharing this beauty It remembers me an old technique of making shadows.. by creating a black+alpha mesh that overlaps the terrain/buildings with a small offset, when almost all thing were made by hand! 1 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Yue Posted July 22, 2017 Share Posted July 22, 2017 This System? 1 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 22, 2017 Author Share Posted July 22, 2017 Jorn is doing something more advanced with splines which I think he said he'll be selling at some point. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted July 22, 2017 Share Posted July 22, 2017 this is just genious. This should be incorporated as purchasable addon. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.