Jump to content
  • Advertisement

Archived

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

jakem3s90

Matrix Camera to World Coordinates

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

Hey everyone! I''ve finally got my matrix camera code working correctly, it''s adjusting the yaw, pitch, and roll, and then translating as it should. My question however is, is that I want to get the "true" coordinate of my camera position. The 4th row of the matrix is basically the the translation the scene, but if I wanted to test something against the position of my camera, it wouldn''t work, since I don''t have the actual position of the camera. I''m using a 4x4 2d array, rather than a sequential array to do the camera rotation / translation. Any ideas / links are appreciated! Thanks!

Share this post


Link to post
Share on other sites
Advertisement
My understanding is the rotation is applied before the translation. So what happens, is you end up with your camera pointing straight down, and apply a camera translation by incrementing the z component of your translation, which moves the camera down, but your translation actually is modifying the z component of the 4th row in the array, rather than the y component, which is what you would want to get your world coordinates.

I'm probably missing something though.



[edited by - jakem3s90 on May 21, 2004 10:30:25 AM]

Share this post


Link to post
Share on other sites
I assume you keep track of your camera position somewhere, and at some point call

glTranslate(-camera.x, -camera.y, -camera.z), or whatever.

Any tests you do with the camera position should be in world space anyway, so just use your normal camera position. You should already have the info you need

Share this post


Link to post
Share on other sites
jyk - I''m using glLoadMatrix() for translation / rotation, passing it a 4x4 matrix, instead of using glRotate, or glTranslate...

Share this post


Link to post
Share on other sites
quote:
Original post by jakem3s90
My understanding is the rotation is applied before the translation. So what happens, is you end up with your camera pointing straight down, and apply a camera translation by incrementing the z component of your translation, which moves the camera down, but your translation actually is modifying the z component of the 4th row in the array, rather than the y component, which is what you would want to get your world coordinates.

I'm probably missing something though.



[edited by - jakem3s90 on May 21, 2004 10:30:25 AM]


I think i know what you mean, that if you rotate your camera, for instance, 90 degrees around the x-axis, then translate it 10 units along the camera's y-axis, then it would actually be transforming it along the world's z-axis because its local axes have been rotated. If that is what you're talking about then you should just be able to multiply the camera coords by the inverse of the rotation matrix in order to get the camera's "true" position.


~aussie

"one of these days im going to cut you into little pieces!" - Pink Floyd

[edited by - James Sioutis on May 21, 2004 12:18:48 PM]

[edited by - James Sioutis on May 24, 2004 1:22:10 PM]

Share this post


Link to post
Share on other sites
James,

That''s exactly what I''m talking about! And THANK YOU! I''ll give that a shot, and post my results, in case anyone else is experiencing the same issue.

Thanks again!

Share this post


Link to post
Share on other sites
James, I just finished all of the coding to do this, I had to write alot of the math code from scratch, which was pretty fun!

Anyways, so far, all of the numbers look really good, my next step is to try it out in a real app, I''ll keep you posted.

Thanks again!

Share this post


Link to post
Share on other sites
James, just tried it, we''re good to go... Thank you so much for the info! You saved me a TON of time!

Thanks again!

Jake

Share this post


Link to post
Share on other sites
hey, lol no problem, so all you had to do was just multiply the coords by the inv. rotation matrix?? I was just taking an estimated guess before so i wasnt 100% sure if it would work or not, and im also in the process of writing a camera class for OGL so if i ever come across that problem it would be good to know if it worked or not.


~aussie

"one of these days im going to cut you into little pieces!" - Pink Floyd

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!