Jump to content
  • Advertisement
Sign in to follow this  
Norman Barrows

camera relative coordinates and setting the camera

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

I'm starting work on the 8th version of SIMSpace, my starship flight sim.

 

the game world will be a cube, 200 trillion kilometers across.

 

needless to say, this won't fit in a float for directx.

 

so i've settled on using an _int64 to store decimeters for world coordinates.

 

to draw, everything will need to be camera relative.

 

so this means all i have to do is put the camera at the origin, rotate it, then translate everything else in view relative to the camera (the origin) before drawing, right?

 

IE its ok to put the camera at the origin, and move everything else relative to that point? after all, its all relative, motion is relative...

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement
so this means all i have to do is put the camera at the origin, rotate it, then translate everything else in view relative to the camera (the origin) before drawing, right?

A model transform M, followed by the view transform of a rotated RC and then translated TC camera looks like (using row vectors)

      M * ( RC * TC )-1

what is equivalent to

      = M * TC-1 * RC-1

 

So yes, you can do an inverse translation manually before the view transform is applied, just to "simulate" the camera positioning.

 

Writing M also as rotation followed by a translation, we get

      = RMTM * TC-1 * RC-1

where a combined translation

      TMC :=  TM * TC-1 = T( tMx - tCx ,  tMy - tCy ,  tMz - tCz )

is contained. It is computed as difference of the 2 positions from the camera to the model. With objects close enough to the camera, the combined translation can be expressed using a matrix of type double again, so that a total matrix transform

      RM * TMC * RC-1

would be a possible way to go.
Edited by haegarr

Share this post


Link to post
Share on other sites


A model transform M, followed by the view transform of...

 

god i wish i still had my linear algebra book! and i got an A in it at OSU!   <g>

 

all you up and coming 3d programmers out there - go buy a linear algebra book, and learn it, breath it, live it! <g>

 

a good physics book might not be a bad idea either...

 

I'll have to go look all that up to refresh my memory. but its good to know the math jibes with the theory. thanks!

Share this post


Link to post
Share on other sites

 

IE its ok to put the camera at the origin, and move everything else relative to that point? after all, its all relative, motion is relative...

Remember that all these spaces are really talking about the same space, they are just different representations or the same thing based on who is describing it. Whether you think of a models space as the absolute one, or the cameras, or some other space not related to any model in particular(world space) it is all the same thing in the end. So yes, setting your camera at <0,0,0> in world space by using an identity matrix for your camera-to-world transform is perfectly fine. You should know that the camera to world transform is the inverse of your world to camera transform and viceversa. Which means your view transform in the above example is also the identity matrix

 

The inverse of a matrix, m, is given by m-1 and what haegarr was showing is that the model * view is actually the same as the model * camera-1 . If your camera transform is a combination of ROTATION, then TRANSLATION, to invert that transform you need to reverse the TRANSLATION first, then the ROTATION second. That should get you through the rest of Haegarr's post.

 

 

god i wish i still had my linear algebra book! and i got an A in it at OSU!   <g>

 

all you up and coming 3d programmers out there - go buy a linear algebra book, and learn it, breath it, live it! <g>

 

a good physics book might not be a bad idea either...

 

I'll have to go look all that up to refresh my memory. but its good to know the math jibes with the theory. thanks!

 

Truth be told, I find that people here at game dev are much better at explaining this stuff than the majority of texts I've come across at the local library, but kudos to you for reminding the "freshmen" just how important some of this boring stuff might actually be to them some day.

Edited by Burnt_Fyr

Share this post


Link to post
Share on other sites


Truth be told, I find that people here at game dev are much better at explaining this stuff than the majority of texts I've come across at the local library

 

my text was no different. like most math texts, you had to skip past a lot of derivation and proofs to get to the useful definitions and formulas. 

 

the thing is, that there's often an elegant and simple liner algebra / vector / 3d geometry solution to many 3d problems, and without a good reference text, i'm forced to use less elegant methods. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!