Jump to content
  • Advertisement

Archived

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

EEPROM

How to implement a Camera???

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

Hi everybody. I would like to know how to implement a Camera into a 3D engine, so that you can look around instead of looking into a fixed direction. I was thinking that I should use 2 points for the camera. One vertex for the actual position of the camera, and one vector for the spot direction. Is that right? And how to I actually render the world from the camera''s perspective? Should I rotate the whole world in funtion of the cameras position/spot direction? "Simple is beautiful"

Share this post


Link to post
Share on other sites
Advertisement
you can either use direct3d or opengl for that. whichever one you choose has camera features.

a2k

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
AFAIK, OpenGL does NOT have camera features. Granted, with gluLookAt() you can make a simple camera system, but OpenGL itself does not support any such feature. IMO, if your using OGL, just roll your own camera system to build a camera matrix from scratch, then load the matrix on to the matrix stack and multiply.

Share this post


Link to post
Share on other sites
I don''t want to seem rude, but I give a shit for all this pre-coded 3D API''s. (OpenGL/Glide/Direct3D/etc.)

What I''m doing is to build a 3D engine in DirectDraw for me to learn how a 3D engine works. I want to know how things are calculated etc. And now I''m asking how I could implement a camera. What I want are some formulas, tutorials, etc...

Please, don''t mention any 3D API''s because using them is for people who allready know how a 3D engine works, or for those who just want to code a 3D engine without any deep knowledge. I plan to use them later to get beautiful graphics on high-resolution.

"Simple is beautiful"

Share this post


Link to post
Share on other sites
okay, gotcha. um, you need to perform what''s called a world to viewer coordinate transformation with a special matrix.

Here''s a link to info as to how this is performed:

http://www.siggraph.org/education/materials/HyperGraph/viewing/view3d/3dview1.htm

a2k

Share this post


Link to post
Share on other sites
OK, thanks. That was exaclty what I am looking for. If you have some other URL''s about this topic I would apreciate it.

I like it to read 2 or 3 diferent tutorials about the same topic, because each author has a diferent point-of-view. So, reading 3 diferent opinions is the best way to make your own conclusions

"Simple is beautiful"

Share this post


Link to post
Share on other sites
Another URL?

Sure, look in the DirectX documentation : )

But hey, feel free to bitch about mentioning an API and not look at it.

G''luck,
-Alamar

Share this post


Link to post
Share on other sites
OK, I''ve found 2 tutorials about camera calculations. One of them provided by a2k .

Both tutorials use a 3x3 Camera Matrix in the clculations. And this is my new question now. What is inside this 3x3 camera matrix?

I really don''t know what to put in there. I have the cameras position inside a vertex:
[X]
[Y]
[Z]

and I''m sure that I must put the cameras direction vector into this 3x3 Camera Matrix, but how???

[Vx,0,0]
[0,Vy,0]
[0,0,Vz]
?

Any idae?

Share this post


Link to post
Share on other sites
3x3 Matrix? Hmmmm, interesting. It would be a little bit easier if you used 4x4 Matrices and worked in Homogeneous space rather than Euclidean space. Then the matrices would be:

Translation:
[1 0 0 X]
[0 1 0 Y]
[0 0 1 Z]
[0 0 0 1]

Rotation around X:
[ 1 0 0 0]
[ 0 cosT -sinT 0]
[ 0 sinT cosT 0]
[ 0 0 0 1]

Rotation around Y:
[cosT 0 sinT 0]
[ 0 1 0 0]
[-sinT 0 cosT 0]
[0 0 0 1]

Rotation around Z:
[cosT -sinT 0 0]
[sinT cosT 0 0]
[ 0 0 1 0]
[ 0 0 0 1]

Remember to rotate before you translate and then invert.

M = Inverse(T * Rz * Ry * Rx)

But if your writing yourself a renderer get yourself the bible. Computer Graphics: Principles and Practice.

Share this post


Link to post
Share on other sites
If you got access to your local bookstore, flip open Game Programming Gems. They have the matrix in there, and a description of where the aspect ratio and field of view go into that matrix.

your aim is to find a way to express a camera with a matrix transformation that accepts:

camera position vector
camera target vector
camera "up" vector
field of view
and aspect ratio

the W->V matrix can readily take these values in (i think)

a2k

Edited by - a2k on August 8, 2001 1:34:12 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!