Archived

This topic is now archived and is closed to further replies.

Claus Hansen Ries

Camera

Recommended Posts

any one got a link to a VERY GOOD camera tutor ??? i have tried 5 times to make a camera...and each time something skrewed totally up.....my problem is the math, if you a at the world coordiante x, y, z and look in direction pitch, yaw, rool and you push eg. forward / strafe / or something else, it just dont move in the right direction......( my calc how a X movement of the camera, result in x,y,z movement i world coordiantes is ALLLLLWAYS wrong =) ) so right now, my camera is static at 0,0,0 and u can only turn around there =)

Share this post


Link to post
Share on other sites
If you compute the orientation of the camera in matrices, you can transform the direction you want to move the camera into world coordinates.

MATRIX RotZ, RotY, RotX;
SetRotateZ(&RotZ, roll);
SetRotateX(&RotX, pitch);
SetRotateY(&RotY, yaw);

MATRIX Mtx;
Mtx = RotY * RotX * RotZ;

VECTOR Forward = {0,0,-1};
VECTOR Up = {0,1,0};
VECTOR Right = {1,0,0};

Forward = Mtx * Forward;
Up = Mtx * Up;
Right = Mtx * Right;

Now you can move the camera by adding the vectors to its position.






Share this post


Link to post
Share on other sites
Hey, I got a system working, this is how I did it...

First, you must rotate the scene by your camera''s roll, pitch, and yaw.
Then, you must translate the scene by the opposite of your camera''s position. Why the opposite? When, shifting the camera to the right is kinda the same as shifting everything else to the left, and you''re working with everything else, so...There you go.

As for moving in the direction you''re facing, that''s going to take some math, trigonometry to be specific. It''s not that hard to figure out...Easier when moving in 2D than when in 3D, though.

- Hai, watashi no chichi no kuruma ga oishii deshita!
...or, in other words, "Yes, my dad's car was deliscious!"

Share this post


Link to post
Share on other sites
What can i say....ARRRRRRRRRRRRGGGGGGGGGGGGGGG

this thing with rotate and then translate ( or translate rotate )....it for a first person shooter right ???....and doesn''t work for airplane ???....if i look straight down ( -y )....the x movement og the mouse results in a roll instead for looking from -x to x of the camera

is it better to use a normal for the direction af the camera ( and a angle for roll ) ???

Share this post


Link to post
Share on other sites