Karsten Fries wrote: > Hi Robert, > > one dirty trick would be to use a texture for the triangles that show > a border at the triangle edges. highlighting would work by > doublicating the respective triangles and by texturing them with > another texture (highlight colored) that is z-offseted to prevent > overlaps.
Code for this approach (or something similar) was posted a few months ago: http://swjscmail1.java.sun.com/cgi-bin/wa?A2=ind0203&L=java3d-interest&P=R31500 However, I've found that the rendering quality is better when two Shape3D objects are used with separate Appearance instances, but a shared geometry. For what it's worth, the code I've written for this is below. I hope it helps. Simeon MeshGroup.java --------------------------- import javax.media.j3d.*; import java.util.Enumeration; /** * A group used to render a given Shape3D as a filled and outlined set * of polygons. Additionally, the class supports a fast rendering mode * to more quickly render the mesh in operations that require higher frame * rates but lower quality, such as rotations. * * @author <a href="mailto:[EMAIL PROTECTED]">Simeon H.K. Fitch</a> * @version $Revision: 1.2 $ * @since May 14, 2002 */ public class MeshGroup extends Group { /** Wireframe appearance */ private Appearance _wireAppearance = null; /** Solid appearance. */ private Appearance _solidAppearance = null; /** * Standard ctor. * * @param original The shape with source geometry. Any set appearance * will be overridden. * @param nodesAsPoints Render nodes as points instead of lines between * nodes. */ public MeshGroup(Shape3D original) { this(original, true, false); } /** * Standard ctor. * * @param original The shape with source geometry. Any set appearance * will be overridden. * be rendered as specified by the parameter <code>nodesAsPoints</code>. * @param nodesAsPoints Render nodes as points instead of lines between * nodes. */ public MeshGroup(Shape3D original, boolean nodesAsPoints) { this(original, true, nodesAsPoints); } /** * Standard ctor. * * @param original The shape with source geometry. Any set appearance * will be overridden. * @param showWireframe If true the nodes or node connectivity will * be rendered as specified by the parameter <code>nodesAsPoints</code>. * @param nodesAsPoints Render nodes as points instead of lines between * nodes. */ public MeshGroup(Shape3D original, boolean showWireframe, boolean nodesAsPoints) { original.setAppearance(_solidAppearance = new SolidAppearance()); addChild(original); if(showWireframe) { // Create the wireframe shape by copying the geometry. Shape3D wireframe = new Shape3D(); Enumeration enum = original.getAllGeometries(); while(enum.hasMoreElements()) { // We also make sure the geometry is pickable. Geometry geom = (Geometry) enum.nextElement(); wireframe.addGeometry(geom); } _wireAppearance = nodesAsPoints ? (Appearance) new PointAppearance() : new WireframeAppearance(); wireframe.setAppearance(_wireAppearance); wireframe.setPickable(false); addChild(wireframe); } } /** * Set the rendering mode. * * @param state True for fast, lower quality rendering, false for higher * quality rendering. */ public void setFastRendering(boolean state) { ColoringAttributes ca = _solidAppearance.getColoringAttributes(); ca.setShadeModel( state ? ColoringAttributes.FASTEST : ColoringAttributes.NICEST); if(_wireAppearance != null) { _wireAppearance.getRenderingAttributes().setVisible(!state); } } } SolidAppearance.java ------------------------- import javax.media.j3d.*; import com.sun.j3d.utils.image.TextureLoader; /** * Default solid component of a model with combinded solid and wireframe views. * * @author <a href="mailto:[EMAIL PROTECTED]">Simeon H.K. Fitch</a> * @version $Revision: 1.5 $ * @since April 11, 2002 */ public class SolidAppearance extends Appearance { /** * Default ctor. */ public SolidAppearance() { ColoringAttributes ca = new ColoringAttributes(); ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD); ca.setCapability(ColoringAttributes.ALLOW_SHADE_MODEL_READ); ca.setCapability(ColoringAttributes.ALLOW_SHADE_MODEL_WRITE); setColoringAttributes(ca); setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ); Material mat = new Material(); mat.setSpecularColor(.1f, .1f, .1f); mat.setShininess(1); mat.setAmbientColor(.3f, .3f, .3f); setMaterial(mat); PolygonAttributes pla = new PolygonAttributes(); pla.setPolygonMode(PolygonAttributes.POLYGON_FILL); pla.setPolygonOffset(1); pla.setPolygonOffsetFactor(1); pla.setCullFace(PolygonAttributes.CULL_NONE); pla.setBackFaceNormalFlip(true); setPolygonAttributes(pla); } } WireframeAppearance.java -------------------------- import javax.media.j3d.*; import com.sun.j3d.utils.image.TextureLoader; /** * Default wireframe component of a model with combinded solid and wireframe views. * * @author <a href="mailto:[EMAIL PROTECTED]">Simeon H.K. Fitch</a> * @version $Revision: 1.7 $ * @since April 11, 2002 */ public class WireframeAppearance extends Appearance { /** * Default ctor. */ public WireframeAppearance() { ColoringAttributes ca = new ColoringAttributes(); ca.setShadeModel(ColoringAttributes.SHADE_FLAT); ca.setColor(0, 0, 0); setColoringAttributes(ca); PolygonAttributes pla = new PolygonAttributes(); pla.setPolygonMode(PolygonAttributes.POLYGON_LINE); pla.setPolygonOffset(-1); pla.setPolygonOffsetFactor(0.1f); pla.setCullFace(PolygonAttributes.CULL_NONE); pla.setBackFaceNormalFlip(true); setPolygonAttributes(pla); LineAttributes la = new LineAttributes(); la.setCapability(LineAttributes.ALLOW_ANTIALIASING_WRITE); la.setLineWidth(.4f); la.setLineAntialiasingEnable(true); setLineAttributes(la); setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ); setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE); RenderingAttributes ra = new RenderingAttributes(); ra.setIgnoreVertexColors(true); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE); setRenderingAttributes(ra); setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ); setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE); TransparencyAttributes ta = new TransparencyAttributes(); ta.setTransparency(0.5f); ta.setTransparencyMode(TransparencyAttributes.BLENDED); ta.setSrcBlendFunction(TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA); ta.setDstBlendFunction(TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA); setTransparencyAttributes(ta); } } PointAppearance.java ------------------- /** * Default appearance for rendering verticies as nodes. * * @author <a href="mailto:[EMAIL PROTECTED]">Simeon H.K. Fitch</a> * @version $Revision: 1.1 $ * @since April 11, 2002 */ public class PointAppearance extends Appearance { /** * Default ctor. */ public PointAppearance() { ColoringAttributes ca = new ColoringAttributes(); ca.setShadeModel(ColoringAttributes.SHADE_FLAT); ca.setColor(0, 0, 0); setColoringAttributes(ca); PolygonAttributes pla = new PolygonAttributes(); pla.setPolygonMode(PolygonAttributes.POLYGON_POINT); pla.setPolygonOffset(-1); pla.setPolygonOffsetFactor(0.1f); pla.setCullFace(PolygonAttributes.CULL_NONE); pla.setBackFaceNormalFlip(true); setPolygonAttributes(pla); PointAttributes pa = new PointAttributes(); pa.setPointAntialiasingEnable(false); pa.setPointSize(2); setPointAttributes(pa); RenderingAttributes ra = new RenderingAttributes(); ra.setIgnoreVertexColors(true); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE); setRenderingAttributes(ra); setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ); setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE); } } =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".