【问题标题】:JFX8 Mixed 2D and 3D, Scene Subscene incorrect drawing 3ds-fileJFX8 混合 2D 和 3D,场景子场景不正确绘制 3ds 文件
【发布时间】:2023-04-03 12:38:01
【问题描述】:

在我的场景中实现子场景时,使用混合 2D 和 3D 时遇到一些问题。 您可以通过单击链接查看问题。我正在使用 Interactivemesh-Modelimporter。

http://s3.postimg.org/nsef8o1f3/without_Subscene.png

http://s3.postimg.org/y16wehpgv/with_Subscene.png

import com.interactivemesh.jfx.importer.ImportException;
import com.interactivemesh.jfx.importer.tds.TdsModelImporter;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Camera;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.SubScene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;



public class JavaFX7 extends Application {

HBox hBoxControls;
Group model3D;
double y_Axis;
double x_Axis;
double rotate;
public Rotate cameraXRotate;
public Rotate cameraYRotate;
public Translate cameraPosition2;

Camera camera;



public void controls() { 
    ...
            ...
}

public void model () {

    //
    // importing 3ds Modell
    // 

    TdsModelImporter myModel = new TdsModelImporter();
        try {
            String path = "C:/Users/Corvin/Downloads/DUC916_L.3DS/DUC916_L.3DS";
            myModel.read(path);
        }
        catch (ImportException e)
        {
            System.out.println("Error importing 3ds model: "+e.getMessage());
            return;
        }

    final Node[] myMesh = myModel.getImport();
    myModel.close();
    model3D = new Group(myMesh);        

}

public static void main(String[] args) {

    launch();
}

@Override
public void start(Stage stage) throws Exception {

    y_Axis = 0.0;
    controls();
    model();

    Camera camera = new PerspectiveCamera();

     //-------------------
    cameraXRotate = new Rotate(-5,Rotate.X_AXIS);
    cameraYRotate = new Rotate(-50,Rotate.Y_AXIS);
    cameraPosition2 = new Translate(0,-1900,-14000);    

    camera.getTransforms().add(cameraXRotate);
    camera.getTransforms().add(cameraYRotate);
    camera.getTransforms().add(cameraPosition2);
     //-------------------

    Pane sub = new Pane();
    AnchorPane root = new AnchorPane();     

    AnchorPane.setRightAnchor(hBoxControls, 10.0);
    AnchorPane.setBottomAnchor(hBoxControls, 10.0);
    root.getChildren().add(hBoxControls);

    // ---------------------------------------
    Scene scene = new Scene(root, 800, 600, true);  
    SubScene subScene = new SubScene (sub, 800, 600);

    subScene.setCamera(camera);

    sub.getChildren().add(model3D);

    root.getChildren().add(subScene);

    stage.setScene(scene);
    stage.show();

}

}

【问题讨论】:

    标签: java javafx javafx-8 java-8 3ds


    【解决方案1】:

    您正在使用 3D 模型。

    这意味着您的子场景需要一个 deapthBuffer 而不是您的主场景。这就是它适用于主要场景的原因。

    改变

    SubScene subScene = new SubScene (sub, 800, 600);
    

    SubScene subScene = new SubScene(sub, 800, 600,true, SceneAntialiasing.DISABLED);
    

    (SceneAntialiasing.DISABLED 或 SceneAntialiasing.BALANCED)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-06
      • 1970-01-01
      相关资源
      最近更新 更多