• Advertisement

Archived

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

World unit's & screen unit's (pixels)?

This topic is 6213 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've been using the following process to project 3D-objects onto the screen: Local To World World To Camera Clip - eg. object in, object out, object partly in (if not object out) Apply Perspective Project To Screen However, I am finding that the object acceptance / rejection I do in camera space (Clip) is not accurately detecting whether objects intersect with the viewing frustum. eg. objects creep outside the screen area when they should have been detected as "partly in/out - clip necessary" (I have the objects rendered in different colours depending on the code which is running). I am almost certain it's a problem with the field of view. Can someone give me some details on how to correctly adjust for the field of view (what to do with the camera coordinates), and if possible give an explanation of the relationship between world units (which may be feet, metres, or anything else I want) & screen units (pixels), because I think I might be clipping with one set of units then using a different unit system when I project (or not converting to pixels)? My clipping code involves testing that normalised (in the range -1 to +1) x is greater than -z and less than z to be in. Same for y. Check that z > 1. The distance from the projection screen is normalised too, when checking these. My projection code involves converting normalised coordinates to the screen by adding 1 (so they are in the range 0..2) then multiplying by half the screen resolutions (512 for x, 384 for y). A bit confused, Paulcoz. Edited by - paulcoz on February 20, 2001 9:57:29 PM

Share this post


Link to post
Share on other sites
Advertisement
I believe the standard technique is to clip to NEAR and FAR before the perspective transform, which involves a division by w. If the object is closer than NEAR, division by w is meaningless.

After clipping to NEAR and FAR, the division by w occurs, which converts the pyramid frustum into a box. At this point, clipping the sides is much more trivial.

Share this post


Link to post
Share on other sites
My clipping routines work, it''s just that it looks like the viewing frustum is just outside the area of the screen instead of corresponding exactly with the screen edges. Objects are detected as intersecting the frustum just after they go outside the area of the screen, instead of the instant they exceed the screen limits - I don''t want to test AFTER I have converted to the screen, vertices must be tested and clipped in camera-space to avoid unnecessary calculations.

I was reading somewhere that world units (the system of measurement used for world coordinates) are not necessarily the same as screen units (or pixels). I would like to know how you convert from one to the other, because at the moment I think I am just projecting world units to the screen (hence the wrongly-aligned frustum).

Presumably you can say "1 world unit is equal to 64 pixels" (an example) in size so you would multiply your x coordinates in normalised space (-1 - +1) by this value in order to adjust them before you convert them to actual screen coordinates - I think the solution to this problem is some sort of scaling, but I would like someone who knows clipping/projection really well to confirm this.

Thanks,
Paulcoz.

Share this post


Link to post
Share on other sites
The correct way to solve this problem is to pick up a 3d graphics text which shows the ''screen to pixel'' transform and the clip algorithm. I''ve studied these before, but I don''t have them off the top of my head. An internet search would probably yield a tutorial.

After finding these, I would work out on paper all four sides to verify that the code is clipping exactly to your screen edges. I would then code a command line app (text only) printing out the results of the clipping to verify again.

Sorry I''m not much more help.

Share this post


Link to post
Share on other sites

  • Advertisement