# Polygonal Meshes

colin shuker

Ranch Hand

Posts: 750

posted 7 years ago

Hi, I'm experimenting with polygonal meshes to make 3D objects.

I can draw two polygons (connected by an edge), each calling:

But there seems to be a slight gap between them, when the edge is not parallel/perpendidular to edge of screen, allowing the background to faintly show through.

So the endpoints of this line eg (20,20) and (50,70) will occur in both polygons.

I can partially fix this by adding 1 to the x-coordinate of the all the points on the right side of each polygon, to extend the polygon on the right side, to seal up the gap.

This backfires once you rotate the polygons so that the right edge becomes the left edge, since here you would have to subtract 1, to fill the gap by extending the new left side intsead.

Is there any simpler way, like setting some property on the Graphics2D object, or something like that?

Thanks for any help.

I can draw two polygons (connected by an edge), each calling:

But there seems to be a slight gap between them, when the edge is not parallel/perpendidular to edge of screen, allowing the background to faintly show through.

So the endpoints of this line eg (20,20) and (50,70) will occur in both polygons.

I can partially fix this by adding 1 to the x-coordinate of the all the points on the right side of each polygon, to extend the polygon on the right side, to seal up the gap.

This backfires once you rotate the polygons so that the right edge becomes the left edge, since here you would have to subtract 1, to fill the gap by extending the new left side intsead.

Is there any simpler way, like setting some property on the Graphics2D object, or something like that?

Thanks for any help.

colin shuker

Ranch Hand

Posts: 750

posted 7 years ago

I just did a little test

If I use:

Then the edges of polygons are smooth, but gaps exist.

Whereas:

Then the edges of polygons are jagged, but no gaps.

So far, I can have one but not the other, unless I start fiddling with adding/subracting 1, to bridge the gaps.

Is there anyway to achieve both?

Thanks again for any help.

If I use:

Then the edges of polygons are smooth, but gaps exist.

Whereas:

Then the edges of polygons are jagged, but no gaps.

So far, I can have one but not the other, unless I start fiddling with adding/subracting 1, to bridge the gaps.

Is there anyway to achieve both?

Thanks again for any help.

It is sorta covered in the JavaRanch Style Guide. |