File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Polygonal Meshes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Polygonal Meshes" Watch "Polygonal Meshes" New topic

Polygonal Meshes

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 750
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.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 750
I just did a little test

If I use:

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


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.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Sometimes the stroke control hint seems to help when precision is important.
I agree. Here's the link:
subject: Polygonal Meshes
jQuery in Action, 3rd edition