场景深度缓冲区不起作用

时间:2016-12-07 12:42:46

标签: java javafx-8

我在JavaFX中遇到深度缓冲区问题。 我开始了一个模拟,现在尝试围绕Y轴旋转我的风轮。 通常它只是显示我的窗格与场景,我可以点击我添加到我的场景中的每个按钮和图表。 正如我注意到隐藏风轮不同部分的最佳方法是深度缓冲。如果我把他设置为真我甚至不能点击我的场景并进行更改。

我在这里有一张照片 with depth buffer

没有深度缓冲区 without depth buffer

所以任何人都知道通过激活缓冲区出了什么问题?

这是我的开始方法:

public class Main extends Application {
Stage primaryStage;
Pane region;
Scene simulation;
Group root;

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

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

    this.primaryStage = primaryStage;
    region = new Pane();
    root = new Group();
    simulation = new Scene(root, 1200, 1000,true);
    simulation.setCamera(new PerspectiveCamera());
    primaryStage.setScene(simulation);
    simulation.setRoot(region);

    new GUI(simulation, region);

    primaryStage.show();

}}

这是我从以下各项加载所有内容的GUI类:

public class GUI {

Pane pane;

ComboBox<String> windpark;

ObservableList<String> recordsWindpark;

ObservableList<String> recrodsWindDirection;

Label settings;

Label windDirection;

Label windStrength;

Label birds;

Label bos;

Label fire;

Label totalKW;

Button start;

Button stop;

Button reset;

Button add;

Button delete;

Button x1;

Button x2;

Button x4;

Button chartRenew;

Line bottomLine;

Line sideline;

Line settingLine;

CheckBox birdsYes;

CheckBox birdsNo;

CheckBox fireYes;

CheckBox fireNo;

CheckBox bosYes;

CheckBox bosNo;

ComboBox<String> windDirectionCombo;

TextField windDegree;

Box gamefield;

Scene scene;

Group root;

int scalingForGUI;

Double timeData;
String windStrenghtData;

WindWheel rad;
WindWheel rad2;
WindWheel rad3;
WindWheel rad4;
WindWheel rad5;
WindWheel rad6;


public GUI(Scene scene, Pane pane) {

    this.pane = pane;
    root = new Group();
    this.scene = scene;


    recordsWindpark = FXCollections.observableArrayList("Windpark Ostsee", "Windpark Nordsee","Delete");
    recrodsWindDirection = FXCollections.observableArrayList("Nord - Nord/Ost", "Ost - Süd/Ost", "Süd - Süd/West",
            "West - Nord/West");

    settings = new Label("Settings");
    settings.setLayoutX(900);
    settings.setLayoutY(30 - scalingForGUI);

    windpark = new ComboBox<>(recordsWindpark);
    windpark.setLayoutX(900);
    windpark.setLayoutY(90 - scalingForGUI);

    windDirection = new Label("Windrichtung");
    windDirection.setLayoutX(900);
    windDirection.setLayoutY(200 - scalingForGUI);

    windStrength = new Label("Windstaerke");
    windStrength.setLayoutX(900);
    windStrength.setLayoutY(300 - scalingForGUI);

    birds = new Label("Voegel");
    birds.setLayoutX(900);
    birds.setLayoutY(540 - scalingForGUI);

    bos = new Label("Boeen");
    bos.setLayoutX(900);
    bos.setLayoutY(600 - scalingForGUI);

    fire = new Label("Brand");
    fire.setLayoutX(900);
    fire.setLayoutY(660 - scalingForGUI);

    totalKW = new Label("Gesamt KW");
    totalKW.setLayoutX(900);
    totalKW.setLayoutY(750 - scalingForGUI);

    start = new Button("Start");
    start.setLayoutX(30);
    start.setLayoutY(700);

    stop = new Button("Stop");
    stop.setLayoutX(80);
    stop.setLayoutY(700);

    reset = new Button("Reset");
    reset.setLayoutX(130);
    reset.setLayoutY(700);

    add = new Button("Add");
    add.setLayoutX(600);
    add.setLayoutY(700);

    delete = new Button("Delete");
    delete.setLayoutX(650);
    delete.setLayoutY(700);

    x1 = new Button("x1");
    x1.setLayoutX(550);
    x1.setLayoutY(100);

    x2 = new Button("x2");
    x2.setLayoutX(600);
    x2.setLayoutY(100);

    x4 = new Button("x4");
    x4.setLayoutX(650);
    x4.setLayoutY(100);

    gamefield = new Box(600, 40, 600);
    gamefield.setMaterial(new PhongMaterial(Color.GREENYELLOW));
    gamefield.getTransforms().add(new Rotate(10, 0, 0, 0, Rotate.X_AXIS));
    gamefield.getTransforms().add(new Rotate(20, 0, 0, 0, Rotate.Y_AXIS));
    gamefield.setLayoutX(400);
    gamefield.setLayoutY(500);
    gamefield.setTranslateZ(1);

    bottomLine = new Line(0, 650, 850, 650);
    sideline = new Line(850, 0, 850, 1000);
    settingLine = new Line(850, 140, 1500, 140);

    birdsYes = new CheckBox("Yes");
    birdsYes.setLayoutX(900);
    birdsYes.setLayoutY(560 - scalingForGUI);

    birdsNo = new CheckBox("No");
    birdsNo.setLayoutX(970);
    birdsNo.setLayoutY(560 - scalingForGUI);

    fireYes = new CheckBox("Yes");
    fireYes.setLayoutX(900);
    fireYes.setLayoutY(680 - scalingForGUI);

    fireNo = new CheckBox("No");
    fireNo.setLayoutX(970);
    fireNo.setLayoutY(680 - scalingForGUI);

    bosYes = new CheckBox("Yes");
    bosYes.setLayoutX(900);
    bosYes.setLayoutY(620 - scalingForGUI);

    bosNo = new CheckBox("No");
    bosNo.setLayoutX(970);
    bosNo.setLayoutY(620 - scalingForGUI);

    chartRenew = new Button("Renew Charts");
    chartRenew.setLayoutX(720);
    chartRenew.setLayoutY(100);

    windDirectionCombo = new ComboBox<>(recrodsWindDirection);
    windDirectionCombo.setLayoutX(900);
    windDirectionCombo.setLayoutY(230);
    windDirectionCombo.setOnAction(e -> {
        switchtingWind();
    });

    windDegree = new TextField("Gradzahl");
    windDegree.setLayoutX(900);
    windDegree.setLayoutY(260);
    windDegree.setEditable(false);




    pane.getChildren().addAll(gamefield, settings, windpark, windDirection, windStrength, birds, bos, fire, totalKW,
            start, stop, reset, add, delete, x1, x2, x4, bottomLine, sideline, settingLine, birdsYes, birdsNo,
            fireYes, fireNo, bosYes, bosNo, windDirectionCombo, windDegree, chartRenew);

    scene.setRoot(pane);

    String artLeistung = "Leistung";
    Chart chartLeistung = new Chart(pane, artLeistung);
    chartLeistung.enableEventHandler();
    chartLeistung.setLayout(835, 310);

}

我希望有人可以帮助我。

谢谢!

0 个答案:

没有答案
相关问题