Search Unity

World Building EasyRoads3D v3 - the upcoming new road system

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

  1. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hello jf3000,

    Could you expand on the issue with the code after removing a road network from the hierarchy? What exactly is the problem? What code lingers behind in the Hierarchy?

    Could you also please refresh my memory regarding that issue you brought up on multiple occassions one year ago?

    Perhaps this slipped somehow but I don't think I have a reputation here for not being responsive. Please send me a reminder of any issues you are having.

    Thank you,
    Raoul

    [Edit] I went through all 42 pages of this thread, your screenname only appears on this page. Please reply here, by email or to the PM I sent to you yesterday, and provide more details or at least your name so I can also check my email because at this moment I cannot answer your questions. How can code linger behind when you remove an object or assets? What is it that exactly happens?
     
    Last edited: Apr 10, 2016
  2. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    I'd like to understand a bit more about how (or when) splatmap blending happens if a splatmap texture is activated for a road. The reason I ask is that we wish to be updating alphamaps and splatprototypes during our game development with LB and ER. We'll be procedurally applying blended textures near the edges of roads with LB and your splatmap blending feature looks like it could complement our landscape-wide tools.

    Ideally people would complete the full landscape before creating any roads but from previous projects we've discovered that this is not practical. So we want to make sure LB and ER work well together during the project lifecycle. And we'll be getting first had experience as we use LB and ER together on a new project.
     
  3. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hello sstrong,

    The splatmap feature will use the splatprototype of your choice to bake the shape of the road in the terrain, several additional options are available in the Inspector for the selected road to control the shape size and blending distance with the original terrain splatmap.

    You can use a different splatprototype index per road and you can also store all this info for road types in general. In this case the splatmap blending settings will be applied automatically to newly created roads of that type.

    To get this up an running, please make sure that "Activate" in the "Add Shape to Terrain Splatmap" section of the selected road is toggled on. Furthemore "Update Terrain Splatmaps" in the Build Settings must be toggled on as well.

    Let me know if you have any further questions about this.

    Thanks,
    Raoul
     
  4. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hello again!
    i've tried with the new beta downloaded, here is my code:

    Code (CSharp):
    1.         var roadNetwork = new ERRoadNetwork();
    2.         ERRoadType roadType = new ERRoadType();
    3.         roadType.roadWidth = 6;
    4.         roadType.roadMaterial = Resources.Load("Materials/roads/single lane") as Material;
    5.         // optional
    6.         roadType.layer = 1;
    7.         roadType.tag = "Untagged";
    8.  
    9.         var road = roadNetwork.CreateRoad("road 1", roadType); //, markers);
    10.         for (int i = 0; i < MainPath.Count; i++)
    11.         {
    12.             road.AddMarker(MainPath[i]);
    13.         }
    14.         roadNetwork.BuildRoadNetwork();
    and after no road will be shown, here is the tree..

     
  5. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    Did you double check MainPath? Because your V3 API code appears to be working fine, this is what I tested:

    Code (csharp):
    1.  
    2.     var roadNetwork = new ERRoadNetwork();
    3.      ERRoadType roadType = new ERRoadType();
    4.      roadType.roadWidth = 6;
    5.      roadType.roadMaterial = Resources.Load("Materials/roads/single lane") as Material;
    6.      // optional
    7.      roadType.layer = 1;
    8.      roadType.tag = "Untagged";
    9.    
    10.      var road = roadNetwork.CreateRoad("road 1", roadType); //, markers);
    11.      List<Vector3> MainPath = new List<Vector3>();
    12.      MainPath.Add(new Vector3(250,5, 250));
    13.      MainPath.Add(new Vector3(300,5, 250));
    14.      MainPath.Add(new Vector3(300,5, 300));
    15.      MainPath.Add(new Vector3(350,5, 300));
    16.  
    17.      for (int i = 0; i < MainPath.Count; i++)
    18.      {
    19.        road.AddMarker(MainPath[i]);
    20.      }
    21.      roadNetwork.BuildRoadNetwork();
    22.  
    Or, which version are using, our website version or the asset store version? Could you try testing this again but make sure the Road Network game object is activated by selecting it first in the hierarchy after code changes. This should not be required though with the asset store version.

    Thanks,
    Raoul
     
  6. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hello @raoul
    after a couple of test seems to work, maybe the first time I needed to load the content...
    I'll try to make some test!
     
    raoul likes this.
  7. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    What are the ranges for Smooth Level and Opacity? Are 0-1 normalized values or something else? A slider and/or tooltips may be useful. I have my LB integration with ER up and running so I'm at the stage of testing the blending.
     
  8. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hello sstrong,

    Smooth Level is an Int Field, it represents the distance in terrain splatmap indexes over which the road shape should blend with the original terrain splatmap. The Max value currently is 3. Opacity refers to the blending of the road shape with the original terrain splatmap. The value should be within the 0..1 range.

    I see that, contrary to in the road settings, you can currently add any values for this in General Settings > Road Types. This will be updated according the functionality in the road settings.

    Yes. tooltips needs attention but will be added (just like in v2). Links to the manual are also added in various sections of the Inspector.

    Thanks,
    Raoul
     
  9. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    LandscapeBuilder_205537.png Hey Raoul, I just created this quick scene. Basically it is a procedurally generated landscape with a couple of textures blended with additional noise on one of them, following the spline of the road (which was manually created in the scene with the usual ER3 editor tools). We have some tools in Landscape Builder which helps us decide how trees, grass, textures, meshes etc. are placed when near road networks. In AAA games you may have noticed that roads have a blended edge with the surrounding textures. I'm envisaging this is what your Smooth Level and Opacity is intended to achieve (correct me if I'm wrong). I've tried all sorts of values (Smooth Level 0-3, Opacity 0.01 - 1) but can't seem to get anything but a sharp road edge.

    When you get a chance, could you post some sample settings and screen shots to point me in the right direction?

    BTW: build 7.6.1 is looking pretty good.
     
  10. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    I'm here again @raoul ,
    Now works! I use the version downloaded by the website (7.6.1), I've little questions:
    • it's possible change the tilt angle of the merker runtime via script?
    • it's possible generate the waypoints runtime?
    thanks!
     
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi sstrong,

    So far this was all about baking the road shape in the terrain splatmap. It seems as if this is one of the two steps to achieve what you want.

    Below is an image from a couple of pages back. It was used to show how you can have ditches next to the road regardless the terrains heightmap resolution. But I belief the road edges is in the direction of what you need, is that right?



    This uses a road texture with grass patches (matching the terrain grass texture) etc. on the road edges, the material has a cut out shader assigned.

    So what you need is a road texture with on the left and right side patches of the same terrain texture also used to visualize the road shape in the terrain splatmap.

    Thanks,
    Raoul
     
    Last edited: Apr 11, 2016
  12. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    Glad to hear you got that working!

    Controlling tilting per marker is indeed not yet avaibale in the scripting API. I will add that.

    The code you posted should also work when creating the roads and adding markers/waypoints at runtime. It looks similar asthe code used for the runtime scene example in the beta package.

    Thanks,
    Raoul
     
  13. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    The road edge effect is the start of what we're after, yes. However, we're not using a "static" texture for the ground around the road. We're procedurally applying texture, trees, etc. to multiple terrains which includes things like height, inclination, mapped areas (which could include, like in this case, a map of the road and edges). So we have multiple textures blended with one or more of the textures placed using perlin noise. So, I'm guessing the same workflow isn't going to apply.
     
  14. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465

    thanks!
    another question:
    it's possible define the cross section of the road? now is flat..
    thanks
     
  15. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    I'm not sure if AAA games blend their road material with the surrounding texture or if it is a shader effect. Obviously using different or custom engines they have other tools that Unity developers don't have access too. Still, I know we can do this within terrain data (because we're already doing it) but not sure how it applies to your road materials and shader.
     
  16. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi sstrong,

    I am not sure now what you are after? What exactly are you already doing within terrain data that you also want to use for the road material?

    Do you want a 100% small/narrow blend with the terrain underneath the road at that point regardless the splat texture? In that case you have to look into custom road shapes, and add an additional triangle strip and use a shader that can blend the geometry 100% with the terrain. It could be a bit heavy but that also depends on the size of your road network.

    But with this approach you cannot achieve the look like in the screenshot I posted with the clear grass / dirt patches on the sides of the road. The road will simply fade in the terrain over a small distance. And In that case, can't you simply use a transparency shader and fade out the road edges?

    Thanks,
    Raoul
     
  17. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    Yes, the roads are by default, flat in keeping with built-in crossings.

    You can have cross sections by using custom crossing connections. The road will inherit the shape of the crossing connections. You may want to check the Main demo scene, it includes a small road network with several examples of this.

    Thanks,
    Raoul
     
  18. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Yes, fading out the road material at the edges would reveal the irregular noise-based blended materials along and under the road edges. Which transparent shader do you suggest? I've tried the shaders that come with ER but none appear to offer that option (they fade the full width of the road material).
     
  19. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    The EasyRoads3D Standard Shader is based on Unity's Standard Shader.

    The texture in the screenshots you posted, is that the default road texture in the beta package? It doesn't have transparency info in the alpha channel like for instance the dirt texture example has. Is that what is missing?

    Thanks,
    Raoul
     
  20. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    so I need to create my own custom crossing connection? I didn't find a sample of this...
     
  21. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    Examples of this are available in the connections tab (3r from the left). Or have a look at the Main demo scene. The road network with the crosswalks is all done with custom connection prefabs, check the various road shapes.

    What kind of shape are you looking for? Something similar as the single lane road shape in that road network?

    Thanks,
    Raoul
     
  22. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    I wish a shape like this for example


    imho was great if there were a property for the road that defines the number of the points for the cross section and a function to set the up/down difference :)
     
  23. CHEFerrol

    CHEFerrol

    Joined:
    Mar 31, 2016
    Posts:
    18
    Easyroad3d_CIS.jpg Hi Raoul:
    Thank you for your answer.
    Now the program run correctly building the Windows Standalone versión.


    We are creating a 30 km road, simulating a highway to develope on it some "realistic" test with an autonomous car.
    We have created the road, and we whant to run the initial simulation into the CAVE we have.
    When we run the Build of the Windows Standalone aplication, we need a lot of hours to get the final product.
    First we use a Free versión of UNITY, but now we are using a Unity Pro versión of Unity, and we need a lot of hours too.
    We only have created 1 Terrain (without details for the moment), 1 road and 3 procedural side objects.
    Is this a logical situation?. Are we doing something wrong?.
    Thank you.

    José L. de Nicolás
     
  24. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    Adding that functionality is not so hard, all the code practically is already there, the Shape Type of side object editor window can be used for that. It is on the list to be added to the Road Types section. But the tricky bit with this is that it will not be possible to connect this track to crossings, etc. The approach so far has been the other way around, create dynamic / custom connection prefabs and have the roads adjust to these connections.

    In fact, if you do not need crossings for this track, you can already do what you see in the screenshot. Simply use a Shape type of side object for the road surface, you can create as many cross sections as you want in the Shape Editor Window.

    And just like in the screenshot and your final request, you can already adjust shape nodes per marker to add variation to the shape, also for roads.

    Or simply create a similar mesh shape with all the cross sections in your modelling app, and import tit in the Custom Prefabs system. It may sound complicated, but it is a simple process. All you have to do is import the mesh and select the vertices that should form a connection, that is it. Optionally you can also assign a new road type to that shape so you can auto create this type of tracks from the 2nd tab from the left

    Thanks,
    Raoul
     
  25. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi Jose Luis,

    Are you sure this is related to EasyRoads3D? The end result are ordinary Unity game objects with a mesh filter / renderer attached just as if they were modelled in a modelling app and imported into Unity.

    Did you do further tests?

    Like duplicate the project and in the duplicated project Finalize the road network so only the game objects remain in the scene without any scripting components attached.

    And build the project with no EasyRoads3D objects at all?

    We have never had issues with builds taking alot of time, neither have we heard of issues like this until now. Perhaps it is related to the long 30km road?

    Does the guard rail follow the full road? More objects like that in the scene will be heavy on performance in general but I am not sure if it affects the project build procedure. I will do some tests myself as well.

    Thanks,
    Raoul
     
  26. CHEFerrol

    CHEFerrol

    Joined:
    Mar 31, 2016
    Posts:
    18
    Thank you Raoul:

    You have the reason, the problem was mine.. My colleague Angel has got the solution. I must des-check the Auto into de Lighting Window. Now all its running On. Very quickly.

    I´m sorry.

    José L. de Nicolás
     
    raoul likes this.
  27. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hello again @raoul ...
    I'm trying to do some crazy thing....
    I need to create terrain and road dynamically:

    I've added the Road Network to my scene, created my own road type and no other thing in design mode..
    after in runtime I do this code:
    Code (CSharp):
    1. var roadModular = GameObject.FindObjectOfType<EasyRoads3Dv3.ERModularBase>();
    2. roadModular.terrainObjects = new Terrain[tg.m_tilesX * tg.m_tilesZ];
    3. int iT = 0;
    4. for (int tx = 0; tx < tg.m_tilesX; tx++)
    5. {
    6.     for (int tz = 0; tz < tg.m_tilesZ; tz++)
    7.     {
    8.         roadModular.terrainObjects[iT++] = tg.m_terrain[tx, tz];
    9.     }
    10. }
    11.  
    12. var roadType = roadModular.GetRoadTypeByName("gRallyRoadType");
    13. var roadNetwork = new EasyRoads3Dv3.ERRoadNetwork();
    14. var road = roadNetwork.CreateRoad("gRallyRoad", roadType);
    15. for (int i = 0; i < track.TrackPath.GetPointsCount(); i++)
    16. {
    17.     road.AddMarker(track.TrackPath.GetPoint(i));
    18. }
    19. roadNetwork.BuildRoadNetwork();
    20.  
    and something works, also 'cause after I parse the road collision and is right, but I can't see the road and I've this warning:

    any idea?

    thanks :)
     
  28. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi Ghiboz,

    That warning is displayed when you select the road network in the hierarchy and when no terrain exists. You do not necessarily need a terrain object but if you want to do create a road network with unity terrain object etc. then obviously that will be required :)

    I cannot really comment on the ERModularBase code, that is not API code, use it at your own risk :)

    But, when you create your terrains and afterwards create the roadNetwork they way you did in code posted on this same page, the first 10 lines of code are not required. Just create your terrains dynamically and do:

    Code (csharp):
    1.  
    2. var roadNetwork = new ERRoadNetwork();
    3.  
    With things like this I would build and test it step by step. First add a terrain to the scene and make sure creating the road works. After that try adding the terrain dynamically.

    Thanks,
    Raoul
     
  29. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    yes it works, but the problem is that if I create the roadnetwork at runtime, it gives the errors 'cause no side objects and road types are available, so no road will be created, otherwise if I create the roadnetwork designtime it ask immediately for objects and road types, may work but the terrain is not yet created....
     
  30. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    I think in general you want to have a road network already in the scene with side objects and road types available. var roadNetwork = new ERRoadNetwork(); will reference that road network. The fact that no terrain is created yet at that moment is not really a problem if you generate the terrain first at runtime and afterwards the road network.

    Thanks,
    Raoul
     
  31. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    so the steps may be:
    • set the roadNetwork to the scene in design time (no terrain at the moment)
    • run
    • create the terrains
    • var roadNetwork = new ERRoadNetwork();
    • create new road, etc
    and work? I'll try :)

    cheers
     
  32. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Yes, that is also how I have been testing code you posted on this page (apart from the dynamic terrain creation). :)

    As mentioned, the main advantage of using this workflow is that you have access to road types created at design time or imported from the project data in general.

    Thanks,
    Raoul
     
  33. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    I've tried, here is the log:

    but the road network -> objects doesn't have any childs...
     
  34. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    sorry @raoul ,
    i've created a new project to show you the problem and in this project it works! I try to reimport easyroads and try again
     
  35. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Yes, on my end the "Road Objects" does have a child object after creatig the actual road through code. But only at runtime, as per standard Unity behaviour the scene will revert back to the original scene (before switching to Play mode).

    Did you figure out what happened in your original project? Because if things work in general it seems unlikely this was due to the package not being imported correctly in that project.

    Thanks,
    Raoul
     
  36. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    mmmh, i've tried to reimport but no changes...
    a thing that may help: in the simple project if I click the settings and expand the scene settings everything is ok, but if I do in my main project appears this:
    ------------------------------------------------------------------------------------------------------------

    Edit: I noticed one thing: when I run the sample project the road objects has as child my 'gRallyRoad', and in the main project I see that a child is created (the arrow appears) and after will be disappeared... :|
     
    Last edited: Apr 13, 2016
  37. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    I am not sure what you mean with this?

    Can you duplicate your scene and in the duplicated scene remove the Road Network object and afterwards create a new Road Network object?

    This involves your API code and your specific scene. It is hard for me to comment on it without seeing this myself. Can you provide exact steps how to reproduce this or, if you want, you can email me the project (or a simple project with the same problem) so I can look at it.

    Did you create this road manually in Scene View?

    Thanks,
    Raoul
     
  38. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    I think that the problem is some thing that I do after the road creation, like re-activating a scene...
    unfortunately a different project works, so I think that is something outside easyroads..
     
  39. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    But you do get that error message. I will check where that happens and make sure it is handled better, but it would be good to know how to trigger it :)

    If it is something that could be related to what you are doing, creating roads at runtime etc., I will let you know.

    Other than that, if this works in a new project / scene, I would think it is either related to your scene or the status of the road network in that scene. That is why I suggested to test this also with a new fresh road network in the same scene.

    Thanks,
    Raoul
     
  40. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    How do I get a reference to an existing RoadNetwork in a scene given a gameobject using the API? I've been using ER Modular Base because my code needs to use System.Reflection and I can get ER Modular Base using the AssemblyQualifiedName. Obviously I'd rather use the API but haven't worked out any way to do that yet.

    The following code works:

    var erModularRoads = mygameobject.GetComponentsInChildren(erModularRoadType);

    but this fails because GetComponent requires that the requested component 'ERRoadNetwork' derives from MonoBehaviour or Component or is an interface.

    var erRoadNetwork = mygameobject.GetComponentsInChildren(erRoadNetworkType);

    The types are EasyRoads3Dv3.ERModularRoad and EasyRoads3Dv3.ERRoadNetwork from the Assembly and are discovered at runtime. I do this because not everyone will have ER3 installed.
     
    Last edited: Apr 14, 2016
  41. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Yes, I think that is a simpler solution. However, I can't use the dirt material at the moment because I'm seeing some strange behavior with that material in beta 7.x. Here are two images, one from an older project with the same material (same texture settings etc) and one from my Landscape Builder test scene. That later seems to have the tiling incorrect but it is the default 1x1 from the default install of the ER3 7.x package. I've seen this problem before but I can't remember how it was fixed.

    dirt1.png

    LandscapeBuilder_100759.png
     
  42. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Here is a sample of some code that attempts to call the API with Reflection. As you can see, the ERRoad class doesn't have a default constructor and therefore I can't return (or Invoke) the methods.
    Code (CSharp):
    1. erRoadNetworkType = System.Type.GetType("EasyRoads3Dv3.ERRoadNetwork, EasyRoads3Dv3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", true, true);
    2. erRoadType = System.Type.GetType("EasyRoads3Dv3.ERRoad, EasyRoads3Dv3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", true, true);
    3. erRoadsType = System.Type.GetType("EasyRoads3Dv3.ERRoad[], EasyRoads3Dv3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", true, true);
    4.  
    5. // Create instances of the API Types to be used so that we can call methods
    6. var erRoadNetwork = Activator.CreateInstance(erRoadNetworkType);
    7. //var erRoad = Activator.CreateInstance(erRoadType);
    8.  
    9. if (erRoadNetwork != null)
    10. {
    11.     // This will get a full list of the ERRoadNetwork methods
    12.     //System.Reflection.MethodInfo[] erRoadNetworkMethodInfo = erRoadNetworkType.GetMethods();
    13.     //foreach (System.Reflection.MethodInfo mInfo in erRoadNetworkMethodInfo)
    14.     //{
    15.     //    Debug.Log(mInfo.Name);
    16.     //}
    17.  
    18.     // Obtain the GetRoads() method from the ERRoadNetwork API
    19.     System.Reflection.MethodInfo methodInfoGetRoads = erRoadNetworkType.GetMethod("GetRoads");
    20.  
    21.     if (methodInfoGetRoads != null)
    22.     {
    23.         // Call the GetRoads() method with no parameters
    24.         var erRoads = methodInfoGetRoads.Invoke(erRoadNetwork, null);
    25.         if (erRoads != null)
    26.         {
    27.             // Returns a ERRoad[] array
    28.             Debug.Log(methodInfoGetRoads.Name + ": " + erRoads.ToString() + " #roads:" + ((object[])erRoads).Length.ToString());
    29.  
    30.             for (int r = 0; r < ((object[])erRoads).Length; r++)
    31.             {
    32.                 var erRoad = ((object[])erRoads)[r];
    33.                 Debug.Log("erRoad type:" + erRoad.GetType().Name);
    34.  
    35.                 // THIS FAILS WITH: Default constructor not found...ctor() of EasyRoads3Dv3.ERRoad
    36.                 var erRoadObj = Activator.CreateInstance(erRoad.GetType());
    37.             }
    38.         }
    39.     }
    40. }
     
  43. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi sstrong,

    Code (csharp):
    1. var roadNetwork = new ERRoadNetwork();
    This will create either a new road network or a reference to an already existing road network in the scene.

    Can you give more details why you want to use Reflection?

    Thanks,
    Raoul
     
    Last edited: Apr 14, 2016
  44. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi again,

    I only mentioned the dirt texture as an example of a texture with alpha channel info. You can do the same for an asphalt texture in your paint program.

    Yes, the UVs seem off, the lowest value? You can easily change that directly in the road settings.

    I am pretty sure I checked all road types in the latest build for the default UV setting, I will have another look.

    Thanks,
    Raoul
     
  45. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Landscape Builder is used by people that don't own ER3. So they won't all have the EasyRoads assembly in their project which means some of our code won't compile. To get round this, we use System.Reflection. I almost have it working (with the API) but I'm stuck on some of the exposed API classes which don't have default constructors. Here is a really basic example, carrying on from my code above.
    Code (CSharp):
    1. System.Reflection.MethodInfo methodInfoGetRoads = erRoadNetworkType.GetMethod("GetRoads");
    2.  
    3. if (methodInfoGetRoads != null)
    4. {
    5.     // Call the GetRoads() method with no parameters
    6.     var erRoads = methodInfoGetRoads.Invoke(erRoadNetwork, null);                                  
    7.     if (erRoads != null)
    8.     {
    9.         // Returns a ERRoad[] array
    10.         Debug.Log(methodInfoGetRoads.Name + ": " + erRoads.ToString() + " #roads:" + ((object[])erRoads).Length.ToString());
    11.  
    12.         for (int r = 0; r < ((object[])erRoads).Length; r++)
    13.         {
    14.             var erRoad = ((object[])erRoads)[r];
    15.             Debug.Log("erRoad type:" + erRoad.GetType().Name);
    16.  
    17.             // This line would work if a user have ER installed but won't compile if they don't
    18.             float roadLength = ((EasyRoads3Dv3.ERRoad)erRoad).GetLength();
    19.  
    20.             Debug.Log("roadLength: " + roadLength.ToString());
     
  46. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Yes, the UV tiling was set to 0.1. What should it be set to? 1.0 seems ok.
     
  47. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    @raoul i've solved.. was my mistake, after the mesh parsing to build my own collision I removed the gameobject :p

    another question: i've seen that the roadType has a roadShape property that is a list of Vector2... what is? it's the shape of the cross section that interest me?
     
  48. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi sstrong,

    I thought this was about a project using both Landscape Builder and EasyRoads3D.I didn't realize you are actually the developer of Landscape Builder, sorry about that! I sent you a message!

    Thanks,
    Raoul
     
  49. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi again,

    Yes, 1 is the default value but you can tweak it to what you prefer.

    Thanks,
    Raoul
     
  50. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi ghiboz,

    Glad you got that resolved :)

    Yes, that is exactly what it is, imagine crossings with sidewalks or custom connections which can have any shape. The road shape is stored in Vector2 format in the road type data as well. So in theory you could change that list but uv data, and other node specific data must match so change this at your own risk :)

    Thanks,
    Raoul