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
  Adjust radius of generated mesh via script? Shackman 1 3 03-26-2024, 01:12 PM
Last Post: _Aka_
  Not seeing mesh extended after following YT PaulM 1 3 02-02-2024, 12:01 PM
Last Post: _Aka_
  Trigger Zones along Spline Mesh dlees9191 1 5 01-05-2024, 10:18 AM
Last Post: _Aka_
  Get spline from generated mesh beartrox 1 5 11-27-2023, 12:30 PM
Last Post: _Aka_

Forum Jump: