Sign in to follow this  

Camera

This topic is 4336 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
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

This topic is 4336 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this