use of org.scijava.java3d.PolygonAttributes in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method updateAppearance.
private static void updateAppearance(CustomMesh mesh, final ImageJ3DResultsViewerSettingsOrBuilder settings) {
mesh.setShaded(settings.getShaded());
final Appearance appearance = mesh.getAppearance();
final PolygonAttributes pa = appearance.getPolygonAttributes();
// For all 3D polygons we want to support a true face orientation so transparency works
final Rendering r = Rendering.forNumber(settings.getRendering());
if (r.is2D()) {
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setBackFaceNormalFlip(true);
} else {
pa.setCullFace(PolygonAttributes.CULL_BACK);
pa.setBackFaceNormalFlip(false);
}
// TransparencyAttributes ta = appearance.getTransparencyAttributes();
// ta.setSrcBlendFunction(TransparencyAttributes.BLEND_SRC_ALPHA);
// ta.setDstBlendFunction(TransparencyAttributes.BLEND_ONE);
// ta.setDstBlendFunction(TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA); // Default
ItemTriangleMesh.setTransparencyMode(TransparencyAttributes.FASTEST);
// ItemTriangleMesh.setTransparencyMode(TransparencyAttributes.SCREEN_DOOR);
// ItemTriangleMesh.setTransparencyMode(TransparencyAttributes.BLENDED);
final ColoringAttributes ca = appearance.getColoringAttributes();
if (r.isHighResolution() || r.is2D()) {
// Smooth across vertices. Required to show 2D surfaces smoothly
ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
} else {
// Faster polygon rendering with flat shading
ca.setShadeModel(ColoringAttributes.SHADE_FLAT);
}
}
Aggregations