Quaternion Rotations
Right.
My little XNA project is moving along. Well, tripping along is more like it. I spent the past three days trying to work out proper transformations for my camera because I they were rotating (in all axes) but the rotations were relative to the world. So they didn't work properly for a flight camera.
Turns out that my calculations for the camera rotation and movement were only updating the position, so the rotation was aways beeing calculated from the world Axis, using values for Yaw, Pitch and Rotation that were just virtual and were not actually changing the avatar.
So I read somewhere (and by somewhere I mean Riemers XNA tutorial) that I needed to use Quaternions to do the transformations easily.
So after reading his tutorial and reading the Wikipedia page about Quaternion Rotations while lying in the bed before sleeping, I ended up dreaming the solution to my problem.
I had to create a Quaternion for the rotation of my invisible avatar, and use that to work out the rotation Matrix for the camera and updating the original Rotation Quaternion after the camera was updated.
Now. It works, but I don't think I fully grasp what I'm doing. It's like knowing how to read out lout a spell from a grimoire without actually knowing what the words you read mean. That can lead to unforeseen and even catastrophic consequences.
My little XNA project is moving along. Well, tripping along is more like it. I spent the past three days trying to work out proper transformations for my camera because I they were rotating (in all axes) but the rotations were relative to the world. So they didn't work properly for a flight camera.
Turns out that my calculations for the camera rotation and movement were only updating the position, so the rotation was aways beeing calculated from the world Axis, using values for Yaw, Pitch and Rotation that were just virtual and were not actually changing the avatar.
So I read somewhere (and by somewhere I mean Riemers XNA tutorial) that I needed to use Quaternions to do the transformations easily.
So after reading his tutorial and reading the Wikipedia page about Quaternion Rotations while lying in the bed before sleeping, I ended up dreaming the solution to my problem.
I had to create a Quaternion for the rotation of my invisible avatar, and use that to work out the rotation Matrix for the camera and updating the original Rotation Quaternion after the camera was updated.
Now. It works, but I don't think I fully grasp what I'm doing. It's like knowing how to read out lout a spell from a grimoire without actually knowing what the words you read mean. That can lead to unforeseen and even catastrophic consequences.












0 Comments:
Post a Comment
<< Home