Skip to main content
GameDev.net gamedev.net
🔒 Locked

camera

Started by George Banks Oct 16, 2000 at 2:11 PM 9 replies 700+ views
Original Post
George Banks
George Banks
I have the following question: Why does the view matrix of my camera have to have (-position.x, -position.y, -position.z) as it''s translation? My camera consists of 3 vectors (up, look, right). I translate the camera this way (e.g. down the positive z-axis): position += speed * z; That would mean that if I translate let''s say -0.5f the camera would move in the opposite direction?!?
punkfloyd
punkfloyd
That would mean that if I translate let''s say -0.5f the camera would move in the opposite direction?!?

Pretty much... consider that moving by, say, 1 meter, eastward is the same as you staying where you are and moving the rest of the universe westward. Camera matrix is the transformation applied to the rest of the universe not to the camera itself, so everything *is* going backward there.

OD

George Banks
George Banks
Oh, I see.

So I have to transform my camera and use it''s matrix to transform every vertex in my whole world?!?
Geocyte
Geocyte
Yes. you should invert the cameras rotation matrix and the translation vector, then apply that transform to everything in your world. You don''t have to do the inversion but if you don''t then when you tell your camera to move forward you are telling your world to move forward i.e. your camera is moving backwards. This would get confusing (in fact, I think it already has).



Geocyte Has Committed Suicide.
Geocyte Has Committed Suicide.
George Banks
George Banks
Ok, thanks Geocyte...

But there''s one point left:

Does my camera (and the view) always stay at (0,0,0)?

This is what I do now:
translate and rotate camera
translate and rotate world
multiply inverse camera view matrix with every vertex in world
draw with view from camera view matrix

Is this right?
Howie
Howie
I have also a question regarding Mr. Anonymous'' answer:

The camera always stays at (0,0,0). But is camerspace != worldspace then?

I can''t see the difference between them!?!

Sorry George for using your thread...
baskuenen
baskuenen
Maybe it''s best to imagine this situation like a tree:

- center of world (root node) (world space)
--- camera (camera space)
--- house (object space)
----- door (object space)


If you''re displaying from the camera, the camera is your origin.
To display the house, you first need to move back from camera to center of world. Now you''re in world space.
Then you move from this center to the house. You''re now in object space, and can draw your object.

To move up a node - multiply matrices.
To move down a node - multiply with inverse matrix.

Howie
Howie
Ok, baskuenen I think I got it... I hope so!?!

Thx
dgruber
dgruber
George,

You should read the article I wrote on this subject at http://www.makegames.com/3Drotation. I drew pictures and even worked a problem. There''s some source code there too. Maybe it will help.

Good luck,

Diana
George Banks
George Banks
I already saw your tutorial at mr-gamemaker...

But it doesn''t show how to exactly render the world... You only set the viewing matrix with the camera matrix?!?
It isn''t shown how you can rotate the world around the camera
(this is what I understood I have to do...)

Sorry for bad English... But I''m drunken

Topic Locked

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

Sign in to reply to this topic.