diff --git a/GUI/src/main/java/cz/fidentis/analyst/scene/Drawable.java b/GUI/src/main/java/cz/fidentis/analyst/scene/Drawable.java index c6dbe3210bbd27e30b1630f2280cd12fe1e256e9..16a76b9811e0cf97a0d43a324e4b88fdd4571fb8 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/scene/Drawable.java +++ b/GUI/src/main/java/cz/fidentis/analyst/scene/Drawable.java @@ -3,6 +3,7 @@ package cz.fidentis.analyst.scene; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2; import java.awt.Color; +import java.util.Comparator; import javax.vecmath.Vector3d; /** @@ -31,7 +32,25 @@ public abstract class Drawable { * Render mode to use, one from {@code GL_FILL}, {@code GL_LINE}, {@code GL_POINT} */ private int renderMode = GL2.GL_FILL; // GL_FILL, GL_LINE, or GL_POINT - + + /** + * Comparator for Drawable objects based on transparency. Used for rendering. + * + * @author Dominik Racek + */ + public static class TransparencyComparator implements Comparator<Drawable> { + @Override + public int compare(Drawable a, Drawable b) { + if (a.transparency < b.transparency) { + return 1; + } + if (a.transparency > b.transparency) { + return -1; + } + return 0; + } + } + /** * Renders the scene. * @param gl OpenGL context diff --git a/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java b/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java index 7307d5afe9fe12edf8feab2b9a7c7ae7523323cf..c1af7f1e5736715e2046c41c3bafc3bd7f9ca391 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java +++ b/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java @@ -117,17 +117,12 @@ public class SceneRenderer { gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_DIFFUSE, Color.white.getComponents(null), 0); setPosition(camera); - List<DrawableFace> faces = getOrderedFaces(drawables); - - for (Drawable obj: drawables) { - if (!(obj instanceof DrawableFace) && obj.isShown()) { - obj.render(gl); - } - } - - for (DrawableFace obj: faces) { + + List<Drawable> objects = new ArrayList<>(drawables); + objects.sort(new Drawable.TransparencyComparator()); + + for (Drawable obj : objects) { if (obj.isShown()) { - //showBackface(obj); obj.render(gl); } } diff --git a/GUI/src/main/java/cz/fidentis/analyst/symmetry/PolylinePanel.java b/GUI/src/main/java/cz/fidentis/analyst/symmetry/PolylinePanel.java index 3ee55f9fa7bac44ab20bca2990e2ceed2d8bb086..2fde656939aa0d5a79537f6cc2aa372d937fb224 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/symmetry/PolylinePanel.java +++ b/GUI/src/main/java/cz/fidentis/analyst/symmetry/PolylinePanel.java @@ -24,7 +24,9 @@ public class PolylinePanel extends JPanel { private static final int PREF_H = 500; private static final int BORDER_GAP = 15; private static final Color PRIMARY_COLOR = Color.green; - private static final Color SECONDARY_COLOR = Color.blue; + private static final Color PRIMARY_MIRROR_COLOR = new Color(0, 85, 0); + private static final Color SECONDARY_COLOR = new Color(0, 155, 200); + private static final Color SECONDARY_MIRROR_COLOR = Color.blue; private static final Stroke GRAPH_STROKE = new BasicStroke(3f); private List<Point3d> primaryPoints; private List<Point3d> secondaryPoints; @@ -144,11 +146,11 @@ public class PolylinePanel extends JPanel { if (mirrorCuts) { drawFace(g2, primaryPoints, PRIMARY_COLOR, true); - drawFace(g2, primaryMirrorPoints, SECONDARY_COLOR, true); + drawFace(g2, primaryMirrorPoints, PRIMARY_MIRROR_COLOR, true); if (secondaryPoints != null) { - drawFace(g2, secondaryPoints, PRIMARY_COLOR, false); - drawFace(g2, secondaryMirrorPoints, SECONDARY_COLOR, false); + drawFace(g2, secondaryPoints, SECONDARY_COLOR, false); + drawFace(g2, secondaryMirrorPoints, SECONDARY_MIRROR_COLOR, false); } } else { drawFace(g2, primaryPoints, PRIMARY_COLOR, true); diff --git a/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java b/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java index 195ae01deab651ede841d24783d56063746f9f2c..dec51a69aea0a9a49959c7563accd11b4c05558e 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java @@ -168,8 +168,10 @@ public class ProfilesAction extends ControlPanelAction { case ProfilesPanel.ACTION_COMMAND_SHOW_HIDE_PLANE: if (((JToggleButton) ae.getSource()).isSelected()) { getScene().showCuttingPlanes(); + getScene().showMirrorPlanes(); } else { getScene().hideCuttingPlanes(); + getScene().hideMirrorPlanes(); } break; case ProfilesPanel.ACTION_COMMAND_EXPORT: diff --git a/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java b/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java index fa8a4688a947dbcf8ca46416f5cdec0862c33a2a..77d00ea3bac8a8ea2e8a2fe6bc9a52f16051d952 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java @@ -75,23 +75,39 @@ public class SymmetryAction extends ControlPanelAction { SymmetryEstimator primaryEstimator = new SymmetryEstimator(controlPanel.getSymmetryConfig()); getPrimaryDrawableFace().getModel().compute(primaryEstimator); - getCanvas().getScene().setDrawableSymmetryPlane(0, - new DrawablePlane(primaryEstimator.getSymmetryPlaneMesh(), primaryEstimator.getSymmetryPlane())); - getCanvas().getScene().setDrawableCuttingPlane(0, - new DrawablePlane(primaryEstimator.getSymmetryPlaneMesh(), primaryEstimator.getSymmetryPlane())); - getCanvas().getScene().setDrawableMirrorPlane(0, - new DrawablePlane(primaryEstimator.getSymmetryPlaneMesh(), primaryEstimator.getSymmetryPlane())); + DrawablePlane primarySymmetryPlane = new DrawablePlane(primaryEstimator.getSymmetryPlaneMesh(), + primaryEstimator.getSymmetryPlane()); + primarySymmetryPlane.setTransparency(0.5f); + getScene().setDrawableSymmetryPlane(0, primarySymmetryPlane); + + DrawablePlane primaryCuttingPlane = new DrawablePlane(primaryEstimator.getSymmetryPlaneMesh(), + primaryEstimator.getSymmetryPlane()); + primaryCuttingPlane.setTransparency(0.5f); + getScene().setDrawableCuttingPlane(0, primaryCuttingPlane); + + DrawablePlane primaryMirrorPlane = new DrawablePlane(primaryEstimator.getSymmetryPlaneMesh(), + primaryEstimator.getSymmetryPlane()); + primaryMirrorPlane.setTransparency(0.5f); + getScene().setDrawableMirrorPlane(0, primaryMirrorPlane); if (getSecondaryDrawableFace() != null) { SymmetryEstimator secondaryEstimator = new SymmetryEstimator(controlPanel.getSymmetryConfig()); getSecondaryDrawableFace().getModel().compute(secondaryEstimator); - getCanvas().getScene().setDrawableSymmetryPlane(1, - new DrawablePlane(secondaryEstimator.getSymmetryPlaneMesh(), secondaryEstimator.getSymmetryPlane())); - getCanvas().getScene().setDrawableCuttingPlane(1, - new DrawablePlane(secondaryEstimator.getSymmetryPlaneMesh(), secondaryEstimator.getSymmetryPlane())); - getCanvas().getScene().setDrawableMirrorPlane(1, - new DrawablePlane(secondaryEstimator.getSymmetryPlaneMesh(), secondaryEstimator.getSymmetryPlane())); + DrawablePlane secondarySymmetryPlane = new DrawablePlane(secondaryEstimator.getSymmetryPlaneMesh(), + secondaryEstimator.getSymmetryPlane()); + secondarySymmetryPlane.setTransparency(0.5f); + getScene().setDrawableSymmetryPlane(1, secondarySymmetryPlane); + + DrawablePlane secondaryCuttingPlane = new DrawablePlane(secondaryEstimator.getSymmetryPlaneMesh(), + secondaryEstimator.getSymmetryPlane()); + secondaryCuttingPlane.setTransparency(0.5f); + getScene().setDrawableCuttingPlane(1, secondaryCuttingPlane); + + DrawablePlane secondaryMirrorPlane = new DrawablePlane(secondaryEstimator.getSymmetryPlaneMesh(), + secondaryEstimator.getSymmetryPlane()); + secondaryMirrorPlane.setTransparency(0.5f); + getScene().setDrawableMirrorPlane(1, secondaryMirrorPlane); } getCanvas().getScene().hideSymmetryPlanes();