Archived

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

3d camera movement

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

How do you rotate the cameras viewpoint in 3d space? Does anybody have any fast algorithms to do this? From what I understand you dont really move the camera itself, you move all the polygons in the game around the camera. If I wanted to move an object around my camera, would I first have to move its center around the camera, and then all the objects points in the opposite direction? any posts would be appreciated. =)

Share this post


Link to post
Share on other sites
im not a 3d programemr but i think i have a solution

you should have a uniform vector for camera (x,y,z = 1,1,1) and then rotate this value using cos and sin an all
then you should multipl this vector for all game objects (easy if you use matrices

i hope it helps

akura

Share this post


Link to post
Share on other sites
It''s not quite that simple. If you did that the object''s vertices would rotate but the object itself would not. What you need to do is translate the object so that it''s origin is equal to the camera position. Then you rotate the object''s points. Next you translate the object back to where it was and last rotate the the translation around the camera. If that doesn''t make sense let me give you this example. Say you want rotate a camera looking at a cube. Not only do you want the cube''s points to rotate reverse of the camera, but you also want the cube itself(thus rotating the translation variables)around the camera. I really hope this helps.

Share this post


Link to post
Share on other sites
Thats what I thought.
you would first have to rotate the objects
center around the camera, and then you would
have to rotate the objects points around the
objects center. good, thats what I thought.

thanx for the posts. =)

Share this post


Link to post
Share on other sites
Yup, the way I think of it is that if I need to move my camera up then I move the world down and put that negative number into the view matrix. Same if I want to rotate the camera to the left, I rotate the objects in my world to the right. Now don''t laugh... but to help me out to see this better I used an empty transparent cassette tape sleve and drew one vertical and one horizontal line on a paper and I moved the sleve around through which I could see the grid lines in the x-z plane. I use to do this a lot in the beginning especially with that wacky rotate first translate second thing in first person view games;-)

Share this post


Link to post
Share on other sites
I don''t know a lot about this (still working on getting my own engine to do want I want) but I think you guessed right to begin with. If you have your camera set at a fixed position then transform all the points in your 3D world around the camera (I think you can program a moving viewpoint but your way sounds simpler to me). You could then use matrices (you can read all about them in text books) to rotate, translate your world points around the camera. That''s the way I am trying to do it anyway. Later, Paulcoz.

Share this post


Link to post
Share on other sites
The problem is that sometimes the vertices are stored relative to their origins, not to the camera. So what I meant was that you''d have to convert them to camera space, then you could rotate just fine.

Share this post


Link to post
Share on other sites