Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
InfiniteTrack example: generated meshes orientations not aligned
#1
Why aren't the generated meshes orientations aligned in the InifiniteTrack example?  Is there an API available to calculate the TNB frame for the last point of one spline and have that as input into the next spline i.e. parallel transport so everything is smooth?

Thanks.
Reply
#2
Hi,

(01-14-2019, 04:39 PM)geekrelief Wrote: Why aren't the generated meshes orientations aligned in the InifiniteTrack example?
 
I don't have the answer to this right now. Aligning the orientations is definitely possible, so I need to see how things were done in the InfiniteTrack example and fix it.

(01-14-2019, 04:39 PM)geekrelief Wrote: Is there an API available to calculate the TNB frame for the last point of one spline and have that as input into the next spline i.e. parallel transport so everything is smooth?
Yes there is:
  • To get the tangent: yourSpline.GetTangent(1) or yourSpline.GetTangentFast(1);
  • To get the normal: yourSpline.GetOrientationUpFast(1);
  • To get the binormal, no API method does this, but you can easily compute it (cross product of tangent and normal)
  • To set the tangent and normal at the start of a spline, just update the orientation of your spline's first control point: yourSpline.ControlPointsList[0].SetRotation(theNewRotation)
  • You can avoid doing all this by using the synchronization options of Connections: https://curvyeditor.com/documentation/sp...onnections . By connecting the last of first control points of two splines, and setting the rotation synchronization, rotating one of them will rotate the other accordingly. The corresponding class in the API is CurvyConnection.
Does this answer your question correctly?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Thanks for the info on the API.  I guess I'll dig into the InifiniteTrack code as well to see what's going on there.
Reply
#4
I'm still investigating the issue, but in the Spline gameobject's Curvy Spline component, if I change the Orientation setting from Dynamic to Static the extruded segments connect properly.  I'm still learning Curvy, so I'm not sure what's the difference yet.
Reply
#5
I haven't worked on this yet.
In the documentation you have an explanation about Dynamic and Static orientations: https://curvyeditor.com/documentation/sp...rientation
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
I've narrowed down the issue a bit.  Here's what the issue looks like  https://streamable.com/06fwn  Notice the unaligned meshes between generators.  The problem gets worse the longer it runs.  

Here I modified CurvySpline_private.cs:1109 

Code:
//Vector3 nextControlPointInitialUp = currentOrientationAnchor.getOrthoUp0INTERNAL();

Vector3 nextControlPointInitialUp = currentOrientationAnchor.ApproximationUp[currentOrientationAnchor.ApproximationUp.Length -1];

https://streamable.com/p2b0r  notice the meshes are now aligned but the ship and camera no longer rotate properly.

Update: Scratch my fix. That changes makes the CurvySplineSegment.ApproximationUp array all zero vectors.
Reply
#7
When the control points have changed as the track advances, nextControlPointInitalUp needs to adjust for when the currentOrientationAnchor up vectors are non-zero.  Because we want to preserve the up vectors through the parallel transport through the segments.  If we change the code to something like:

Code:
Vector3 nextControlPointInitialUp;
if (currentOrientationAnchor.ApproximationUp[0].sqrMagnitude == 0f)
{  
    nextControlPointInitialUp = currentOrientation.getOrthoUp0Internal();
}
else
{
    nextControlPointInitialUp = currentOrientationAnchor.ApproximationUp[0];
}

That should in theory give us the same up vectors for the old segments and produce the proper up vectors for the new segments.

But we also need to modify the code that does the swirl.  I don't understand what the smoothingAngleStep calculation does, but I suspect that and the block of code below "Apply swirl" which is updating the update vectors needs a fix.  If I comment out the swirl code the meshes are basically aligned though there is a very tiny misalignment.

For now I'll see if I can get away with using Static orientations, the behavior is much simpler and looking at the code probably runs faster too.
Reply
#8
Thanks for the info. I will take a look at this later this week, as soon as I finish my current tasks.

And yes, I confirm that static orientations run faster than dynamic ones.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#9
Ok, I dug into the scene 51, and found the issue. It will be fixed at the next release. Here is the explanation:

The spline orientation is set to dynamic, which basically means that the orientation at each control point is set automatically to keep a smooth result, except for control points set as "Orientation Anchor". So, when the spline is modified, extended, the orientation of existing control points can be modified too.

To avoid this, the last control point of each section should be set as an orientation anchor. This way, when the spline extends beyond that CP (Control point), CP before the anchor will not get modified. This is the fix that will be in the next update.

The orientation anchor was set only at startup, but not to the CPs created when the track is extended. That's why you never notice the issue with the initial track.

Each time the track spline is extended, only one Curvy Generator is updated, as a way to avoid recomputing sections of the mesh that is not supposed to be modified. But because of the issue I explained earlier, existing CPs got modified too. So we end up with a modified spline, but only part of the mesh follows that new spline, existing parts just keep their old mesh. The transition from one part to the other is what makes the mesh discontinuity you noticed.

After digging inside the code of the scene 51, I noticed different things that can be simplified. It will be part of the next update too.

I will PM you the new code as soon as I finish working on it.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Material stretched on generated mesh Tim1234 12 242 07-01-2019, 03:57 PM
Last Post: _Aka_
  Easy way to modify the UVs of the generated mesh? douoht 2 674 01-06-2019, 05:15 PM
Last Post: douoht
  Generated meshes not 'parallel' to spline Alexey 8 2,090 11-20-2018, 07:13 PM
Last Post: Alexey
  How to make the generated mesh readable ? Anthonyk 3 2,690 07-10-2018, 09:23 AM
Last Post: _Aka_

Forum Jump: