javajavafx3djavafx-3d

JavaFX 3D - Is it possible to change the width of Line in DrawMode.Line?


I would like to change the linewidth of any mesh with DrawMode.LINE, but I don't know if it is possible.

I added some code for reference.

@Override
public void start(Stage primaryStage) throws Exception{
    PerspectiveCamera camera= new PerspectiveCamera(true);
    Group root = new Group();
    Scene scene = new Scene(root, 1024, 768, true);

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

    scene.setFill(Color.BLACK);
    camera.setFarClip(10000);
    camera.setTranslateZ(-10);
    scene.setCamera(camera);

    Box box  = new Box();
    box.setDrawMode(DrawMode.LINE);
    root.getChildren().addAll(camera,box);
}


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

Solution

  • It is not possible. The DrawMode is passed down to the native renderer whose default wireframe is a width 1 line. For the Direct3D pipeline, see Outline and Fill State. Even if you use the line drawing support library it will tell you that:

    The library uses native hardware line drawing support (if available in the device) only if:

    • Line width is 1.
    • No line pattern is enabled.

    Line widths that are different than 1 cannot be drawn with line primitives, but have to be drawn with triangles instead:

    The line drawing library emulates lines using texture triangles

    In other words, a width of 1 is special because it has specific hardware support.