Tuesday, March 9, 2010

Sad days indeed....

Well, here's something that has hit me hard...

Just the other day, I rebooted my Windows 7 machine due to a system update and BOOM... the RAID 0 settings I had for my 2 1TB drives was destroyed, can you see what happened here?

Did you know that you can't just say, make a RAID 0 and poof your data will be returned to you?
Yes, you've read that right... everything I had on my hard drives was wiped clean. The downside to this, I've lost everything I had on my computer...

Thankfully, my friend who is working on the games with me has an older copy of the games, but at least not everything has been lost!

What's worse is, 2 days before I had fixed my gimbal locked camera and we had a full 360 degree of freedom. Oh well, now that I know how it's done, I can rebuilt that code easily.

Tuesday, March 2, 2010

The problem with Cameras and a Gimbal!

Alright. There might be some of you who just by looking at the title to this post go: Duh!

And for those of you, who like me, wouldn'tve figured out what the problem is here's the low down.
I keep saying that my camera controls aren't quite what I want and there's a reason for that. I'm working in a 3D space, but I'm using a 2D input device (the mouse).

Now, my original code to rotate the cube around the screen was by adjusting the x and y rotations by the value that the mouse has moved. Seemed simple enough. Create a degree of rotation, transfer that into a Matrix and poof! Instant rotation of the cube... and this does work... mostly. The problem is, I'm only using 2 out of 3 dimensions for rotation... can anyone see the problem?

I did some research and found out the term... it's called Gimbal Lock. This happens with 3D maths that use regular vectors and matrices... 1 axis of rotation lines up with a 2nd axis and suddenly they're locked together, unable to seperate. Leaving you only 2 degrees of rotation. Well my code has this without even bothering to lock an axis. Since I was only using the x- and y-axis, this locked the z-axis from any rotation. In theory I deliberately coded in a Gimbal Lock.

Now, I've read about how I can prevent this completely by using Quaternions... what's a Quaternion? Good question, I never studied these in University, so everything I'm learning is from the wonderful internet. With that said, I think I have a rough enough understanding on how they work and how to use them. Unfortunately, the XNA libraries don't have prebuilt Quaternion maths, so it looks like I'll be creating a new Component to my GameLibrary that'll handle all of my Quaternions.

(As a quick heads up for people who've never heard of Quaternions... they work in 4D space, wrap your head around that!)