Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unpredictable mesh generation
#1
Hi!

I'm creating a vertical road using the generator (shape extrusion) and feeding it a a randomly generated set of control points.
The road itself is completely flat (localPosition.z is always = 0).

About 50% of the time the generated mesh is perfect (it took me a while to avoid overlapping triangles and getting z fighting) and the remaining times the road insists on behaving unexpectedly.
It all depends on what I select as Orientation under my Curvy Spline general settings: 
- if I select "Static": some parts of the mesh will be flipped 180°  (this happens 100% of the time) (picture 1).
- If I select "Dynamic": sometimes (~50%) I get what I want (picture 2) and sometimes it starts twisting around (picture 3) and when it does it's not like the road is always perpendicular to the x axis... it may start correctly aligned and then corkscrew around the Y axis...

   

this is the main loop that generates the spline:

Code:
        CurvySpline CS = RoadSpline.GetComponent<CurvySpline>();
        for (int i = 0; i < numberOfCPs; i++)
        {
            CurvySplineSegment CSS_Last = CS.ControlPoints[CS.ControlPoints.Count - 1];
            CurvySplineSegment CSS = CS.InsertAfter(CSS_Last);
            float xPosition = Random.Range(-maxHorizontalWidth, maxHorizontalWidth);
            float yPosition = CSS_Last.localPosition.y + verticalSpacingBetweenCPs;
            CSS.localPosition = new Vector3(xPosition, yPosition , 0);
            CSS.localRotation = CSS_Last.localRotation; //this doesn't help either
            

        }


any ideas?

Thank you for your help!
Reply
#2
After examining the scene the problem seems to being caused by the spline's RestrictTo2D mode in combination with Dynamic Orientation. If you disable 2D, you'll notice the orientation rolls in curves (like a plane would fly the path), but using 2D makes the dynamic orientation pointless.

I switched Orientation to Static and set a proper rotation (-90,0,0), then it looks like expected.
Reply
#3
(05-05-2016, 10:08 AM)Jake Wrote: After examining the scene the problem seems to being caused by the spline's RestrictTo2D mode in combination with Dynamic Orientation. If you disable 2D, you'll notice the orientation rolls in curves (like a plane would fly the path), but using 2D makes the dynamic orientation pointless.

I switched Orientation to Static and set a proper rotation (-90,0,0), then it looks like expected.

Thank you for your answer!
The road stays correctly aligned, but I still get this issue: 
   
This is what I did: I switched the orientation to static (and turned off restrictTo2D) and when I generate the control point I used the following line of code:

Code:
CSS.rotation = Quaternion.LookRotation(new Vector3(-90, 0, 0)); //CSS = a CurvySplineSegment

Thanks again!
Reply
#4
try Quaternion.euler(-90,0,0). What you see is caused by orientation flipping, but that shouldn't occur if rotation sticks to one direction always. I can't imagine how this can be caused by a bug, because all Curvy does in Static mode is lerping between the two rotations and lerping between two identical values should be relatively predictable Wink
Reply
#5
Sadly it's exactly the same...
If you want to have a look for yourself, the script is RoadSplineBehavior attached to RoadSpline.

Again, thank you very much for your help!
Reply
#6
I'll send you your changed scene back asap...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 960 06-09-2021, 12:42 PM
Last Post: _Aka_
  Disabled mesh generation until a certain number of CPs are added. boriskourt 1 413 05-02-2021, 10:02 AM
Last Post: _Aka_
  Performance lag for Endless Road generation User2200 5 1,377 04-08-2021, 08:33 AM
Last Post: _Aka_
  How to change the mesh inside the generator elitegorgong 5 1,172 04-03-2021, 04:53 PM
Last Post: _Aka_

Forum Jump: