Search Unity

Spline direction vector twisting, making unwanted spirals when lofting

Discussion in 'Scripting' started by Tiki, Oct 9, 2015.

  1. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Hello, here's a picture for reference:

    spiralspline.png

    As you can see, the bezier curve's direction vector is twisting in 3d space. I'm finding the lofted values by finding two cross products, so the vertical perpendicular, and then using the vertical perpendicular to find the lateral perpendicular. However it appears that my vertical perpendicular is not "vertical", but relative. Can anyone give me some elaboration from their own spline experience which might help me to tame this spiral and keep it level?
     
  2. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    If you cross your forward direction you get from the derivate with world up you should get the proper right direction. then cross the right with forward to get your local up.
     
  3. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    My solution ended up being to avoid finding the first cross (a local vertical perpendicular) and replacing it's use with a basic world up (0,1,0). Not my ideal solution, but it works for the purpose of the program.

    splineworking.png