# problem with projection

This topic is 3987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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):

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

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 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 on other sites
any good articles on clipping?

1. 1
2. 2
Rutin
22
3. 3
A4L
15
4. 4
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013639
×