View Full Version : Visible Sides

ame_nguyenanhtai

07-30-2008, 09:39 PM

Dear All,

Could you please tell me how to determine which sides of a bar are visible or not. for example in the image bellow the top, front and left side of bar are visible and the other is invisible

http://img246.imageshack.us/img246/1143/charttd9.png (http://imageshack.us)

Thanks for your help.

S.Seegel

07-31-2008, 02:33 AM

Still working on this problem (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=239626#Post239626) ?

Do you remember the way i suggested to find the outline of those boxes ?

1. Compute the outline of an object. Your objects - at least in your examples - are boxes. A box is convex, so computing its outline comes down to:

i. transform all vertices (8) to screen coordinates

ii. compute frontfacing/backfacing property of all faces (6). this can be done by either applying the winding rule to all vertice of each face, or by the sign of the z-component of the eye-space face normal.

iii. each edge (12) between two faces with different front-/backfacing property is part of the outline.

Step 1.ii does exactly that: test which sides are facing to the camera. For a convex shape like a box this is the visibility property you want. Except for overlapping with other shapes in the scene of course.

Be aware of the fact that the general case will have tree sides visible, but only two (when looking perpendicular at an axis of the box) or even a single one (when looking perpendicular at a side) are possible.

ame_nguyenanhtai

08-01-2008, 04:01 AM

yes, before In order to get a bound of a bar. I transform all faces ( 6 faces) of the bar to screen coordinates then I union all polygons (6 polygon ) that made from the faces ( 6 faces) after transform tho screen coordinates.

but for now, I want to transform only visible faces

S.Seegel

08-04-2008, 12:42 AM

In order to determine if a given face is visible with respect to your camera placement you need to transform the face to eye space. Or, going the other way round, compute the inverse transformation and transform your camera into world space or even object space.

But you can exploit certain properties of your scene instead of solving your problem for the general case.

For example you seem to use a parallel projection and aligned boxes. This allows you to compute the visible sides of one box and be sure that all the other boxes will have the same sides visible.

So you will have to transform all faces of the first box (for visibility determination), but only the visible ones for the following boxes.

But you wont save too much on transformations. Look at your boxes: in the general case (three sides visible) you need seven of eight vertice anyway. Nevertheless, you will save the visibility determination on all but the first box.

Restricting the computation of the union of your screen space faces (6) to the visible ones (3) can save you half (!) the cpu cycles spend on that computation.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.