Java Code Examples for javafx.scene.PerspectiveCamera#setFieldOfView()

The following examples show how to use javafx.scene.PerspectiveCamera#setFieldOfView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewFrustumTest.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp()
{
	camera = new PerspectiveCamera(true);
	camera.setNearClip(0.1);
	camera.setFarClip(10.0);
	camera.setFieldOfView(45);
	camera.setVerticalFieldOfView(true);

	frustumCamera = new ViewFrustum(camera, new double[] {800, 600});

	cameraTransform = new AffineTransform3D();
	cameraTransform.setTranslation(0, 0, -1);

	sceneTransform = new AffineTransform3D();
	sceneTransform.set(
			-1.9735242914056459E-4, -1.0436920839427981E-4, -2.061953312972022E-4, 3.0306137875177632,
			-1.2649862727035413E-4, -1.7813723813362014E-4, 2.11240737752298E-4, 0.956379113095983,
			-1.9341029860978865E-4, 2.2300587509429097E-4, 7.223755022420857E-5, -1.1240682338705246
		);

	sourceToWorldTransform = new AffineTransform3D();
	sourceToWorldTransform.set(
			64.0, 0.0, 0.0, 3674.0,
			0.0, 64.0, 0.0, 3674.0,
			0.0, 0.0, 80.0, 1540.0
		);
}
 
Example 2
Source File: TilesFxDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
	FlowGridPane pane = new FlowGridPane(7, 4, percentageTile, clockTile, gaugeTile, sparkLineTile, areaChartTile,
			lineChartTile, timerControlTile, numberTile, textTile, highLowTile, plusMinusTile, sliderTile,
			switchTile, timeTile, barChartTile, customTile, leaderBoardTile, worldTile, mapTile, radialChartTile,
			donutChartTile, circularProgressTile, stockTile, gaugeSparkLineTile, radarChartTile1, radarChartTile2,
			smoothAreaChartTile, countryTile, flipTile);// , weatherTile);

	pane.setHgap(5);
	pane.setVgap(5);
	pane.setAlignment(Pos.CENTER);
	pane.setCenterShape(true);
	pane.setPadding(new Insets(5));
	// pane.setPrefSize(800, 600);
	pane.setBackground(new Background(new BackgroundFill(Color.web("#101214"), CornerRadii.EMPTY, Insets.EMPTY)));

	PerspectiveCamera camera = new PerspectiveCamera();
	camera.setFieldOfView(7);
	
	Scene scene = new Scene(pane);
	scene.setCamera(camera);
	
	stage.setTitle("TilesFX");
	stage.setScene(scene);
	stage.show();

	timer.start();

	mapTile.addPoiLocation(new Location(51.85, 7.75, "Test"));
	mapTile.removePoiLocation(new Location(51.85, 7.75, "Test"));
}
 
Example 3
Source File: TilesDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    FlowGridPane pane = new FlowGridPane(7, 5,
                                         percentageTile, clockTile, gaugeTile, sparkLineTile, areaChartTile,
                                         lineChartTile, timerControlTile, numberTile, textTile,
                                         highLowTile, plusMinusTile, sliderTile, switchTile, timeTile,
                                         barChartTile, customTile, leaderBoardTile, worldTile, mapTile,
                                         radialChartTile, donutChartTile, circularProgressTile, stockTile,
                                         gaugeSparkLineTile, radarChartTile1, radarChartTile2,
                                         smoothAreaChartTile, countryTile, ephemerisTile, characterTile,
                                         flipTile, switchSliderTile, dateTile, calendarTile);//, weatherTile);

    pane.setHgap(5);
    pane.setVgap(5);
    pane.setAlignment(Pos.CENTER);
    pane.setCenterShape(true);
    pane.setPadding(new Insets(5));
    //pane.setPrefSize(800, 600);
    pane.setBackground(new Background(new BackgroundFill(Color.web("#101214"), CornerRadii.EMPTY, Insets.EMPTY)));

    PerspectiveCamera camera = new PerspectiveCamera();
    camera.setFieldOfView(10);

    Scene scene = new Scene(pane);
    scene.setCamera(camera);

    stage.setTitle("TilesFX");
    stage.setScene(scene);
    stage.show();

    timer.start();

    mapTile.addPoiLocation(new Location(51.85, 7.75, "Test"));
    mapTile.removePoiLocation(new Location(51.85, 7.75, "Test"));
}
 
Example 4
Source File: BillBoardBehaviorTest.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
private void createSubscene(){        
    subScene = new SubScene(root, 800, 600, true, SceneAntialiasing.BALANCED);
    
    camera = new PerspectiveCamera(true);
    cameraTransform.setTranslate(0, 0, 0);
    cameraTransform.getChildren().addAll(camera);
    camera.setNearClip(0.1);
    camera.setFarClip(100000.0);
    camera.setFieldOfView(35);
    camera.setTranslateZ(-cameraDistance);
    cameraTransform.ry.setAngle(-45.0);
    cameraTransform.rx.setAngle(-10.0);
    //add a Point Light for better viewing of the grid coordinate system
    PointLight light = new PointLight(Color.WHITE);
    
    cameraTransform.getChildren().add(light);
    light.setTranslateX(camera.getTranslateX());
    light.setTranslateY(camera.getTranslateY());
    light.setTranslateZ(camera.getTranslateZ());
            
    root.getChildren().add(cameraTransform);
    subScene.setCamera(camera);
    
    initFirstPersonControls(subScene);
    
    skyBox = new Skybox(new Image("http://www.zfight.com/misc/images/textures/envmaps/violentdays_large.jpg"), 100000, camera);      
   
    //Make a bunch of semi random Torusesessses(toroids?) and stuff : from torustest
    Group torusGroup = new Group();        
    for (int i = 0; i < 10; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat() * 300) + 50);
        float randomTubeRadius = (float) ((r.nextFloat() * 100) + 1);
        int randomTubeDivisions = (int) ((r.nextFloat() * 64) + 1);
        int randomRadiusDivisions = (int) ((r.nextFloat() * 64) + 1);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        boolean ambientRandom = r.nextBoolean();
        boolean fillRandom = r.nextBoolean();
        
        if(i == 0){                
            torusGroup.getChildren().add(bill);
        }
        TorusMesh torus = new TorusMesh(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius);
        
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        torus.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        //torus.getTransforms().add(translate);
        torusGroup.getChildren().add(torus);
    }
    root.getChildren().addAll(skyBox, torusGroup);
    
    rootPane.getChildren().add(subScene);
    //Enable subScene resizing
    subScene.widthProperty().bind(rootPane.widthProperty());
    subScene.heightProperty().bind(rootPane.heightProperty());
    subScene.setFocusTraversable(true);
    
}
 
Example 5
Source File: SpheroidTest.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    
    Group spheroidGroup = new Group();        
    for (int i = 0; i < 50; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomMajorRadius = (float) ((r.nextFloat() * 300) + 50);
        float randomMinorRadius = (float) ((r.nextFloat() * 300) + 50);
        int randomDivisions = (int) ((r.nextFloat() * 64) + 1);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Spheroid sm = new Spheroid(randomDivisions, randomMajorRadius, randomMinorRadius, randomColor);               
        sm.setDrawMode(DrawMode.LINE);
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        sm.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        spheroidGroup.getChildren().add(sm);
    }
    root.getChildren().add(spheroidGroup);
    
    System.out.println(spheroidGroup.getChildren().size());
    
    camera = new PerspectiveCamera(true);
    cameraTransform.setTranslate(0, 0, 0);
    cameraTransform.getChildren().addAll(camera);
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setTranslateZ(cameraDistance);
    cameraTransform.ry.setAngle(-45.0);
    cameraTransform.rx.setAngle(-10.0);
    //add a Point Light for better viewing of the grid coordinate system
    PointLight light = new PointLight(Color.WHITE);
    
    cameraTransform.getChildren().add(light);
    light.setTranslateX(camera.getTranslateX());
    light.setTranslateY(camera.getTranslateY());
    light.setTranslateZ(camera.getTranslateZ());
    root.getChildren().add(cameraTransform);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    initFirstPersonControls(scene);
    
    stage.setTitle("Hello World!");
    stage.setScene(scene);
    stage.show();
}