Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFx透视摄像头-FixedYeatCamerazero标志-如果为true,所有对象都将消失_Java_Javafx_Graphics_3d_Javafx 3d - Fatal编程技术网

JavaFx透视摄像头-FixedYeatCamerazero标志-如果为true,所有对象都将消失

JavaFx透视摄像头-FixedYeatCamerazero标志-如果为true,所有对象都将消失,java,javafx,graphics,3d,javafx-3d,Java,Javafx,Graphics,3d,Javafx 3d,我想模拟长方体和矩形的透视失真。我的目标是扭曲长方体和图像,就像相机倾斜和移动一样。但我真的不懂如何使用透视照相机 当我将fixedEyeAtCameraZero设置为false时,我可以在屏幕上看到框和图像。但改变窗口大小会导致奇怪的正交透视变化,这是不现实的 另一方面,当我将fixedeayatcamerazero设置为true时,我看到的只是一个空白窗口 错误: 正确: 这是代码,第51行有违规标志 package sample; import javafx.application.A

我想模拟长方体和矩形的透视失真。我的目标是扭曲长方体和图像,就像相机倾斜和移动一样。但我真的不懂如何使用透视照相机

当我将
fixedEyeAtCameraZero
设置为
false
时,我可以在屏幕上看到框和图像。但改变窗口大小会导致奇怪的正交透视变化,这是不现实的

另一方面,当我将
fixedeayatcamerazero
设置为
true
时,我看到的只是一个空白窗口

错误:

正确:

这是代码,第51行有违规标志

package sample;
import javafx.application.Application;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.shape.Box;
import javafx.scene.shape.DrawMode;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class Example_Box extends Application {
    @Override
    public void start(Stage stage) {

        //Drawing a Box
        Box box2 = new Box();

        //Setting the properties of the Box
        box2.setWidth(100.0);
        box2.setHeight(100.0);
        box2.setDepth(100.0);

        //Setting the position of the box
        box2.setTranslateX(30); //450
        box2.setTranslateY(90);//150
        box2.setTranslateZ(300);

        //Setting the drawing mode of the box
        box2.setDrawMode(DrawMode.LINE);

        //Drawing an Image
        Image image = new Image("Lenna.png");
        ImageView imageView = new ImageView(image);
        imageView.setTranslateX(200);
        imageView.setTranslateY(150);
        imageView.setTranslateZ(200);

        //imageView.getTransforms().add(new Rotate(30, 50, 30));

        //Creating a Group object
        Group root = new Group(box2, imageView);

        //Creating a scene object
        Scene scene = new Scene(root, 600, 300);

        //Setting camera
        PerspectiveCamera camera = new PerspectiveCamera(true);
        camera.setTranslateX(30);
        camera.setTranslateY(0);
        camera.setTranslateZ(-100);

        camera.setRotationAxis(new Point3D(1,0,0));
        scene.setCamera(camera);

        //Setting title to the Stage
        stage.setTitle("Drawing a Box");

        //Adding scene to the stage
        stage.setScene(scene);

        //Displaying the contents of the stage
        stage.show();
    }
    public static void main(String args[]){
        launch(args);
    }
}

尝试更改farClip值。默认情况下,FX透视摄影机中的farClip值为100

    camera.setFarClip(2000.0);
加上上面的代码,我可以看到盒子。如果我把相机移得更远(Z方向),我也能看到图像

    camera.setTranslateZ(-1000);
参考: