Jump to content
  • Advertisement
Sign in to follow this  
Ganoosh_

Camera

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm creating a Camera class using equations like the one in here. I've noticed if you rotate too much on the X axis (look up/down), the world gets distorted and stretches out and zooms away. Why is this happening, and is there a way to fix it? Also, if you set the position and view to (0, 0, 0), the camera won't work. Why?

Share this post


Link to post
Share on other sites
Advertisement
I think some of the code in that tutorial may be wrong (although I'd have to look more carefully to be sure). You might try the following:
void RotateCamera(double Angle, double x, double y, double z)
{
quaternion temp, quat_view, result;

temp.x = x * sin(Angle/2);
temp.y = y * sin(Angle/2);
temp.z = z * sin(Angle/2);
temp.w = cos(Angle/2);

quat_view.x = View.x-Position.x; // Changed this line
quat_view.y = View.y-Position.y; // Changed this line
quat_view.z = View.z-Position.z; // Changed this line
quat_view.w = 0;

result = mult(mult(temp, quat_view), conjugate(temp));

View.x = result.x+Position.x; // Changed this line
View.y = result.y+Position.y; // Changed this line
View.z = result.z+Position.z; // Changed this line
}
However, I wouldn't recommend basing your camera on that tutorial. I can elaborate if you like, but I'd just be repeating things that have already been said in numerous threads recently...

Share this post


Link to post
Share on other sites
That's the way I had it originally, but it still does what I said. I think I found your post I'm gonna go read it. Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!