Advertisement

How to do the camera right?

Started by February 23, 2003 05:28 AM
1 comment, last by Marty666 22 years ago
Hi all! I''ve got two problems with my camera class. One: My camera has a position and 2 angles, like a head of a person. (up/down = AngleY) (left/right = AngleX). I use the X coordinates of the mouse for AngleX and the Y coordinates for AngleY. This works fine for looking left and rigth when i don''t look up and down and vice versa. But when I rotate the matrix for one of the two, it influences the other. Two: I use glutMotionFunc, but it''s only called when a button is pressed. I''d like to read the mouse coordinates constantly. Question: How do I do the camera the right way?
_____ /____ /|| | || MtY | ||_____|/Marty
I didn''t quite get what you were asking about the camera, and the rotations. But I would definetely use DirectInput instead of using GLUT! Look through the gametutorials on NeHe''s site, or in the MSDN. The gametutorials didn''t compile on my machine though, so I don''t know if it will on yours...
And look at the camera class article also. It''s great, and I found out everything I needed to know, when I made my camera class =).
Advertisement
i get the 3 angles
pitch yaw roll
calculate the forward up and right vector
and then use
LeftHandedIdentityMatrix(vec3_t forward,vec3_t up,vec3_t eye)
{
vec3_t f;
vec3_t s;
vec3_t u;
float m[16];
VectorSubtract(forward,eye,f);
VectorNormalize(f);
VectorNormalize(up);
CrossProduct(f,up,s);
CrossProduct(s,f,u);

m[0]=s[0];
m[1]=u[0];
m[2]=-f[0];
m[3]=0;
m[4]=s[1];
m[5]=u[1];
m[6]=-f[1];
m[7]=0;
m[8]=s[2];
m[9]=u[2];
m[10]=-f[2];
m[11]=0;
m[12]=0;
m[13]=0;
m[14]=0;
m[15]=1;
glMultMatrixf(m);
}

the neat effect is that is sets up a coordinate system which QUAKE engines use
and in my opinion quake`s coordinate system is much easier to imagine that a Y axis going upwards lol GAY
http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement