[RELEASE][World Editor Extension] Road-edge Generator

Discussion in 'World Editor' started by stuffi3000, Apr 28, 2024.

  1. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Introduction

    Dear Community,
    I am pleased to present you yet another lua extension for the World Editor: Road-edge Generator. As the name suggests, it offers World Editor users a one-click solution to generator road-edges for DecalRoads placed in the level.

    This extension was created because I got fed up with the fact that there wasn't a possibility to automatically place edges next to your decal roads. Do you also want to save hours of manual work to place road-edges on both sides of your decal roads? This is for you!

    Presentation


    This is the extension's window. It comes with a small amount of parameters and a built-in tutorial. There are also lots of additional infos in the tooltips.

    Here's a short video of the window in action (if the embedded video doesn't work, click on the link below):


    (https://imgur.com/a/1FTprzC)

    Features:

    • Generate road-edges (or any other type of DecalRoad) next/parallel to existing DecalRoads
    • Chose the width of the new edge-road, its overlap with the DecalRoad, material, render priority and start/end fade
    • Chose on which side of the DecalRoad the edge should be placed, with an option to invert the placement (from end to start instead of start to end)
    • Generate edges for multiple DecalRoads at the same time
    • Randomise node placement
    Disclaimer: the tool does not work in 100% of all cases. Due to how the World Editor places roads, the tool isn't always accurate in very tight, short turns. User experience might therefore vary, but the general result is very good.

    Installation

    To install this extension, follow these steps:
    1. Download the .zip file attached to this thread
    2.1. Open up the file and place it's content into your userfolder.
    2.2. Alternatively, open up the file and place its content into your BeamNG Drive Root directory (can be easily found by right-clicking on BeamNG Drive in Steam -> Manage -> Browse local files): Place the lua folder where the lua folder is.
    2.3. Alternatively, navigate through all folders in the .zip attached and place the "roadedgegenerator.lua" file in BeamNG.drive\lua\ge\extensions\editor.

    Once done, it should automatically show up in your editor under Window -> Road-edge Generator.
    If it doesn't show up:
    - Make sure you placed the .lua file in the right directory and no other software is blocking its execution
    - In your editor, go to Window -> Extensions Editor and check whenever roadedgegeneratoris enabled
    - Restart BeamNG drive
    - As a last resort: post a message here.

    Changelog

    The following changes were made since release:
    • 1.0: Initial release
    • 1.1: Small update:
      • Added start fade and end fade parameters
      • Added option to randomise node placement
      • Clarified tooltips and interface
      • Road-edge width can now be a decimal value
    • 1.2: Small update:
      • Added option to specify texture length
      • Fixed startFade & endFade numbers being merged together for only the startFade property for number higher than 1.0

    Final Words & Notes

    Please don't hestitate to post suggestions on how to improve the current tool. This is "only" my second extension.

    This extension is licenced under bCDDL v1.1.
     

    Attached Files:

    #1 stuffi3000, Apr 28, 2024
    Last edited: Oct 26, 2024
    • Like Like x 12
  2. VectriciXY

    VectriciXY
    Expand Collapse

    Joined:
    Nov 6, 2022
    Messages:
    98
    Tried the extention immediately and there's not much to say, map modders know the significance of this. The extention can be used to create road edges, roadmarkings or other decalroads, just great!

    Suggestion: maybe you can keep the selection of the decalroad after creating a road edge, so if you"re not satisfied with the road edge you can delete it, adjust the settings and create a new one without selecting decalroad again. Another one is that I hope I can choose the startEndFade; or you can just select a road edge and use its property, it would be even better.

    Edit: There seems to be a small issue, road edge width cannot be set as a decimal, such as 2.5
     
    #2 VectriciXY, Apr 28, 2024
    Last edited: Apr 28, 2024
    • Like Like x 3
  3. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Keeping the decal road selected has sadly let to issues on the coding part. When you keep it selected after the process but you delete in the World Editor, then the extension breaks. That's why I made it like this. Maybe I can dig into it and try to find a way around it in the future.

    I can clearly add a setting for startEndFade. Selecting another road edge to grab the parameters from would also be doable. I'll first add the setting and then publish a v1.1
     
    #3 stuffi3000, Apr 28, 2024
    Last edited: Apr 28, 2024
    • Like Like x 1
  4. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    508
    Wow! Have to try it. If it works you get a special place in my heart, haha. Can you have a kind of offset instead of overlapping with the original decal road too? Sometimes I need it to make a temp decal road which I use with the spline editor. The spline editor sadly has only offset for random placements.
     
    • Like Like x 1
  5. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Thank you!

    It should actually be possible to use negative values in the overlap parameter, which should allow you to do your offset.
     
    • Like Like x 1
  6. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    508
    It works really well! Big Kudos from my side! It gets a bit funky if you invert the road edges. Then left and right side functionality gets inverted too. Once checked out its no real problem.
     
    • Like Like x 1
  7. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Thank you again! Do you think I could somehow clarify that behaviour, beyond what is already stated in the tooltips?
     
  8. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    508
    RTFT :) I had the feeling I must invert left and right as well when using "Invert edge placement". I don't know how to say it better. If this is always the case then you could perhaps flip the left, right caption or do it in code behind.
     
    • Like Like x 1
  9. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    493
    This is brilliant. I pretty much only used roads with a single decal (including the edges) because it was so difficult, but this is much better.

    Perhaps adding a randomiser option for the placement (slight changes only) to help make it look more 'natural' could be good.

    But otherwise this is excellent. Did you bastardise the spline object placement tool for this? I always thought that tool should allow this too.
     
    • Like Like x 1
  10. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Thank you very much. This always means a lot to me coming from another active member of the forum!

    A position randomiser might be possible. I will add it to the list of changes to implement.

    I honestly didn't even look at the spline tool. The idea came to me when I was lying in bed, thinking that this had to be a mathematically solvable problem. Because of my previous extension I knew that decal roads were just a list of points in 3D space. It then occurred to me that you'd just have to calculate a vector between point A and point B, flip that 90° to the side and add some distance to always have an edge point parallel to another. And here we go now.
     
    #10 stuffi3000, Apr 29, 2024
    Last edited: Apr 29, 2024
    • Like Like x 3
  11. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    493
    Fair play. I wish I could make my ideas a reality like that. Unfortunately I lack the coding skill...

    I wonder about an evolution of this, where you could use it to place mesh roads either side, but in such a way as to function as pavement/sidewalk...Would be trickier to align to the terrain, so might only work on quite flat ground, but one thing BeamNG really misses is an easy way to create pavements. Would open up the mapping community to more urban areas using existing building models.
     
    • Like Like x 1
  12. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    508
    I used this new tool here yesterday and made a decalroad with half the offset of the width of an pavement building block. Then I used this new decalroad as spline for the object to spline tool. It works quite well.
    --- Post updated ---
    It would be cool to export the decalroad to a curve to blender with all original positions and then just use an arraymodifier in blender. Then the pavement would have perfect curves. But a lot of polygons as well….
     
    • Like Like x 1
  13. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    Don't be so hard on yourself! I used ChatGPT for the hard maths and when I got stuck ;)

    That combination with the spline tool is actually a great idea. I didn't even know there were pavement building blocks you could fit together.
     
    #13 stuffi3000, Apr 29, 2024
    Last edited: Apr 29, 2024
    • Like Like x 1
  14. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    508
    It would be cool to export the decalroad to a curve to blender with all original positions and then just use an arraymodifier in blender. Then the pavement would have perfect curves. But a lot of polygons as well
    I found nice building blocks on Megascans.
     
    • Like Like x 1
  15. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    649
    Wow! Great tool! This fits perfectly along with my little road tutorial. It's a supperb alternative for baked roads decals! Thaks a lot for your epic work and the best is the smooth integration into the World Editor :)
     
    • Like Like x 2
  16. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    True that.

    Could you share these building blocks? I never heard of megascans.
    --- Post updated ---
    Thank you! You're tutorial looks great too! Thanks for including me :)

    I noticed that your tutorial used mesh roads for shaping the terrain and then decal roads. I did the same. Did you know that I also developed a tool to convert mesh roads to decal roads, for this exact purpose? :)
     
    • Like Like x 2
  17. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    649
    Didn't know there are even more diamonds you made! So I added also a link to your
    Mesh - Decal Road Convert into my road tutorial. (See step 8)
    --- Post updated ---
    I don't know if I'm 100% right but: I encountered the bezier algorithms BNG uses, have no proper endpoint strategy. If you look closer when making a Mesh-Road, the ends "swing out". I mean if you design a 90° left curve, the endpoints tend to make a little right turn. That's because the bezier endpoints are not properly defined as END (FLAT) by BNG, I think :confused:. So any bezier curve made in BNG with the road tools is not shape equal with the most in graphic design software.
    But you actually can export a Mesh-Road into a bezier curve in Blender quite easy:
    1. Export the Mesh-Road as a dae
    2. Import to Blender
    -EDIT: Tris to Quads
    3. Use the Loop Cut Tool to make a center line
    4. Select the top part of the center line and separate
    5. Convert (the new object) to curve
    6. Set Spline type to bézier
    7. Adjust anything you like with the blender tools (e.g. smooth or simplify)
     
    #17 Barbent Servo GT, May 1, 2024
    Last edited: May 3, 2024
    • Like Like x 5
  18. stuffi3000

    stuffi3000
    Expand Collapse

    Joined:
    Feb 6, 2022
    Messages:
    42
    New update is out (V 1.1):
     
    • Like Like x 6
  19. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    508
    That’s the hint I was looking for. Great! Thanks.
     
    • Like Like x 1
  20. Barbent Servo GT

    Barbent Servo GT
    Expand Collapse

    Joined:
    Jun 4, 2023
    Messages:
    649
    Apologies for the oversight, but I forgot to include the "Tris to Quads" step in the list above. Without it, generating a centerline wouldn't work, of course. And sorry for kinda off topic...
     
    • Agree Agree x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice