pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2); minsPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius()); pointerGroup.getTransforms().add(minsPointerRotate);
hoursPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius()); pointerRotate.set(hoursPointerRotate); pointerGroup.getTransforms().add(hoursPointerRotate); pointerGroup.setVisible(!is24HourView); _24HourHoursPointerRotate = new Rotate(0, contentCircleRadius - shift - _24HourShift, selectionCircle.getRadius()); _24HourPointerRotate.set(_24HourHoursPointerRotate); pointer24HourGroup.getTransforms().add(_24HourHoursPointerRotate); pointer24HourGroup.setVisible(is24HourView);
@Override protected void doScaleInstruction(Graphics3DScaleInstruction graphics3DScale) { Vector3D scale = graphics3DScale.getScaleFactor(); Scale outputScale = new Scale(scale.getX(), scale.getY(), scale.getZ()); Group scaleGroup = new Group(); scaleGroup.getTransforms().add(outputScale); currentGroup.getChildren().add(scaleGroup); currentGroup = scaleGroup; }
@Override protected void doTranslateInstruction(Graphics3DTranslateInstruction graphics3DTranslate) { Vector3D t = graphics3DTranslate.getTranslation(); Translate outputTranslation = new Translate(t.getX(), t.getY(), t.getZ()); Group translationGroup = new Group(); translationGroup.getTransforms().add(outputTranslation); currentGroup.getChildren().add(translationGroup); currentGroup = translationGroup; }
/** Initialize the pane content. * * @param content the content. */ protected void initializePane(Node content) { final Group contentGroup = new Group(); this.zoomGroup = new Group(); contentGroup.getChildren().add(this.zoomGroup); this.zoomGroup.getChildren().add(content); setContent(contentGroup); this.scaleTransform = new Scale(this.scaleValue, this.scaleValue, 0, 0); this.zoomGroup.getTransforms().add(this.scaleTransform); this.zoomGroup.setOnScroll(new ZoomHandler()); setContent(contentGroup); setFitToWidth(true); setFitToHeight(true); }
@Override protected void doRotateInstruction(Graphics3DRotateInstruction rot) { RotationMatrix mat = rot.getRotationMatrix(); Affine outputRotation = new Affine(new double[] {mat.getM00(), mat.getM01(), mat.getM02(), 0, mat.getM10(), mat.getM11(), mat.getM12(), 0, mat.getM20(), mat.getM21(), mat.getM22(), 0, 0, 0, 0, 1}, MatrixType.MT_3D_4x4, 0); Group rotationGroup = new Group(); rotationGroup.getTransforms().add(outputRotation); currentGroup.getChildren().add(rotationGroup); currentGroup = rotationGroup; }
/** * Create a new 3d viewer */ public Viewer3d() { this.contentGroup = new Group(); this.contentGroup.getTransforms().add(this.contentScale); Group root = new Group(this.contentGroup); this.scene = new SubScene(root, -1, -1, true, SceneAntialiasing.BALANCED); this.scene.setManaged(false); this.camera = setupCamera(); this.scene.setCamera(this.camera); root.getChildren().add(this.camera); this.scene.widthProperty().addListener((o) -> updateSize()); this.scene.heightProperty().addListener((o) -> updateSize()); getChildren().add(this.scene); addEventHandler(MouseEvent.MOUSE_PRESSED, this::cameraRotationHandler); addEventHandler(MouseEvent.MOUSE_DRAGGED, this::cameraRotationHandler); addEventHandler(ScrollEvent.SCROLL, this::zoomHandler); contentProperty().addListener(this::contentHandler); contentRotateProperty().addListener(this::animationHandler); }
/** * Create a new 3d viewer */ public Viewer3d() { this.contentGroup = new Group(); this.contentGroup.getTransforms().add(this.contentScale); Group root = new Group(this.contentGroup); this.scene = new SubScene(root, -1, -1, true, SceneAntialiasing.BALANCED); this.scene.setManaged(false); this.camera = setupCamera(); this.scene.setCamera(this.camera); root.getChildren().add(this.camera); this.scene.widthProperty().addListener((o) -> updateSize()); this.scene.heightProperty().addListener((o) -> updateSize()); getChildren().add(this.scene); addEventHandler(MouseEvent.MOUSE_PRESSED, this::cameraRotationHandler); addEventHandler(MouseEvent.MOUSE_DRAGGED, this::cameraRotationHandler); addEventHandler(ScrollEvent.SCROLL, this::zoomHandler); contentProperty().addListener(this::contentHandler); contentRotateProperty().addListener(this::animationHandler); }
private void initViewport(double w, double h) { Viewport viewport = getViewport(); gameRoot.layoutXProperty().bind(viewport.xProperty().negate()); gameRoot.layoutYProperty().bind(viewport.yProperty().negate()); Scale scale = new Scale(); scale.pivotXProperty().bind(viewport.xProperty()); scale.pivotYProperty().bind(viewport.yProperty()); scale.xProperty().bind(viewport.zoomProperty()); scale.yProperty().bind(viewport.zoomProperty()); gameRoot.getTransforms().add(scale); Rotate rotate = new Rotate(0, Rotate.Z_AXIS); rotate.pivotXProperty().bind(viewport.xProperty().add(w / 2)); rotate.pivotYProperty().bind(viewport.yProperty().add(h / 2)); rotate.angleProperty().bind(viewport.angleProperty().negate()); gameRoot.getTransforms().add(rotate); }
pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2); minsPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius()); pointerGroup.getTransforms().add(minsPointerRotate);
hoursPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius()); pointerRotate.set(hoursPointerRotate); pointerGroup.getTransforms().add(hoursPointerRotate); pointerGroup.setVisible(!is24HourView); _24HourHoursPointerRotate = new Rotate(0, contentCircleRadius - shift - _24HourShift, selectionCircle.getRadius()); _24HourPointerRotate.set(_24HourHoursPointerRotate); pointer24HourGroup.getTransforms().add(_24HourHoursPointerRotate); pointer24HourGroup.setVisible(is24HourView);
Group axisGroup = createAxis(15.0); PmRpy rpy = tp.getRpy(); axisGroup.getTransforms().addAll(new Translate(tp.x * getDistScale(), tp.y * getDistScale(), tp.z * getDistScale()), new Rotate(Math.toDegrees(rpy.y), Rotate.Z_AXIS), new Rotate(Math.toDegrees(rpy.p), Rotate.Y_AXIS), new Rotate(Math.toDegrees(rpy.r), Rotate.X_AXIS)); trackGroup.getChildren().addAll(axisGroup);
/** * Create a 3D Scene * * @param w the value of w * @param h the value of h * @return new Scene */ public Scene create3DScene(int w, int h) { Group root = new Group(); root.setDepthTest(DepthTest.ENABLE); Scene scene3D = new Scene(root, w, h, true); camera = new PerspectiveCamera(); scene3D.setCamera(camera); getCenterWinTranslate().setX(w / 3); getCenterWinTranslate().setY((2 * h) / 3); root.getTransforms().addAll(getCenterWinTranslate(), new Rotate(180, Rotate.X_AXIS)); setContentGroup(this.create3dContent()); root.getChildren().addAll(getContentGroup()); scene3D.setOnMouseDragged(this::handleFxRootMouseEvent); scene3D.setOnMouseReleased(this::handlePanelMouseReleasExitedEvent); scene3D.setOnMouseExited(this::handlePanelMouseReleasExitedEvent); scene3D.setOnKeyPressed(this::handleKeyEvent); scene3D.setOnKeyTyped(this::handleKeyEvent); Platform.runLater(() -> { xNegView(); }); return scene3D; }
public void setupSubscene(SubScene scene3D, double w, double h) { Parent p = scene3D.getRoot(); boolean pIsGroup = p instanceof Group; // System.out.println("scene3D.getRoot() = " + scene3D.getRoot()); // System.out.println("scene3D.getParent() = " + scene3D.getParent()); // System.out.println("pIsGroup = " + pIsGroup); Group root = pIsGroup ? (Group) p : new Group(); root.setDepthTest(DepthTest.ENABLE); camera = new PerspectiveCamera(); scene3D.setCamera(camera); scene3D.setRoot(root); getCenterWinTranslate().setX(w / 3); getCenterWinTranslate().setY((2 * h) / 3); root.getTransforms().addAll(getCenterWinTranslate(), new Rotate(180, Rotate.X_AXIS)); setContentGroup(this.create3dContent()); root.getChildren().addAll(getContentGroup()); // scene3D.heightProperty().bind(scene3D.getParent()); // scene3D.setManaged(false); scene3D.setOnMouseDragged(this::handleFxRootMouseEvent); scene3D.setOnMouseReleased(this::handlePanelMouseReleasExitedEvent); scene3D.setOnMouseExited(this::handlePanelMouseReleasExitedEvent); scene3D.setOnKeyPressed(this::handleKeyEvent); scene3D.setOnKeyTyped(this::handleKeyEvent); Platform.runLater(() -> { xNegView(); }); }