Jump to content
  • Advertisement
Sign in to follow this  
staticVoid2

problem with projection

This topic is 3808 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 having a problem with projection when converting 3d points in a camera object, the camera faces in the negative z axis direction. I have the 3d points that are converted into the cameras coordinate system but the problem is when the coordinates have a z value greater than 0 or when they lie behind the camera it creates an inverse image. I display the 2d converted points on a x and y axis that are centered on the screen. here's the code I use to project the 3d points:
      result.x = (field_of_view * point.x) / (distance_from_plane - point.z);
      result.y = (field_of_view * point.y) / (distance_from_plane - point.z);


where field_of_view is usualy 1000 and distance_from_plane is usualy 0. once i get the result i just draw it to the screen like: final.x = screen_center.x + result.x final.y = screen_center.y - result.y If I could upload an image or somthing you would see the problem clearer but i'm not sure how to, or if you can.

Share this post


Link to post
Share on other sites
Advertisement
Just snap a screenshot of your app, you can use something like FRAPS if you'd like. Then go to imageshack.us and upload your pic, then copy and paste the link here so we can see it.

Share this post


Link to post
Share on other sites
here's the first image where the position of the camera is somthing like (10, 10, 200) and rotation is (0, 0, 0):

Free Image Hosting at www.ImageShack.us

here the position is (10, 10, -200) and rotation still (0, 0, 0):

Free Image Hosting at www.ImageShack.us

as you can see i havent implemented bsp trees or anything yet but you can see the two blue triangles on the top right are where the bottom left sides were in the first picture, it's sort of an inverse image?? the cube shape is placed on the origon with a size of 100 i think.

Share this post


Link to post
Share on other sites
You forget the Culling-step.

ZNear < Z < ZFar ;if fail, cull.

P = Cot(0.5 * FieldOfView)

X2 = X * P
Y2 = Y * P * AspectRatio

-Z < X2 < Z ;if fail, cull.
-Z < Y2 < Z ;"

Peter

[Edited by - Shadebob on January 16, 2008 2:03:39 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!