@Override protected Appearance createAppearance() { Appearance appearance = new Appearance(); appearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ); appearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ); LineAttributes lineAttrib = new LineAttributes(); lineAttrib.setCapability(LineAttributes.ALLOW_ANTIALIASING_WRITE); lineAttrib.setCapability(LineAttributes.ALLOW_PATTERN_WRITE); lineAttrib.setCapability(LineAttributes.ALLOW_WIDTH_WRITE); lineAttrib.setLineWidth(linewidth); lineAttrib.setLinePattern(pattern); appearance.setLineAttributes(lineAttrib); PolygonAttributes polyAttrib = new PolygonAttributes(); polyAttrib.setCapability(PolygonAttributes.ALLOW_MODE_WRITE); polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_FILL); polyAttrib.setCullFace(PolygonAttributes.CULL_NONE); polyAttrib.setBackFaceNormalFlip(true); appearance.setPolygonAttributes(polyAttrib); ColoringAttributes colorAttrib = new ColoringAttributes(); colorAttrib.setShadeModel(ColoringAttributes.SHADE_GOURAUD); colorAttrib.setColor(color); appearance.setColoringAttributes(colorAttrib); TransparencyAttributes tr = new TransparencyAttributes(); int mode = transparency == 0f ? TransparencyAttributes.NONE : TransparencyAttributes.FASTEST; tr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE); tr.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE); tr.setTransparencyMode(mode); tr.setTransparency(transparency); appearance.setTransparencyAttributes(tr); Material material = new Material(); material.setCapability(Material.ALLOW_COMPONENT_WRITE); material.setAmbientColor(0.1f, 0.1f, 0.1f); material.setSpecularColor(0.1f, 0.1f, 0.1f); material.setDiffuseColor(0.1f, 0.1f, 0.1f); appearance.setMaterial(material); return appearance; }
@Override protected Appearance createAppearance() { final Appearance appearance = new Appearance(); appearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ); appearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ); final PointAttributes pointAttrib = new PointAttributes(); pointAttrib.setCapability(PointAttributes.ALLOW_ANTIALIASING_WRITE); pointAttrib.setCapability(PointAttributes.ALLOW_SIZE_WRITE); pointAttrib.setPointSize(pointsize); appearance.setPointAttributes(pointAttrib); final PolygonAttributes polyAttrib = new PolygonAttributes(); polyAttrib.setCapability(PolygonAttributes.ALLOW_MODE_WRITE); polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_FILL); polyAttrib.setCullFace(PolygonAttributes.CULL_BACK); polyAttrib.setBackFaceNormalFlip(false); appearance.setPolygonAttributes(polyAttrib); final ColoringAttributes colorAttrib = new ColoringAttributes(); colorAttrib.setShadeModel(ColoringAttributes.SHADE_GOURAUD); colorAttrib.setColor(color); appearance.setColoringAttributes(colorAttrib); final TransparencyAttributes tr = new TransparencyAttributes(); final int mode = transparency == 0f ? TransparencyAttributes.NONE : TransparencyAttributes.FASTEST; tr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE); tr.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE); tr.setTransparencyMode(mode); tr.setTransparency(transparency); appearance.setTransparencyAttributes(tr); final Material material = new Material(); material.setCapability(Material.ALLOW_COMPONENT_WRITE); material.setAmbientColor(0.1f, 0.1f, 0.1f); material.setSpecularColor(0.1f, 0.1f, 0.1f); material.setDiffuseColor(0.1f, 0.1f, 0.1f); appearance.setMaterial(material); return appearance; }
private void setOtherAppearanceValues(int mode, float factor, Color color, boolean visible) { // Transparency values TransparencyAttributes ta = new TransparencyAttributes(mode, factor); ta.setCapability(TransparencyAttributes.ALLOW_VALUE_READ); ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE); ta.setCapability(TransparencyAttributes.ALLOW_MODE_READ); ta.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE); setTransparencyAttributes(ta); setCapability(ALLOW_TRANSPARENCY_ATTRIBUTES_READ); setCapability(ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE); // For highlight setCapability(ALLOW_MATERIAL_READ); setCapability(ALLOW_MATERIAL_WRITE); // For visibility setCapability(ALLOW_RENDERING_ATTRIBUTES_READ); setCapability(ALLOW_RENDERING_ATTRIBUTES_WRITE); // Color setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ); setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); // Adding Rendering attributes to access visibility flag if layer is available if (layer != null) { RenderingAttributes ra = new RenderingAttributes(); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_READ); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE); ra.setCapability(RenderingAttributes.ALLOW_DEPTH_ENABLE_READ); ra.setCapability(RenderingAttributes.ALLOW_DEPTH_ENABLE_WRITE); ra.setVisible(visible); setRenderingAttributes(ra); if (mode != TransparencyAttributes.NONE) ra.setDepthBufferEnable(true); } // Set up the polygon attributes // PolygonAttributes pa = new PolygonAttributes(); // pa.setCullFace(PolygonAttributes.CULL_NONE); // pa.setPolygonMode(PolygonAttributes.POLYGON_LINE); // setPolygonAttributes(pa); // TextureAttributes texAttr = new TextureAttributes(); // texAttr.setTextureMode(TextureAttributes.MODULATE); // texAttr.setTextureColorTable(pattern); // setTextureAttributes(texAttr); // LineAttributes lineAttr = new LineAttributes(); // lineAttr.setLineAntialiasingEnable(true); // setLineAttributes(lineAttr); // Adding to internal material // Material mat = new Material(objColor, black, objColor, white, 70.0f); if (color != null) { Color3f objColor = new Color3f(color); // Emissive is black and specular is plastic! // Color3f specular = new Color3f(color.brighter()); Material mat = new Material(objColor, J3DUtils.black, objColor, J3DUtils.plastic /*J3DUtils.white*/, 17); mat.setLightingEnable(true); mat.setCapability(Material.ALLOW_COMPONENT_READ); mat.setCapability(Material.ALLOW_COMPONENT_WRITE); mat.setCapability(Material.AMBIENT_AND_DIFFUSE); setMaterial(mat); } }