/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. */ //package zbuffertest; import javafx.application.Application; import javafx.application.ConditionalFeature; import javafx.application.Platform; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Rectangle; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.transform.Rotate; import javafx.scene.transform.Translate; import javafx.stage.Stage; /** * @author cyang */ public class LineWithDepth extends Application { @Override public void start(Stage stage) { stage.setTitle("Z-Buffer Test On Line"); Scene scene = new Scene(new Group(), WIDTH, HEIGHT, true); scene.setFill(Color.GRAY); scene.setCamera(new PerspectiveCamera()); Group sceneContent = new Group(); VBox vbox = new VBox(); vbox.setTranslateX(10.0F); vbox.setSpacing(5.0F); Text draw = new Text(); draw.setFont(new Font(12)); draw.setFill(Color.LIGHTGRAY); draw.setText("[Draw order (back to front): RED LINE, GREEN, BLUE]"); Text order = new Text(); order.setFont(new Font(16)); order.setFill(Color.YELLOW); order.setText("Z order (back to front): BLUE, RED LINE, GREEN"); Group group = new Group(); Rotate rotate = new Rotate(); rotate.setAxis(Rotate.Y_AXIS); rotate.setAngle(0); Translate translate = new Translate(0, 0, 0); Line redLine = new Line(30, 60, 150, 150); redLine.setStroke(Color.RED); redLine.setStrokeWidth(10); redLine.setTranslateZ(2); Rectangle green = new Rectangle(50, 20, 100, 100); green.setFill(Color.GREEN); green.setTranslateZ(1); Rectangle blue = new Rectangle(20, 50, 100, 100); blue.setFill(Color.BLUE); blue.setTranslateZ(3); group.getChildren().addAll(redLine, green, blue); group.getTransforms().addAll(translate, rotate); vbox.getChildren().addAll(draw, order, group); sceneContent.getChildren().addAll(vbox); ((Group)scene.getRoot()).getChildren().addAll(sceneContent); stage.setScene(scene); if (!Platform.isSupported(ConditionalFeature.SCENE3D)) { System.out.println("*************************************************************"); System.out.println("* WARNING: common conditional SCENE3D isn\'t supported *"); System.out.println("*************************************************************"); } stage.show(); } public static void main(String[] args) { Application.launch(args); } private static float WIDTH = 400.0F; private static float HEIGHT = 300.0F; }