Skip to main content
gamedev.net
🔒 Locked

Camera

Started by Ganoosh_ Jan 27, 2006 at 3:44 PM 1 replies 400+ views
Original Post
Ganoosh_
Ganoosh_
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?
Zakwayda
Zakwayda
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...
Ganoosh_
Ganoosh_
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.