Search in sources :

Example 6 with PolygonAttributes

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);
    }
}
Also used : Rendering(uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper.Rendering) ColoringAttributes(org.scijava.java3d.ColoringAttributes) Appearance(org.scijava.java3d.Appearance) PolygonAttributes(org.scijava.java3d.PolygonAttributes)

Aggregations

PolygonAttributes (org.scijava.java3d.PolygonAttributes)6 Appearance (org.scijava.java3d.Appearance)4 ColoringAttributes (org.scijava.java3d.ColoringAttributes)3 Material (org.scijava.java3d.Material)3 PointAttributes (org.scijava.java3d.PointAttributes)3 PointArray (org.scijava.java3d.PointArray)2 TransparencyAttributes (org.scijava.java3d.TransparencyAttributes)2 CustomLineMesh (customnode.CustomLineMesh)1 CustomMesh (customnode.CustomMesh)1 CustomMultiMesh (customnode.CustomMultiMesh)1 CustomTriangleMesh (customnode.CustomTriangleMesh)1 Content (ij3d.Content)1 Color (java.awt.Color)1 Callable (java.util.concurrent.Callable)1 GeometryArray (org.scijava.java3d.GeometryArray)1 Shape3D (org.scijava.java3d.Shape3D)1 Color3f (org.scijava.vecmath.Color3f)1 Point3f (org.scijava.vecmath.Point3f)1 Rendering (uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper.Rendering)1