Announcement

Collapse
No announcement yet.

[Resolved] Connect two points on a sphere surface with a spline arc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Resolved] Connect two points on a sphere surface with a spline arc

    I'm trying to get an arc-like spline that connects two points on the surface of a sphere. The sphere represents a planet and the arc should represent a flight path for transporters.
    I know how to handle splines and in/out tangents and was able to calculate the location of both spline points but I can't get the right rotation of the spline / arc. I know two ways to achieve the correct rotation.
    1. Use local tangents and calculate the spline actor rotation
    2. Calculate the world tangents and ignore the spline actor rotation
    sadly I'm not able to achieve any of the above solutions. I know the look at rotation from point A to B but that is relative to the world up-vector, which is Z. I guess the up-vector I need is somewhat the normal of the sphere surface.

    Does anyone have an idea how this can be accomplished?

    Resolved:
    Calculate the world rotation of the spline with "Make Rot from XZ" with the average normal from the start and end location as Z and the look at rotations forward vector of both points as X
    Last edited by Lord7even; 06-27-2019, 09:31 AM.

    #2
    - take both locations and average them
    - once you have the average, Make Rotation from Z
    - apply that rotation as relative to the spline - that's assuming the spline is a child of the sphere
    - apply spline to the spline mesh

    edit:

    Here's a quick mock up:

    Click image for larger version  Name:	Capture.PNG Views:	1 Size:	243.0 KB ID:	1635701
    vid:

    https://i.gyazo.com/481bc1af8cbf810d17cc71c54cd148f9.mp4

    You will need better tangents than this, of course. But it seems you've already got that going nicely.
    Last edited by Everynone; 06-26-2019, 03:12 AM.

    Comment


      #3
      Thank you very much! I was kind of down the hole, trying to rotate normals and manipulate rotators.
      Your solution is very nice and I was able to implement it. I just need to apply it to the spline mesh but that's not a problem.

      Click image for larger version

Name:	screen0146.jpg
Views:	7
Size:	107.5 KB
ID:	1635882

      Comment


        #4
        I just made a few modifications. The biggest one was to set the spline world rotation calculated from the average normal and the find loot at rotation. This was necessary to set the tangents in local space and with so, you only need to spline points. Here's a screenshot of the code



        Click image for larger version

Name:	screen0148.jpg
Views:	7
Size:	94.7 KB
ID:	1636175Click image for larger version

Name:	screen0147.jpg
Views:	7
Size:	231.3 KB
ID:	1636174

        Comment


          #5
          This looks really good for something with only 2 (!) spline points and 1 spline mesh. Neat and straightforward. And only 1 var for the tangent? Nice job. Stealing this for a private library.

          Comment

          Working...
          X