Announcement

Collapse
No announcement yet.

FindLookAtRotation and declaring Up vector?

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

    FindLookAtRotation and declaring Up vector?

    Is there any way to declare and use a custom Up vector in the FindLookAtRotation function?
    Reason i ask, is because it seems the return value always uses the world Z as up. So making games like "f-zero/XGRA" is a nightmare.

    Basically, i'am having a break from c++ coding and giving visual blueprints a go, really enjoying it.
    Heres my original source code using a different engine:
    Code:
    		D3DXQUATERNION qBikeRotation;
    		iVectorRotate(&vUp,&vUp,&qBikeOrigin);
    		iQuaternionLookAt(&qBikeRotation,&vScanDownCp,&(vScanDownCp+vScanDownCn),&vUp);
    		D3DXQUATERNION qForward;
    		iQuaternionFromEulerAngles(&qForward,-90.0f,180.0f,0.0f);
    		iQuaternionMultiply(&qBikeRotation,&qForward,&qBikeRotation);
    This gives me the rotation relative to the up vector of my source (qBikeOrigin in this case). I can then use this rotation to apply directly to my object. In effect, it will rotate an object to match the hit normal. Say hello F-zero.

    This is how the bluerpint looks, but, without being able to declare the Up vector in the "FindLookAtRotation" function. It cant be done.
    Click image for larger version

Name:	bp.png
Views:	1
Size:	150.9 KB
ID:	1138933

    Does anyone know a way around this, or, is there another method?
    Cheers,
    Dan

    #2
    Blueprints exposes a function that will give you a rotator from axis and angle inputs. Axis angle form is great for interpolating.

    What you will need to do is get the the vector between your actor and the target call it L. Lets call your Forward vector F

    F Cross L = Axis
    Norm(F) dot Norm(L) = cos(Theta)
    You can get Theta with arccos

    Then you can pull out a rotator of any angle between 0 and Theta on the Axis of rotation if you need a sub-step.

    Edit: forgot cosine!
    Last edited by james0x0A; 09-29-2014, 07:57 AM. Reason: normalized vectors

    Comment


      #3
      Originally posted by james0x0A View Post
      Blueprints exposes a function that will give you a rotator from axis and angle inputs. Axis angle form is great for interpolating.

      What you will need to do is get the the vector between your actor and the target call it L. Lets call your Forward vector F

      F Cross L = Axis
      Norm(F) dot Norm(L) = cos(Theta)
      You can get Theta with arccos

      Then you can pull out a rotator of any angle between 0 and Theta on the Axis of rotation if you need a sub-step.

      Edit: forgot cosine!
      Hi James,

      Thanks for the reply. I did try your method but with my lack of knowledge in dot/cross (never used them before, lookatrotation was my tool of choice with declaring up vector), didnt get very far.
      I've been reading up on this after your advice http://www.euclideanspace.com/maths/.../angleBetween/, but still havnt been able to fully grasp it yet.

      I did manage to obtain the rotations needed using this method below, however, i'am not sure its the "best method". Even with Lerp the results are very jumpy.
      If you have any advice, i'd appreciate it.

      Click image for larger version

Name:	Rotate.png
Views:	1
Size:	374.0 KB
ID:	1057663

      Thanks again for your original reply, and, sorry for the delay.
      Cheers
      Dan

      Comment

      Working...
      X