Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Zylann's avatar
Zylann
Honored Guest
11 years ago

[Solved] Problem using the pose quaternion

Hello,
I'm having trouble getting correct rotations with my custom game engine:
When I rotate the rift left, it goes right.
When I rotate up, it goes down...
However, when I roll, the rotation is good whatever direction I'm facing.

I've seen a few posts regarding a similar issue for left-handed cases. However, instead of using euler angles or converting to a view matrix, I'm using a direct copy frop the LibOVR's Quat type to my own Quaternion type (something like myHead.setRotation(Quaternion(quat.w, quat.x, quat.y, quat.z))..

I tried to invert the quaternion, but there is still wrong rotations here and there... not sure what I should do :?

Any idea how I can fix this?

Edit: I checked the values of quaternion (w,x,y,z) when rotating an object 90° right in both my engine and Unity3D for a reference: values are the same, but LibOVR gives different ones...

2 Replies

  • Matlock's avatar
    Matlock
    Honored Guest
    I would just negate the x of the quat, and see if that fixes one of your rotations. If that works, you will also need to negate on of the remaining y, or z to fix the other rotation.

    Also, you said "quaternion (w,x,y,z)" I have never seen the W component listed as the first one, it is usually (x,y,z,w). That could be a massive problem in your implementation
  • Zylann's avatar
    Zylann
    Honored Guest
    Ok, after a few tests, I found that this combination gives the correct rotations:
    myHead.setRotation(Quaternion(q.w, -q.x, -q.y, q.z));


    The W is first because my Quaternion type has a constructor taking it as first parameter, because it's the real part. That's just an order of arguments. Maybe I should put the W last to make it less misleading.

    Thank you for the advice :)