本文整理匯總了Java中javafx.scene.PerspectiveCamera.setFarClip方法的典型用法代碼示例。如果您正苦於以下問題:Java PerspectiveCamera.setFarClip方法的具體用法?Java PerspectiveCamera.setFarClip怎麽用?Java PerspectiveCamera.setFarClip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.PerspectiveCamera
的用法示例。
在下文中一共展示了PerspectiveCamera.setFarClip方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
private void loadCamera(Scene scene) {
//initialize camera
camera = new PerspectiveCamera(true);
camera.setVerticalFieldOfView(RUN_JASON);
//setup camera transform for rotational support
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().add(camera);
camera.setNearClip(0.1);
camera.setFarClip(100000.0);
camera.setTranslateZ(-5000);
cameraTransform.ry.setAngle(0.0);
cameraTransform.rx.setAngle(-45.0);
//add a Point Light for better viewing of the grid coordinate system
PointLight light = new PointLight(Color.GAINSBORO);
cameraTransform.getChildren().add(light);
cameraTransform.getChildren().add(new AmbientLight(Color.WHITE));
light.setTranslateX(camera.getTranslateX());
light.setTranslateY(camera.getTranslateY());
light.setTranslateZ(camera.getTranslateZ());
//attach camera to scene
scene.setCamera(camera);
}
示例2: createDefaultCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
/**
* <p>
* Creates the current geometry editor camera.
* </p>
*
* @param parent
* the parent to create the camera on
*
*/
protected void createDefaultCamera(Group parent) {
PerspectiveCamera perspCamera = new PerspectiveCamera(true);
perspCamera.setNearClip(0.1);
perspCamera.setFarClip(4000.0);
perspCamera.setFieldOfView(35);
perspCamera.setTranslateX(0);
perspCamera.setTranslateY(0);
parent.getChildren().add(perspCamera);
// Hacked in camera (for now)
FXCameraAttachment cameraAttachment = new FXCameraAttachment(
perspCamera);
setCamera(cameraAttachment);
}
示例3: loadCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
private void loadCamera(Scene scene) {
//initialize camera
camera = new PerspectiveCamera(true);
camera.setVerticalFieldOfView(RUN_JASON);
//setup camera transform for rotational support
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().add(camera);
camera.setNearClip(0.1);
camera.setFarClip(100000.0);
camera.setTranslateZ(-5000);
cameraTransform.ry.setAngle(0.0);
cameraTransform.rx.setAngle(-45.0);
//add a Point Light for better viewing of the grid coordinate system
PointLight light = new PointLight(Color.GAINSBORO);
cameraTransform.getChildren().add(light);
cameraTransform.getChildren().add(new AmbientLight(Color.WHITE));
light.setTranslateX(camera.getTranslateX());
light.setTranslateY(camera.getTranslateY());
light.setTranslateZ(camera.getTranslateZ());
//attach camera to scene
scene.setCamera(camera);
}
示例4: addCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
protected Camera addCamera(SubScene scene) {
PerspectiveCamera pc = new PerspectiveCamera(true);
scene.setCamera(pc);
pc.setFarClip(10000);
return pc;
}
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:8,代碼來源:SubScenePerspectiveCameraFixedEyeIsolateTestApp.java
示例5: createContent
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
public Parent createContent() {
BorderPane p = new BorderPane();
HBox btBox = new HBox(50, leftBt, lookLeftBt, forwardBt, upBt, downBt, backBt, lookRightBt, rightBt);
btBox.alignmentProperty().set(Pos.CENTER);
p.setBottom(btBox);
setUpButtons();
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.getTransforms().add(cameraTranslate);
camera.getTransforms().add(cameraRotate);
camera.setFieldOfView(50);
camera.setFarClip(10000);
camera.setNearClip(1);
p.setDepthTest(DepthTest.ENABLE);
BorderPane cirmLiveUI = cirmLive.createSceneContent();
cirmLiveUI.setCache(true);
cirmLiveUI.setCacheShape(true);
cirmLiveUI.setCacheHint(CacheHint.QUALITY);
//cirmLiveUI.setSsetAlignment(camera, Pos.CENTER);
//cirmLiveUI.setTranslateZ(500);
//TODO root.getChildren().addAll(c, c2, c3);
SubScene subScene = new SubScene(cirmLiveUI, 1600, 900, true, SceneAntialiasing.BALANCED);
subScene.setFill(Color.CORAL);
subScene.setCamera(camera);
p.setCenter(subScene);
return p;
}
示例6: buildCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
private void buildCamera(Group root, PerspectiveCamera camera) {
root.getChildren().add(cameraXform);
cameraXform.getChildren().add(cameraXform2);
cameraXform2.getChildren().add(cameraXform3);
cameraXform3.getChildren().add(camera);
camera.setNearClip(CAMERA_NEAR_CLIP);
camera.setFarClip(CAMERA_FAR_CLIP);
cameraXform.ry.setAngle(CAMERA_INITIAL_Y_ANGLE);
cameraXform.rx.setAngle(CAMERA_INITIAL_X_ANGLE);
}
示例7: start
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
camera = new PerspectiveCamera(true);
// setup camera transform for rotational support
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setTranslateZ(-20);
makeYUp(camera);
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().add(camera);
// cameraTransform.ry.setAngle(-45.0);
// cameraTransform.rx.setAngle(-10.0);
// add a Point Light for better viewing of the grid coordinate system
PointLight point = new PointLight(Color.LIGHTSTEELBLUE);
AmbientLight ambient = new AmbientLight(Color.LIGHTSKYBLUE);
cameraTransform.getChildren().addAll(point, ambient);
point.setTranslateX(camera.getTranslateX());
point.setTranslateY(camera.getTranslateY());
point.setTranslateZ(camera.getTranslateZ());
Group group = new Group(cameraTransform);
Group sceneRoot = new Group(group);
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
this.pointLight = point;
this.ambientLight = ambient;
configSceneColor(scene, point, ambient, cameraTransform);
scene.setCamera(camera);
makeObjects(group);
setActions(scene);
lastEffect = System.nanoTime();
AnimationTimer timerEffect = makeAnimation();
stage.setScene(scene);
stage.show();
timerEffect.start();
}
示例8: buildCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
protected Camera buildCamera() {
PerspectiveCamera cam = new PerspectiveCamera(true);
cam.setFarClip(SCALE * 30);
return cam;
}
示例9: buildCamera
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
protected Camera buildCamera() {
PerspectiveCamera cam = new PerspectiveCamera(true);
cam.setFarClip(SCALE * 25);
return cam;
}
示例10: start
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
Group sceneRoot = new Group();
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
camera = new PerspectiveCamera(true);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setTranslateZ(-1000);
scene.setCamera(camera);
scatterPlot = new ScatterPlot(1000, 1, true);
sceneRoot.getChildren().addAll(scatterPlot);
ArrayList<Double> dataX = new ArrayList<>();
ArrayList<Double> dataY = new ArrayList<>();
ArrayList<Double> dataZ = new ArrayList<>();
for(int i=-250;i<250;i++) {
dataX.add(new Double(i));
dataY.add(new Double(Math.sin(i)*50)+i);
dataZ.add(new Double(Math.cos(i)*50)+i);
}
scatterPlot.setXYZData(dataX, dataY, dataZ);
scene.setOnKeyPressed(event -> {
double change = 10.0;
//Add shift modifier to simulate "Running Speed"
if(event.isShiftDown()) { change = 50.0; }
//What key did the user press?
KeyCode keycode = event.getCode();
//Step 2c: Add Zoom controls
if(keycode == KeyCode.W) { camera.setTranslateZ(camera.getTranslateZ() + change); }
if(keycode == KeyCode.S) { camera.setTranslateZ(camera.getTranslateZ() - change); }
//Step 2d: Add Strafe controls
if(keycode == KeyCode.A) { camera.setTranslateX(camera.getTranslateX() - change); }
if(keycode == KeyCode.D) { camera.setTranslateX(camera.getTranslateX() + change); }
});
//Add a Mouse Handler for Rotations
Rotate xRotate = new Rotate(0, Rotate.X_AXIS);
Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);
Rotate zRotate = new Rotate(0, Rotate.Z_AXIS);
scatterPlot.getTransforms().addAll(xRotate, yRotate);
//Use Binding so your rotation doesn't have to be recreated
xRotate.angleProperty().bind(angleX);
yRotate.angleProperty().bind(angleY);
zRotate.angleProperty().bind(angleZ);
//Start Tracking mouse movements only when a button is pressed
scene.setOnMousePressed(event -> {
scenex = event.getSceneX();
sceney = event.getSceneY();
fixedXAngle = angleX.get();
fixedYAngle = angleY.get();
if(event.isMiddleButtonDown()) {
scenez = event.getSceneX();
fixedZAngle = angleZ.get();
}
});
//Angle calculation will only change when the button has been pressed
scene.setOnMouseDragged(event -> {
if(event.isMiddleButtonDown())
angleZ.set(fixedZAngle - (scenez - event.getSceneY()));
else
angleX.set(fixedXAngle - (scenex - event.getSceneY()));
angleY.set(fixedYAngle + sceney - event.getSceneX());
});
primaryStage.setTitle("F(X)yz ScatterPlotTest");
primaryStage.setScene(scene);
primaryStage.show();
}
示例11: start
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
Group sceneRoot = new Group();
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
camera = new PerspectiveCamera(true);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setTranslateZ(-1000);
scene.setCamera(camera);
ArrayList<Point3D> points = new ArrayList<>();
for(int i=-250;i<250;i++) {
points.add(new Point3D(
(float) i,
(float) Math.sin(i)*50+i,
(float) Math.cos(i)*50+i));
}
polyLine3D = new PolyLine3D(points,3,Color.STEELBLUE);
sceneRoot.getChildren().addAll(polyLine3D);
scene.setOnKeyPressed(event -> {
double change = 10.0;
//Add shift modifier to simulate "Running Speed"
if(event.isShiftDown()) { change = 50.0; }
//What key did the user press?
KeyCode keycode = event.getCode();
//Step 2c: Add Zoom controls
if(keycode == KeyCode.W) { camera.setTranslateZ(camera.getTranslateZ() + change); }
if(keycode == KeyCode.S) { camera.setTranslateZ(camera.getTranslateZ() - change); }
//Step 2d: Add Strafe controls
if(keycode == KeyCode.A) { camera.setTranslateX(camera.getTranslateX() - change); }
if(keycode == KeyCode.D) { camera.setTranslateX(camera.getTranslateX() + change); }
});
//Add a Mouse Handler for Rotations
Rotate xRotate = new Rotate(0, Rotate.X_AXIS);
Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);
Rotate zRotate = new Rotate(0, Rotate.Z_AXIS);
polyLine3D.getTransforms().addAll(xRotate, yRotate);
//Use Binding so your rotation doesn't have to be recreated
xRotate.angleProperty().bind(angleX);
yRotate.angleProperty().bind(angleY);
zRotate.angleProperty().bind(angleZ);
//Start Tracking mouse movements only when a button is pressed
scene.setOnMousePressed(event -> {
scenex = event.getSceneX();
sceney = event.getSceneY();
fixedXAngle = angleX.get();
fixedYAngle = angleY.get();
if(event.isMiddleButtonDown()) {
scenez = event.getSceneX();
fixedZAngle = angleZ.get();
}
});
//Angle calculation will only change when the button has been pressed
scene.setOnMouseDragged(event -> {
if(event.isMiddleButtonDown())
angleZ.set(fixedZAngle - (scenez - event.getSceneY()));
else
angleX.set(fixedXAngle - (scenex - event.getSceneY()));
angleY.set(fixedYAngle + sceney - event.getSceneX());
});
primaryStage.setTitle("F(X)yz ScatterPlotTest");
primaryStage.setScene(scene);
primaryStage.show();
}
示例12: createSubscene
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
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);
}
示例13: start
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@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();
}
示例14: start
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
Group sceneRoot = new Group();
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
camera = new PerspectiveCamera(true);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setTranslateZ(-1000);
scene.setCamera(camera);
scatterPlotMesh = new ScatterPlotMesh(1000, 1, true);
sceneRoot.getChildren().addAll(scatterPlotMesh);
ArrayList<Double> dataX = new ArrayList<>();
ArrayList<Double> dataY = new ArrayList<>();
ArrayList<Double> dataZ = new ArrayList<>();
for(int i=-250;i<250;i++) {
dataX.add(new Double(i));
dataY.add(new Double(Math.sin(i)*50)+i);
dataZ.add(new Double(Math.cos(i)*50)+i);
}
scatterPlotMesh.setXYZData(dataX, dataY, dataZ);
scene.setOnKeyPressed(event -> {
double change = 10.0;
//Add shift modifier to simulate "Running Speed"
if(event.isShiftDown()) { change = 50.0; }
//What key did the user press?
KeyCode keycode = event.getCode();
//Step 2c: Add Zoom controls
if(keycode == KeyCode.W) { camera.setTranslateZ(camera.getTranslateZ() + change); }
if(keycode == KeyCode.S) { camera.setTranslateZ(camera.getTranslateZ() - change); }
//Step 2d: Add Strafe controls
if(keycode == KeyCode.A) { camera.setTranslateX(camera.getTranslateX() - change); }
if(keycode == KeyCode.D) { camera.setTranslateX(camera.getTranslateX() + change); }
});
//Add a Mouse Handler for Rotations
Rotate xRotate = new Rotate(0, Rotate.X_AXIS);
Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);
Rotate zRotate = new Rotate(0, Rotate.Z_AXIS);
scatterPlotMesh.getTransforms().addAll(xRotate, yRotate);
//Use Binding so your rotation doesn't have to be recreated
xRotate.angleProperty().bind(angleX);
yRotate.angleProperty().bind(angleY);
zRotate.angleProperty().bind(angleZ);
//Start Tracking mouse movements only when a button is pressed
scene.setOnMousePressed(event -> {
scenex = event.getSceneX();
sceney = event.getSceneY();
fixedXAngle = angleX.get();
fixedYAngle = angleY.get();
if(event.isMiddleButtonDown()) {
scenez = event.getSceneX();
fixedZAngle = angleZ.get();
}
});
//Angle calculation will only change when the button has been pressed
scene.setOnMouseDragged(event -> {
if(event.isMiddleButtonDown())
angleZ.set(fixedZAngle - (scenez - event.getSceneY()));
else
angleX.set(fixedXAngle - (scenex - event.getSceneY()));
angleY.set(fixedYAngle + sceney - event.getSceneX());
});
primaryStage.setTitle("F(X)yz ScatterPlotTest");
primaryStage.setScene(scene);
primaryStage.show();
}
示例15: start
import javafx.scene.PerspectiveCamera; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
Group sceneRoot = new Group();
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
camera = new PerspectiveCamera(true);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setTranslateZ(-1000);
scene.setCamera(camera);
scatterPlot = new ScatterPlot(1000, 1, true);
sceneRoot.getChildren().addAll(scatterPlot);
List<Double> dataX = new ArrayList<>();
List<Double> dataY = new ArrayList<>();
List<Double> dataZ = new ArrayList<>();
List<Color> colors = new ArrayList<>();
int k = 0;
for(int i=-250;i<250;i++) {
dataX.add(new Double(i));
dataY.add(Math.sin(i)*50+i);
dataZ.add(Math.cos(i)*50+i);
colors.add(new Color(Math.abs(i) / 250D, Math.abs(dataY.get(k)) / 300D, Math.abs(dataZ.get(k) / 300D), 0.25));
k++;
}
scatterPlot.setXYZData(dataX, dataY, dataZ, colors);
scene.setOnKeyPressed(event -> {
double change = 10.0;
//Add shift modifier to simulate "Running Speed"
if(event.isShiftDown()) { change = 50.0; }
//What key did the user press?
KeyCode keycode = event.getCode();
//Step 2c: Add Zoom controls
if(keycode == KeyCode.W) { camera.setTranslateZ(camera.getTranslateZ() + change); }
if(keycode == KeyCode.S) { camera.setTranslateZ(camera.getTranslateZ() - change); }
//Step 2d: Add Strafe controls
if(keycode == KeyCode.A) { camera.setTranslateX(camera.getTranslateX() - change); }
if(keycode == KeyCode.D) { camera.setTranslateX(camera.getTranslateX() + change); }
});
//Add a Mouse Handler for Rotations
Rotate xRotate = new Rotate(0, Rotate.X_AXIS);
Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);
Rotate zRotate = new Rotate(0, Rotate.Z_AXIS);
scatterPlot.getTransforms().addAll(xRotate, yRotate);
//Use Binding so your rotation doesn't have to be recreated
xRotate.angleProperty().bind(angleX);
yRotate.angleProperty().bind(angleY);
zRotate.angleProperty().bind(angleZ);
//Start Tracking mouse movements only when a button is pressed
scene.setOnMousePressed(event -> {
scenex = event.getSceneX();
sceney = event.getSceneY();
fixedXAngle = angleX.get();
fixedYAngle = angleY.get();
if(event.isMiddleButtonDown()) {
scenez = event.getSceneX();
fixedZAngle = angleZ.get();
}
});
//Angle calculation will only change when the button has been pressed
scene.setOnMouseDragged(event -> {
if(event.isMiddleButtonDown())
angleZ.set(fixedZAngle - (scenez - event.getSceneY()));
else
angleX.set(fixedXAngle - (scenex - event.getSceneY()));
angleY.set(fixedYAngle + sceney - event.getSceneX());
});
primaryStage.setTitle("F(X)yz ScatterPlotColorTest");
primaryStage.setScene(scene);
primaryStage.show();
}