Open gianlucafabris opened 6 months ago
all the road, if all the nodes are added at once partial (only the segment to spese or to dense), if the nodes are added one at a time
Hello Gianluca,
I don't see the road being flipped upside down in your example, but there are glitches (folding and maybe material mapping problems). You can inspect the road a bit better if you go into the World Editor (press F11) then at the top, select the Decal Road Editor.
Your points are not monotonous in the X dimension (the first 5 go left, and the rest go right) - this describes a very sharp turn, since the Y value does change, but this may explain the 'folding' appearance. The road tool is not perfect, and this pushes it quite stiff. Also - it is probably better to create the mesh before laying the decal road on top of it (although I am not sure this matters from BeamNGPy tbh).
The internal tool which creates the roads has some known issues which we are working on (it is very old), so for now it would be best to keep points from being too close together, and to avoid very sharp turns. You shouldn't need to put points that close together anyway - internally, a spline will be fitted to them, so any detail at that resolution would likely be lost in this process.
Dave
thanks for the reply the example was made by hand, here is the corrected version (monotonic)
road.add_nodes((-307.5, 20, 0, 30)) #dense road.add_nodes((-307.4, 20, 0, 30)) road.add_nodes((-307.3, 20, 0, 30)) road.add_nodes((-307.2, 20, 0, 30)) road.add_nodes((-307.1, 20, 0, 30)) road.add_nodes((-307, 20, 0, 30)) road.add_nodes((-257, 15, 1)) road.add_nodes((-207, 25, 2, 15)) # the 4th is width of the node road.add_nodes((-157, 20, 1)) road.add_nodes((-107, 20, 0)) #sparse road.add_nodes((97, 20, 0))
In my project i'm using a tool to generate the nodes, and some times the nodes are to dense or to sparse, here is an example with two roads monotonic both x and y
road1.add_nodes((220.38, 0.0, 0.0),) road1.add_nodes((228.222, 10.388, 0.0),) road1.add_nodes((257.577, 58.126, 0.0),) road1.add_nodes((268.611, 77.357, 3.0),) road1.add_nodes((304.989, 137.108, 3.0),) road1.add_nodes((308.183, 142.592, 3.0),) #dense road1.add_nodes((309.842, 145.428, 3.0),) road2.add_nodes((-28.224, 170.02, 3.0),) road2.add_nodes((47.185, 119.69, 1.0),) road2.add_nodes((82.989, 94.664, 1.0),) road2.add_nodes((123.993, 65.734, 0.0),) road2.add_nodes((133.075, 59.684, 0.0),) #sparse road2.add_nodes((220.38, 0.0, 0.0),)
the lighter areas are how the road is supposed to look like, the darker areas are where it is to dense or to sparse
btw, with nodes properly spaced works fine even with non monotonic x and y, example (circle like)
road.add_nodes((-20, 0, 0.0),) road.add_nodes((0, 20, 0.0),) road.add_nodes((20, 0, 0.0),) road.add_nodes((0, -20, 0.0),) road.add_nodes((-40, 0, 0.0),)
You could try running a pass over the points, whereby if two consecutive points are too close (eg < some epsilon) then remove the 2nd, etc. To increase density, you could start adding midpoints. We do this kind of thing sometimes.
Dave
ok thanks, hoping for a correction of the bug in future versions
some updates: I've done some test to better understand the cause of the problem, here are the test and analysis github.com/gianlucafabris/BeamNGpy - Road test, hoping this might help you
Creating Road with addnodes and a set of nodes too sparse or to dense flips the road upside down. This issue affects all the road or part of it, this can't be fixed with flip_direction=True.