Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8148550

anti aliasing in 3D Node

XMLWordPrintable

    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.10.5

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Intel Graphics HD 4000 (MacBook Pro Mid 2012)
      Intel Graphics HD 6000 (MacBook Air Early 2015)

      A DESCRIPTION OF THE PROBLEM :
      JavaFX Flips the 3D Nodes this anti aliasing on (Balanced) on the x axis. This is not correct, because the mouse listener is still working as not flipped. For example: I have 2 Box objects added to a group (as the root node of the scene). On of the two boxes is placed at the front face of the box other box. or example, I placed it at the top-right corner. But it should be at the bottom-right corner (as n Windows). For the mouse listener, this box is at the bottom-right corner but is is not visual there.

      REGRESSION. Last worked in version 8u60

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a scenegraph with a box, not at (x, y) = (0, 0). Create a scene with anti aliasing balanced. Add a mouse clicked listener on the box and press on it. It should not workling as espected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The box response to the click, then you press at the same x point, but on the negative y value.
      ACTUAL -
      Flipped at the x axis

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No Crash

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.DepthTest;
      import javafx.scene.Group;
      import javafx.scene.Node;
      import javafx.scene.PerspectiveCamera;
      import javafx.scene.Scene;
      import javafx.scene.SceneAntialiasing;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.paint.Color;
      import javafx.scene.paint.PhongMaterial;
      import javafx.scene.shape.Box;
      import javafx.scene.transform.Rotate;
      import javafx.stage.Stage;

      public class JavaFxTest extends Application {

      final Group root = new Group();
      final Group world = new Group();
      final PerspectiveCamera camera = new PerspectiveCamera(true);
      private static final double CAMERA_INITIAL_DISTANCE = -450;
      private static final double CAMERA_NEAR_CLIP = 0.1;
      private static final double CAMERA_FAR_CLIP = 10000.0;

      double mousePosX;
      double mousePosY;

      private Rotate rotateX = new Rotate(0, Rotate.X_AXIS);
      private Rotate rotateY = new Rotate(0, Rotate.Y_AXIS);
      private Rotate rotateZ = new Rotate(0, Rotate.Z_AXIS);

      private void buildCamera() {
      root.getChildren().add(camera);

      camera.setNearClip(CAMERA_NEAR_CLIP);
      camera.setFarClip(CAMERA_FAR_CLIP);
      camera.setTranslateZ(CAMERA_INITIAL_DISTANCE);
      }

      private void handleMouse(Scene scene, final Node root) {
      scene.setOnMousePressed((MouseEvent me) -> {
      mousePosX = me.getSceneX();
      mousePosY = me.getSceneY();
      });

      scene.setOnMouseDragged((MouseEvent me) -> {
      double dx = (mousePosX - me.getSceneX());
      double dy = (mousePosY - me.getSceneY());
      if (me.isPrimaryButtonDown()) {
      rotateX.setAngle(rotateX.getAngle() - dy * 0.2);
      rotateY.setAngle(rotateY.getAngle() + dx * 0.2);
      }
      mousePosX = me.getSceneX();
      mousePosY = me.getSceneY();
      });

      root.getTransforms().addAll(rotateX, rotateY, rotateZ);
      }

      private void buildMolecule() {
      final PhongMaterial redMaterial = new PhongMaterial();
      redMaterial.setDiffuseColor(Color.DARKRED);
      redMaterial.setSpecularColor(Color.RED);

      final PhongMaterial whiteMaterial = new PhongMaterial();
      whiteMaterial.setDiffuseColor(Color.WHITE);
      whiteMaterial.setSpecularColor(Color.LIGHTBLUE);

      Box box = new Box(100, 100, 100);
      box.setMaterial(redMaterial);
      world.getChildren().add(box);

      Box button = new Box(10, 10, 10);
      button.setMaterial(whiteMaterial);
      button.setTranslateZ(-50);
      button.relocate(30, 30);
      button.setOnMouseClicked(e -> {
      System.out.println("Pressed");
      });
      world.getChildren().add(button);
      }

      @Override
      public void start(Stage primaryStage) {
      root.getChildren().add(world);
      root.setDepthTest(DepthTest.ENABLE);

      buildCamera();
      buildMolecule();

      Scene scene = new Scene(root, 1024, 768, true, SceneAntialiasing.BALANCED);
      scene.setFill(Color.GREY);
      handleMouse(scene, world);

      primaryStage.setScene(scene);
      primaryStage.show();

      scene.setCamera(camera);
      }

      public static void main(String[] args) {
      launch(args);
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      disable anti aliasing

      SUPPORT :
      YES

            ckyang Chien Yang (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: