Search Unity

EasyRoads3D v3 - the upcoming new road system

Discussion in 'Works In Progress' started by raoul, Feb 19, 2014.

  1. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    I found the LOD Groups section in the Road settings and set it to active. It seems to work and builds the LOD models so that is good. Each road piece is treated as a complete object so it's necessary to break a road into separate segments using connection objects. Is there another way to break roads into separate LOD chunks?

    The custom prefab editor looks like it would be perfect for adding some traffic flow information. If there were a way to extend this editor that would be great.

    BTW - It looks like there's no support for undo/redo is that right?
     
  2. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    Currently it is not possible in v3 to split roads in sections like in v2. In general crossings will already split a road in segments. Indeed longer winding roads would need that option, it is on the list to implement.

    As mentioned, requests for specific features/functionality are always welcome. If you have more details of how you like to see this being extended, let me know. Are you referring to defining lane info between the different lanes and crossing connections? Abnd in that case, what exactly should be implemented?

    Indeed undo/redo is currently not implemented apart from the Inspector for several sections. Getting the functionality all done has priority at this moment, afterwards we will see how Unity's Undo class can be used for this and what other options are available.

    Thanks,
    Raoul
     
  3. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    OK, sounds good.

    As for the traffic flow information, what I imagine would be needed is a way to place lines or splines to define the center of traffic lanes just as BUDU_KRATOK has done. So it would be great if we could lay down these lines with lane connection nodes on the connector prefabs and also have them defined on the road segments too. Then have the system connect these splines into a lane network when the road network is built. We would want nodes to split and merge lanes too I guess. Maybe BUDU_KRATOK has some suggestions on how it could work. I think it would be pretty simple to add on to the great framework you already have for building road components.

    Thanks,
    Miggy
     
  4. BUDU_KRATOK

    BUDU_KRATOK

    Joined:
    Jan 3, 2011
    Posts:
    30
    Raoul, is there a feature to change the width of already placed road in the road network? Looks like when I placed some roads and connected them, I can't change road width (by clicking on the node or by changing width in config tab).

    Miggy, currently I have that logic:
    - Road instance has Lines and information about offsets, line count, one way or not etc.
    - Line have nodes and knows about all connections to other lines
    - Node can connect to the other node (and lerp position between them by bezier curve) and have status ("Stop" or "Move")

    So after generating Road Network by EasyRoads3D v3 our traffic system creates Roads, based on information from configurator (editor class) and ERRoad (like road width value). After that, it placed Lines, using EasyRoads API (getting the position of road spline by distance and creates nodes, if needed - by reverse distance for oncoming lines) and doing all needed offsets for moving Line spline from the center of the road. So on this step traffic system looks like this (old screenshot, there is some bugs, but illustrates this step):


    After that, roads needs to be connected. It can be done by getting end nodes of every Road Line and trying to connect them to any near nodes that are start nodes of their Lines (ignoring Lines with same Road (I think this is really hard to make correct u-turn for AI-controlled car)):


    Adding some logic for crossroads (by getting every ERCrossroad position, checking near nodes and getting angles between vectors):


    And now you have fully connected waypoint network and can use it for traffic (WIP screenshot =):


    About ring crossroads - looks like in this case we need to create some small road parts and connects them already on crossroad prefab. It will give more flexibility of correct linking of nodes.

    After that, we can use our lines to make navigation (for example by using Dijkstra's algorithm, vertices will be lines and "weights" will be distance from start node to end node (precalculated) or to some target node). Like this:


    Actually I don't know how correct this approach, but it working for our little project :)
    And sorry for my English, I'm trying to add screenshots as informative as possible. I hope it helps :)
     
    Last edited: Sep 15, 2015
  5. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    Thanks for the info BUDU_KRATOK. That's a cool system you have developed.
     
  6. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    Yes, I belief the visual part is clear, defining lanes, connecting lanes of different crossings, perhaps controls to smoothen the spline shape, etc.

    The question is, what’s next, what data to store and how to store it? I am just very busy and also want to get v3 out. I also do not want to implement something that turns out not to be very useful. So if you guys can give exact info on what to implement, I can see if I can schedule that in. I see BUDU_KRATOK already gave additional info on how his system works.

    Thanks,

    Raoul
     
  7. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667

    Hi BUDU_KRATOK,

    The current logic is that roads adapt to crossings. Before starting to build the road network you prepare the road types and the crossings. You can assign road types to crossing connections, the width of the connection will change and roads pulled out of that connection will be of the specified road type. This way you only have to prepare crossings once and you can reuse them like prefabs and the attached roads will match the specifed road type.

    So, indeed, at this moment changing the road width of a road will not work once it is attached to a crossing. But you can select the specific crossing and change the width of the crossing connection, the road width should update. Making this to work the other way around is on the list.

    Thank you for providing more info about your traffic system! With regard to Miggy’s post if you have any input/requests please let me know.

    Thanks,

    Raoul
     
  8. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,148
    Hi Raoul and guys!

    We definitely are going to work on make them integrated, the way im thinking to do it right now is by making a script that can read into an XML file all the needed info from Easyroads3D for then get it loaded into iTS with iTS XML road network loader.

    @raoul I'll be working on this for more or less middle of next month, I'll let you know if i need a bit more info ;)

    Cheers!

    Rhod,
     
    Last edited: Sep 17, 2015
  9. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Rhod,

    Great! we will be in touch :)

    Thanks,
    Raoul
     
    Meceka and Tinjaw like this.
  10. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Hi Raoul, I have updated to Unity 5.2.0p1 (Mac) and EasyRoads3D beta 6.8.1 doesn't appear to work.

    If I create a new project, create a terrain and try to create a new road the markers appears on the terrain however no road mesh is created. I have also tried opening the demo "scene main" and all the roads are there, however if I try to move any road markers the roads don't update, only the marker moves.

    Can anyone confirm if EasyRoads3D is working under 5.2.0p1 ?

    EDIT - just upgraded my other Mac to 5.2.0p1 and it's all working OK. Will try to reinstall and see if that sorts it out.
     
    Last edited: Sep 19, 2015
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi radimoto,

    I have not heard of any issues Unity 5.2 related. Is the Unity update the only change?

    What you describe, markers appear but the road is not build, sounds like an activation issue. I will send you a script that will reset the activation. Let's see if that fixes the issue.

    Thanks,
    Raoul
     
  12. jcarrick

    jcarrick

    Joined:
    May 5, 2015
    Posts:
    15
    Hi,
    I'm using a mac w/ the free version of easy roads on my first game build.
    Installed it - had to convert my object to a terrain - with the help of Eric Haines and his Object2Terrain script. http://wiki.unity3d.com/index.php?title=Object2Terrain
    EasyRoads now recognizes my terrain and lets me me create a new road.
    When I click on my new road object in the scene, and then click on the new marker button...
    With instructions reading "Add markers by holding [shift] and pressing the left mouse button on the desired position in the Scene Editor"
    Sounds easy enough - Except when I hold shift, (left or right), and click the left mouse button - in the scene, all my system does - is select the terrain mesh.
    So, without the ability to set markers, I'm not getting very far...
    I have a wireless logitech trackball mouse - works fine in every other regard.
    Any help would be greatly appreciated.
     
  13. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi jcarrick,

    Earlier this week I submitted updates for v2 Free and v2 Pro to the asset store. I tested all this before submitting and had no issues with adding markers. I have never received feedback related to a wireless logitech trackball mouse. Athough I would think it should work just fine it could be related. Are you in the position to test with another mouse?

    Do you get error messages? Or is something else interfering, the script you used to turn your model into a terrain object?

    I can double check v2 later on my macbook but I would say it is unlikely this is related to the Mac as all this has always worked fine on the Mac in the past 5 years.

    Also, just as a test

    Thanks,
    Raoul

    ps, this is the v3 beta thread, v3 is an entirely new road tool. This is the v2 thread http://http://forum.unity3d.com/thr...d-rivers-procedural-geometry-for-unity.82331/
     
  14. klund

    klund

    Joined:
    Mar 21, 2011
    Posts:
    33
    Hi how do I using the new V3 beta version connect the roads on this image to the triangularsquare. The roads are brownies single lanes. I have tried to make a custome crossing without succes ?
    Skærmbillede 2015-09-25 kl. 17.46.42.png
     
  15. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Klund,

    Do you mean the triangular square visible in the texture?

    That is indeed something very specific for which you can use the custom crossing system. Did you create a model of the square and is that not working well in the Custom Prefab window? What exacty is not working well? Could you send it to me so I can check on my end?

    Thanks,
    Raoul
     
  16. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    Sounds like promising stuff. Raoul, what functions are available to us to get info from the ERModularRoad classes? Are there functions to sample positions on the road spline? Also, it would be cool if you could expose the editor classes so we can extend them with our own functionality.
     
  17. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    Yes, you can sample positions on the road spline in several ways. The runtime example scene shows how to create a road at runtime and have an object follow the track. The API is not clearly documented yet in the manual but you can find all current functions in /Assets/EasyRoads3D/scripts/runtimescript.cs. And if you miss something related road spline info, let me know and I will add it.

    I may expose the the editor classes, however through the API you should already be able to add additional functionality.

    Thanks,
    Raoul
     
  18. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I think I am at the stage where I need to build custom intersections. Not T and X crossings, but other shapes like Y and such. I think I need to make custom meshes for these. Is there any documentation on how to do that?
     
  19. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Tinjaw,

    The dynamic T and X crossing options will be expanded with more options like the Y shape. Meanwhile you can indeed use the custom prefab crossing system by importing your own meshes.

    It is a fairly straightforward process:

    1) Open the Custom Prefab Window
    2) Click "Build Connection Prefab" to Create the new Custom Prefab in /Assets/EasyRoads3D/Resources/custom prefabs
    3) Create a new connection and select those vertices where the attached road should connect to.

    Here are two videos showing the process:




    It is recommended to start with a simple model just to get a feeling of how this works. Let me know if you have further questions.

    Thanks,
    Raoul
     
  20. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    @raoul : Those are helpful videos, however they both start with prefabs. What I am looking for is information on how to make those prefabs. I understand I'm going to need to use another tool (like Blender), but I need a sort of "specification" as to what I need to build in those tools to work with EasyRoads3D.
     
  21. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Tinjaw,

    This system was updated in beta 6.7 and is fairly forgiving regarding mesh inaccuracies compared to the initial system. Standard road shapes should work just fine, certainly Y crossing shapes. As you can see in the current 6.8 beta more complex shapes are now also supported (including complete brdige elements).

    But that is why I mentioned that it is recommended to start simple, a lo res Y shape crossing for example, no sidewalks. Just to get familiar with the custom crossings system.

    Making those prefabs/meshes is indeed what is required. I think there are plenty of resources on how to get started with this also regarding blender. You could even start with a simple plane with about 10 width/length segments or so, export to .obj or .fbx and see if you can turn that into a custom prefab with road connections using for example 4, 5 or 6 vertices.

    Something else you could do is export a road or a crossing prefab to .obj and import this into your modelling app. This way you will have a good reference of the road width etc. and you can use the imported model as a base for the new prefab. Exporting individual roads is already possible, exporting individual crossings will be possible in a nex build. Meanwhile you could create a temporary new scene, add a crossing and use the main "Export Road Network" option to export that crossing. Or use one of the .obj exporter scripts on the unify wiki, https://www.google.com/search?q=unity+.obj+exporter&ie=utf-8&oe=utf-8

    Thanks,
    Raoul
     
  22. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    @raoul : Thanks. That sounds like a good way to get started. Now all I need is a weekend uninterrupted and I'll give it a try.
     
  23. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Ok :) Let me know if you need any further help with this!

    Raoul
     
  24. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    OK, thanks, Raoul. I will experiment with that some more. Is it possible to create custom roads? I see how you can create custom crossings but I would like to create custom roads with a mesh representation of lane markings because texture filtering just blurs them out in an ugly way even with anisotropic filtering.
     
  25. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    Roads connected to custom crossings inherit the shape of the custom crossing connection. So by using custom crossings you can also create custom roads. To what extend do you want custom roads, do you also want an exact mesh representation of for example dashed markings in the middle? That is not possible in the current version.

    Thanks,
    Raoul
     
  26. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    Yes, I did want to uses meshes for the dashes and lines but I think I'll roll my own dynamic procedural mesh and only create them close to the camera.
     
  27. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    Yes, you could do that using the API or perhaps even with procedural or shape type of side objects.

    Thanks,
    Raoul
     
  28. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    Hi Raoul,

    I'm working on a editor window similar to your custom prefab editor so I can place traffic splines and other info to the crossing prefabs. How did you build that custom viewport for viewing the prefabs with the grid and the grid coordinates?

    Thanks,
    Miggy
     
  29. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    That is an EditorWindow using Handles to draw the stage and mesh outlines.

    As mentioned before, extending this window with options to set spline info for traffic simulation is on the list. What I have in mind is using the texture window as a start because it clearly shows the road texture which makes it easier to set control points for the lanes. Once this info is available matching handles will be displayed in the main editor window. You will be able to connect these handles and also add additional control points for smoother spline curves.

    If you have additional requests, please let me know.

    Thanks,
    Raoul
     
  30. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    Do you have an estimate on when that might be available? I'm not sure if I can wait for the functionality to be implemented so I may have to continue to roll my own. Of course, it would be best if the source to those editors was made available so we can make our own customizations.
     
  31. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    I will have a look at this for the next beta and I can always send you test builds in between if you want. If you have something specific in mind please let me know! I cannot really give the source away at this moment, during beta period and at the current low price.

    Thanks,
    Raoul
     
  32. ekuNNN

    ekuNNN

    Joined:
    Sep 3, 2013
    Posts:
    19
    Hey Raoul,

    Maybe I'm missing it but is there a way to add Specular maps to the road material?
     
  33. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi ekuNNN,

    The provided shaders in the beta package are provisional. I will double check for the specular shaders. Meanwhile you could copy the shaders from v2 to the beta package. V2 does include shaders supporting specular maps.

    Also, find attached adapted versions of the Unity 5 Standard and Standard Specular shaders available in the next beta.

    Thanks,
    Raoul
     

    Attached Files:

    hopeful likes this.
  34. ekuNNN

    ekuNNN

    Joined:
    Sep 3, 2013
    Posts:
    19
    Hey Raoul,

    Thanks for the quick reply. Sadly it wouldn't really work in my project. I also needed to use a normal map, and using the old or the new materials either the road wouldn't receive any lights in the scene, or it would become flat black. I found a work around for now, because the materials work fine on side objects. Instead of using the actual road, I made a side object to replace the road, and that works fine and looks as I would expect, with specular and bump.
     
  35. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi ekuNNN,

    You mention normal maps, when using normal maps the shader needs tangent info. When no tangent info is available the object is rendered in black in Unity 5.

    Can you double check that "Calculate Tangents" is toggled on in the Build Settings just before clicking the "Build Terrains" button?

    Thanks,
    Raoul
     
  36. ekuNNN

    ekuNNN

    Joined:
    Sep 3, 2013
    Posts:
    19
    Hey Raoul, that sounds like a really plausible reason actually, as I had "calculate tangents" off, but when I try to build terrain i get the error: "MissingMethodException: Method not found: 'UnityEngine.TreeInstance.set_prototypeIndex'.
    EasyRoads3Dv3Editor.OQCQCOODCQ.OnInspectorGUI ()
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1211)
    UnityEditor.DockArea:OnGUI()" and it hangs on "Preparing Mesh Data" without doing anything.
     
  37. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi ekuNNN,

    The beta donwload includes two packages, one for Unity 4 and one for Unity 5.

    The error message you posted is a typical error that happens when using the Unity 4 package in Unity 5.

    Can you make sure you have the Unity 5 package imported?

    Thanks,
    Raoul
     
  38. ekuNNN

    ekuNNN

    Joined:
    Sep 3, 2013
    Posts:
    19
    Ah yes, good point. I upgraded my Unity to 5 after starting on this project, so that's what's causing it. Do you think it's possible to fix it by copying the Unity 5 package over the old one, or do I have to rebuild my whole road system?
     
  39. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Yes, exactly, when upgrading Unity 4 projects to Unity 5, the Unity 5 version of EasyRoads3D is required.

    Importing the Unity 5 package over the existing old Unity 4 version should work just fine. No need to start all over with your road system.

    Thanks,
    Raoul
     
  40. ekuNNN

    ekuNNN

    Joined:
    Sep 3, 2013
    Posts:
    19
    Thanks a lot for helping me troubleshoot it, that fixed it, plus some other weird behaviour as well :]
     
  41. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Glad to hear that :) let me know if you need further help.

    Thanks,
    Raoul
     
  42. deverolirc

    deverolirc

    Joined:
    Jan 19, 2014
    Posts:
    352
    Hey there, I have Easy Roads Pro but had to cease use because I was attempting to use it on a very low res terrain, (256) so when up close the roads would be floating on the ground, could you suggest a solution to this? Thanks!
     
  43. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi deverolirc,

    The heightmapscale of your terrain (terrain size vs heightmap resolution) determines flexibility of the road shapes. The lower the heightmapscale (more terrain points available) the more flexible you are. Assuming you have a standard terrain size of 2000x2000, a heightmaps resolution of 256 means about 8 units between terrain points, indeed you will want to avoid too abrupt road height changes. Regarding terrain deformation, there is nothing you can do in this specific situation, it is impossible to add detail points to the terrain object.

    Alternatively you could use for example side objects to create a mesh terrain surface, have the outer vertices snap to the terrain. This will give you much more flexibility in the road shape. This mesh surface could be blended completely with the terrain when using for example the RTP shader package.

    Thanks,
    Raoul
     
  44. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    Hi Raoul,

    I'm looking at the runtimescript.cs example. Could you give some more info on some of these functions:

    What does this function return exactly?
    Code (CSharp):
    1. road.GetConnectionAtStart(out int connection): GameObject; // connections: 0 = bottom, 1= tip, 2 = left, 3 = right (the same for T crossings)
    I guess this gives you position along the length of the road? Is there a way to know the total length of the road so we don't overshoot with the distance parameter? What's currentElement?
    Code (CSharp):
    1. Vector3 v = road.GetPosition(distance, ref currentElement);
    2.  
    I guess these functions return spline control points for center, left side and right side of the road. Is that right?
    Code (CSharp):
    1. // spline point info center of the road
    2. //      public function ERRoad.GetSplinePointsCenter() : Vector3[];
    3.  
    4. // spline point info center of the road
    5. //      public function ERRoad.GetSplinePointsRightSide() : Vector3[];
    6.  
    7. // spline point info center of the road
    8. //      public function ERRoad.GetSplinePointsLeftSide() : Vector3[];
     
  45. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    Code (csharp):
    1.  
    2. road.GetConnectionAtStart(out int connection): GameObject; // connections: 0 = bottom, 1= tip, 2 = left, 3 = right (the same for T crossings)
    3.  
    This returns the crossing game object at the start of the road (if any) and also to which connection of this prefab the road is attached.

    Code (csharp):
    1.  
    2. Vector3 v = road.GetPosition(distance, ref currentElement);
    3.  
    Yes, this returns the center of the road at X distance. currentElement is optional and can be used for optimization purposes. You can check how it is used in runtimescript.cs.

    For now you can use road.roadScript.totalDistance to get the length of the road. I will add this to the API.

    ERRoad.GetSplinePointsCenter() , ERRoad.GetSplinePointsRightSide() and ERRoad.GetSplinePointsLeftSide() return the points on the spline shape based on the resolution value. You can indeed use them as control points for traffic simulation.

    Thanks,
    Raoul
     
  46. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    Thanks for the quick reply. And how can I get a reference to the ERRoadNetwork from script in a scene where I've already added a New Road Network?
     
  47. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Do you mean a reference to an exisiting road network in the hierarchy?

    Only one road network can exist in a scene. The following, similar as in the runtime script example, will reference that road network:

    ERRoadNetwork roadNetwork = new ERRoadNetwork();

    Thanks,
    Raoul
     
  48. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    Yes, I mean the road network which already exists in the scene which has a ERModularBase script. I want to get a list of the road types in a project.
     
    Last edited: Oct 8, 2015
  49. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,667
    Hi Miggy,

    ERRoadType[] roadTypes = roadNetwork.GetRoadTypes();
    ERRoadType roadType = roadNetwork.GetRoadTypeByName(string name);


    Thanks,
    Raoul
     
  50. Miggy

    Miggy

    Joined:
    Feb 9, 2010
    Posts:
    74
    @raoul

    That works. And one other question. Can I get the road type from ERRoad? There is a roadType in roadScript but it's a double...