Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Orientation in 2D
#8
The simple approach of just rotating the last control point only worked for some cases, so I'm trying to find the correct 2D rotation approach for each control point. I am still struggling to translate your pseudo-code recommendation for at least 2 reasons. First, vector math and quaternions always make me queasy. Second, I still don't have a good handle on how best to instantiate control points and set CP rotations vs what Curvy does behind the scenes.

For example, I learned that you can't instantiate and rotate a control point in the same step since there are some functions (GetOrientationFast) that needs the cache from the spline. So I instantiated all the control points first, then ran spline.Refresh, and now am passing back through the spline control points trying to figure out the appropriate orientation adjustment.

Here's my approach, that does not work. What has me struggling is that even when I try to set all the control point orientations to a fixed rotation, they still get twisted into 3D on some curves at run-time. That makes me wonder if my attempts at setting the rotation here are getting overwritten by something else in Curvy.

Code:
//need to refresh after creating control points so the cache is available for GetOrientationFast & GetTangentFast
TrackSpline.Refresh();

//need to rotate each control point in the spline to stay on the 2D plane
for (int i = 1; i < TrackSpline.ControlPointCount; i++) {
Vector3 previousTangent = TrackSpline.ControlPointsList[i - 1].GetTangentFast(0f);
Vector3 nextTangent = TrackSpline.ControlPointsList[i].GetTangentFast(0f);

Quaternion previousRotation = TrackSpline.ControlPointsList[i - 1].GetOrientationFast(0f);

Quaternion adjustment = previousRotation * (Quaternion.FromToRotation(previousTangent, nextTangent));

TrackSpline.ControlPointsList[i].SetRotation(adjustment);
}

TrackSpline.Refresh();
Reply


Messages In This Thread
Orientation in 2D - by Livealot - 07-24-2018, 09:54 PM
RE: Orientation in 2D - by _Aka_ - 07-25-2018, 11:47 AM
RE: Orientation in 2D - by _Aka_ - 07-25-2018, 11:59 AM
RE: Orientation in 2D - by Livealot - 07-26-2018, 03:05 PM
RE: Orientation in 2D - by _Aka_ - 07-26-2018, 04:11 PM
RE: Orientation in 2D - by Livealot - 07-26-2018, 04:41 PM
RE: Orientation in 2D - by _Aka_ - 07-26-2018, 06:10 PM
RE: Orientation in 2D - by Livealot - 07-29-2018, 09:31 PM
RE: Orientation in 2D - by _Aka_ - 07-30-2018, 12:35 AM
RE: Orientation in 2D - by Livealot - 07-30-2018, 04:47 PM
RE: Orientation in 2D - by Livealot - 07-30-2018, 11:27 PM
RE: Orientation in 2D - by _Aka_ - 07-31-2018, 10:13 PM
RE: Orientation in 2D - by Livealot - 08-01-2018, 12:30 AM
RE: Orientation in 2D - by _Aka_ - 08-01-2018, 12:12 PM
RE: Orientation in 2D - by Livealot - 08-01-2018, 08:00 PM
RE: Orientation in 2D - by _Aka_ - 08-02-2018, 10:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Shapes points orientation itsGama 3 8 01-18-2023, 02:51 PM
Last Post: _Aka_
  2d - orientation looping_co 1 5 09-01-2022, 04:17 PM
Last Post: _Aka_
  Spline controller orientation itsGama 4 31 01-24-2022, 06:38 PM
Last Post: _Aka_
  Regarding static orientation mydayz 10 288 12-05-2021, 01:25 PM
Last Post: _Aka_

Forum Jump: