Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Depth sorting rectangular polygons, all parts of model axes facing

I'm working on some rendering graphics, I have a model like this, I'm using Java canvas tools and windowing, otherwise independently written.

3d-frame model

All the parts are either rectangular polygons or line-segments. As it happens in this model all the polygon parts are aligned with either the x,y or z planes, the xy-origin running from the front corner of the model in the picture. (it is possible to discern the rectangular subdivision of the sides by looking closely at how they appear patched together - but getting rid of this artifact is not addressed here)

I haven't figured out a technique for getting a clean depth-sorting, this one is based on farthest vertex. I've tried some naive techniques and they all have various artifacts to them. I noted binary space partitioning and Newell's algorithm without delving, but have a feeling there should be an easier way in this case, particularly with the condition that all parts are right aligned and parallel to the axes. Any tips on ways about it appreciated

Update

I've come up with this idea that might have something going for it

comparison of rectangular polygons

Given the planar facing constraint, there are 6 possible relationships, (x-x plane), (x-y plane), (x-z plane), (y-y plane), (y-z plane), and (z-z plane).

It is easy to sort two polygons if they share the same plane, the other 3 combinations are shown above (xy on xz), (xy on yz) and (xz on yz), with different order in depth that may occur.

I'm thinking my comparison condition might go something like this, given P1 = polygon1 and P2 = polygon2

if (P1 == xy_plane) return min(P1.z, P2.z)
if (P2 == xy_plane) return min(P2.z, P1.z)
if (P1 == xz_plane) return min(P1.y, P2.y)
if (P2 == xz_plane) return min(P2.y, P1.y)

P1 or P2 must lie in one of the first two planes, so for problem statement should be sufficient, need to confirm if this approach works

Update2

I had some progress along the idea above, and it seems that sorting on polygon matching is doing something interesting, it's been working partially, I'd say it looks easy, but, ... well, I hope you think it is and can tell me what I need to do.

Along the line above, first of all contrary to my assumption, polygons in the same plane are not trivial, they can have several different configurations shown here; parallel and not sharing another axis such as in the first two, or parallel and on the same plane. This sometimes means they don't care which axes they sort on (for pairwise comparison), (and speaks of a deeper side to this pursuit).

polygons on the same plane

Setting up a series of conditional statements regardless, something along the lines of the suggestion above, which had a brute-force flavor with an extensive series of "if-else", I think eventually I found a correct pair-wise polygon to polygon comparison, so that in this notion one can say certainly if either the subject or the other is the closer.

Working on a single side of the model here, managed to produce something that looks pretty convincing. The process in general feeling close to locking in, but trying to get rid of some final misalignment somehow defiant, as old physical trivias fixing one side the other always gets broken.

enter image description here

like image 932
Rob Hoff Avatar asked Aug 24 '15 20:08

Rob Hoff


People also ask

How are polygons used in depth sort?

When a program needs to display the data using a depth-sort, the polygons are preprocessed to determine their depth in the scene (obviously most are not perpendicular to the view vector, so some approximation may be performed). After preprocessing the polygons are drawn, in their entirety, to the screen.

What is the Order of data stored in polygons?

Most data is stored in the order it was created. When a program needs to display the data using a depth-sort, the polygons are preprocessed to determine their depth in the scene (obviously most are not perpendicular to the view vector, so some approximation may be performed).

How to determine the length of the output polygon features?

The length of the output polygon features along the input line features. The default value is determined by the spatial reference of the input line features. This value will be 1/100 of the input feature class extent along the x-axis. The length of the output polygon features perpendicular to the input line features.


1 Answers

Let me add some observations:

The conditions that

  • all polygon sides are parallel to an axis and that
  • the polygons are not intersecting

are not enough to ensure the existance of a global depth sorting of the polygons - as can be seen with this example of three rectangles:

depths interleaving

Also the relative depth order of two objects can depend on other objects as can be seen in this 2D example, where the depth order of the objects A and B, which are not hiding each other, depends on the position of object C:

enter image description here

So going for a global depth sorting of the objects does not seem to be the way to go.

like image 129
coproc Avatar answered Oct 03 '22 01:10

coproc