当我在我的场景中实现子场景时,使用混合 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();
}
}