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

[JFX 8 3D] BaseMesh throws NPE in case of dead face(s)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • Win 7/64, JDK 8 b115

      The second face in ThreeTriangles.fxml is 'dead': the second and third point indices are identical. So, the two other triangles should be rendered. But the test program BaseMeshTest.java throws the below-mentioned NPE.

      My assumption is:

      This NPE is thrown because the MeshVertex-elements in 'pool' of the third (!!) face are null.

      The MeshVertex-array 'pool' is filled in BaseMesh.computeTBNormal(...). In case of a dead face the index buffer is marked (indexBuffer[index] = MeshVertex.IDX_UNDEFINED;) at the corresponding face-vertex-index. The 'pool'-index 'poolIndex' remains unchanged. In consequence the arrays 'indexBuffer' and 'pool' are no longer synchronized. The MeshVertex-elements of the third face are set at the positions for the second face and the remaining elements for the third face are null.

      This NPE is not thrown when the file is loaded in 3DViewer, only the WARNING is printed. The initially loaded model in 3DViewer creates a MeshTempState instance which 'pool'-array is reused because it exists and has a sufficient length. But the rendering is not correct: only one of at least two regular triangles is rendered.

      Hope this helps.

      ThreeTriangles.fxml

      <?xml version="1.0" encoding="utf-8"?>

      <?import javafx.scene.paint.PhongMaterial?>
      <?import javafx.scene.shape.MeshView?>
      <?import javafx.scene.shape.TriangleMesh?>

      <MeshView>
        <material>
          <PhongMaterial diffuseColor="#ff0000">
          </PhongMaterial>
        </material>
        <mesh>
          <TriangleMesh>
            <points>0.0 0.0 0.0 1.0 0.0 0.0 0.5 -1.0 0.0 2.0 0.0 0.0 3.0 0.0 0.0 2.5 -1.0 0.0 1.5 -0.5 0.0 2.0 -1.5 0.0 1.0 -1.5 0.0</points>
            <texCoords>0 0</texCoords>
            <faces>0 0 1 0 2 0 3 0 4 0 4 0 6 0 7 0 8 0</faces>
            <faceSmoothingGroups>1 1 1</faceSmoothingGroups>
          </TriangleMesh>
        </mesh>
      </MeshView>
       
      Nov 18, 2013 11:49:30 AM com.sun.prism.impl.BaseMesh computeTBNormal
      WARNUNG: Dead face [3, 4, 4] @ face group 1; nEmptyFaces = 1
      java.lang.NullPointerException
              at com.sun.prism.impl.BaseMesh.buildIndexBuffer(BaseMesh.java:251)
              at com.sun.prism.impl.BaseMesh.buildGeometry(BaseMesh.java:122)
              at com.sun.javafx.sg.prism.NGTriangleMesh.validate(NGTriangleMesh.java:65)
              at com.sun.javafx.sg.prism.NGShape3D.renderMeshView(NGShape3D.java:86)
              at com.sun.javafx.sg.prism.NGShape3D.renderContent(NGShape3D.java:188)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2037)
              at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:225)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2037)
              at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
              at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:475)
              at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:330)
              at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
              at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
              at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:129)
              at java.lang.Thread.run(Thread.java:744)
              

      BaseMeshTest.java

      package jiraissue;

      import java.io.IOException;
      import java.net.URL;
      import javafx.application.Application;
      import javafx.event.EventHandler;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Group;
      import javafx.scene.Node;
      import javafx.scene.PerspectiveCamera;
      import javafx.scene.PointLight;
      import javafx.scene.Scene;
      import javafx.scene.paint.Color;
      import javafx.stage.Stage;
      import javafx.stage.WindowEvent;

      public class BaseMeshTest extends Application {
          
          public static void main(String[] args) {
              launch(args);
          }
          
          @Override public void start(Stage stage) {
              
              final URL modelUrl = this.getClass().getResource("ThreeTriangles.fxml");
              final FXMLLoader fxmlLoader = new FXMLLoader(modelUrl);
              Node model = null;
              try {
                  model = (Node)fxmlLoader.load();
              }
              catch(IOException e) {
                  e.printStackTrace();
                  return;
              }
              
              final PerspectiveCamera perspectiveCamera = new PerspectiveCamera(true);
              perspectiveCamera.setTranslateX(1.5);
              perspectiveCamera.setTranslateY(-0.5);
              perspectiveCamera.setTranslateZ(-6);

              final PointLight pointLight = new PointLight(Color.WHITE);
              pointLight.setTranslateZ(-200);

              final Group root = new Group(model, perspectiveCamera, pointLight);
              final Scene scene = new Scene(root, 800, 800, true);
              scene.setCamera(perspectiveCamera);
              stage.setTitle("BaseMeshTest");
              stage.setScene(scene);
              stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                  @Override public void handle(WindowEvent event) {
                      System.exit(0);
                  }
              });
              stage.show();
          }
      }

            ckyang Chien Yang (Inactive)
            alammersdjfx August Lammersdorf (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: