Skip to main content

Drawing the outline and texture of triangles/faces

3 replies [Last post]
garoad
Offline
Joined: 2011-05-20
Points: 0

I have a 3d mesh being rendered successfully with textures (POLYGON_FILL). What I'd like to do is also programatically draw lines (POLYGON_LINE PolygonAttribute) of a different color *at the same time*, to display the edges of the triangles. It would look something like you might see in a 3d modeling program or some such application--face textures with wire outlines illustrating the face edges.
Is this something easily done through the API or will it take some amount of creativity? I guess I could alter the texture coords so that the texture falls slightly short of the polygon's edges (but I think it'd look inconsistent if the gap on the face edges varied widely), however I'm using TexCoordGeneration and I'm not sure where to start in doing something like that.
Basically this is going to be for a sort of basic but highly customized 3d modeller app, so there's a lot of less common operations going on regarding user manipulation of the 3d geometry.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
garoad
Offline
Joined: 2011-05-20
Points: 0

I've been able to achieve the effect I wanted by basically creating two Shape3D objects with a POLYGON_LINE shapes slightly *above* the POLYGON_FILL shapes. (Since the camera will always be "above" this virtual landscape mesh this seems to work fine.) But obviously this isn't ideal as it's doubling my polys from about 40k to 80k and requires me to update two shapes for every change in the geometry. (This is for a 3d mesh editor for a landscape/map, which will involve altering textures and vertex locations...) Any suggestions for better solutions would be welcome...

darwinjob
Offline
Joined: 2004-11-16
Points: 0

garoad wrote:

I've been able to achieve the effect I wanted by basically creating two Shape3D objects with a POLYGON_LINE shapes slightly *above* the POLYGON_FILL shapes. (Since the camera will always be "above" this virtual landscape mesh this seems to work fine.)

You can "elevate" the POLYGON_LINE shapes by setting http://download.java.net/media/java3d/javadoc/1.5.2/javax/media/j3d/Poly...
garoad wrote:

But obviously this isn't ideal as it's doubling my polys from about 40k to 80k and requires me to update two shapes for every change in the geometry. (This is for a 3d mesh editor for a landscape/map, which will involve altering textures and vertex locations...) Any suggestions for better solutions would be welcome...

You should probably try to use the gemetry
BY_REFERENCE http://download.java.net/media/java3d/javadoc/1.5.2/javax/media/j3d/Geom... />
garoad
Offline
Joined: 2011-05-20
Points: 0

The "two shape3d" method I described above works okay, but it does effect performance some (not sure specifically why--I don't think it's the number of Shape3Ds), so I looked into using LineArray geometry (within a SINGLE Shape3D) to draw lines for each polygon. Seems to perform better and work okay, but I still need to work out a way to keep that performance gain while allowing changes to the LineArray geometry. If I enable coordinate write capability on the LineArrays, FPS drops to crap. So I might have to remove/add LineArrays from the Shape3D when the lines need to be moved as vertices are dragged, but that sounds like asking for even more trouble. (When the user's dragging a vertex I'd have to remove/add a new LineArray to the Shape3D containing all the LineArrays on each mouse event!)