Loading src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +16 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import Shape.Obstacle; import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.geometry.Pos; import javafx.scene.*; import javafx.scene.control.Label; Loading Loading @@ -44,8 +45,11 @@ public class GraphicsAndWindowsTest extends Application { */ @Override public void start(Stage stage) throws IOException { VisibleWindow sceneWindow = new VisibleWindow(500, 600, 200); double windowXOffset = 600; double windowYOffset = 200; VisibleWindow sceneWindow = new VisibleWindow(500, -250, -250); Box ourWindow = sceneWindow.makeWindow(); //Obstacle obs = new Obstacle(sceneWindow.getWindowSize(),sceneWindow.getXOffset(), sceneWindow.getYOffset(),10,100); String[] ob2 = {"--image", "src/teapot.txt", "--speed", "20", "--dir", "4,", "10,", "6"}; Loading Loading @@ -73,9 +77,13 @@ public class GraphicsAndWindowsTest extends Application { Group group3D = new Group(); // Group of our 3D elements for (MovingObject o : objects ) { o.setTranslate(sceneWindow.getXOffset(), sceneWindow.getYOffset(),0); //o.setTranslate(0, 0,0); group3D.getChildren().add(o.getMesh()); } group3D.setTranslateX(windowXOffset); group3D.setTranslateY(windowYOffset); group3D.setTranslateZ(250); group3D.getChildren().add(ourWindow); group3D.getChildren().add(new AmbientLight(Color.WHITE)); //obs.addToGroup(group3D); Loading @@ -87,14 +95,16 @@ public class GraphicsAndWindowsTest extends Application { Camera camera = new PerspectiveCamera(); camera.setNearClip(.1); camera.setFarClip(2000); camera.setTranslateX(0); camera.setTranslateY(0); camera.setTranslateZ(300); camera.setTranslateX(-125); camera.setTranslateY(-250); camera.setTranslateZ(-250); //https://stackoverflow.com/questions/65510979/move-camera-relative-to-view-in-javafx //Incorporated the code from this post Rotate groupRotX = new Rotate(0, Rotate.X_AXIS); Rotate groupRotY = new Rotate(0, Rotate.Y_AXIS); Point3D xAxis = new Point3D(1,0,0); Point3D yAxis = new Point3D(0,1,0); Rotate groupRotX = new Rotate(0, xAxis); Rotate groupRotY = new Rotate(0, yAxis); group3D.getTransforms().addAll(groupRotY, groupRotX); Loading target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class (3.12 KiB) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/GraphicsAndWindowsTest$2.class (830 B) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/GraphicsAndWindowsTest.class +237 B (6.28 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +16 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import Shape.Obstacle; import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.geometry.Pos; import javafx.scene.*; import javafx.scene.control.Label; Loading Loading @@ -44,8 +45,11 @@ public class GraphicsAndWindowsTest extends Application { */ @Override public void start(Stage stage) throws IOException { VisibleWindow sceneWindow = new VisibleWindow(500, 600, 200); double windowXOffset = 600; double windowYOffset = 200; VisibleWindow sceneWindow = new VisibleWindow(500, -250, -250); Box ourWindow = sceneWindow.makeWindow(); //Obstacle obs = new Obstacle(sceneWindow.getWindowSize(),sceneWindow.getXOffset(), sceneWindow.getYOffset(),10,100); String[] ob2 = {"--image", "src/teapot.txt", "--speed", "20", "--dir", "4,", "10,", "6"}; Loading Loading @@ -73,9 +77,13 @@ public class GraphicsAndWindowsTest extends Application { Group group3D = new Group(); // Group of our 3D elements for (MovingObject o : objects ) { o.setTranslate(sceneWindow.getXOffset(), sceneWindow.getYOffset(),0); //o.setTranslate(0, 0,0); group3D.getChildren().add(o.getMesh()); } group3D.setTranslateX(windowXOffset); group3D.setTranslateY(windowYOffset); group3D.setTranslateZ(250); group3D.getChildren().add(ourWindow); group3D.getChildren().add(new AmbientLight(Color.WHITE)); //obs.addToGroup(group3D); Loading @@ -87,14 +95,16 @@ public class GraphicsAndWindowsTest extends Application { Camera camera = new PerspectiveCamera(); camera.setNearClip(.1); camera.setFarClip(2000); camera.setTranslateX(0); camera.setTranslateY(0); camera.setTranslateZ(300); camera.setTranslateX(-125); camera.setTranslateY(-250); camera.setTranslateZ(-250); //https://stackoverflow.com/questions/65510979/move-camera-relative-to-view-in-javafx //Incorporated the code from this post Rotate groupRotX = new Rotate(0, Rotate.X_AXIS); Rotate groupRotY = new Rotate(0, Rotate.Y_AXIS); Point3D xAxis = new Point3D(1,0,0); Point3D yAxis = new Point3D(0,1,0); Rotate groupRotX = new Rotate(0, xAxis); Rotate groupRotY = new Rotate(0, yAxis); group3D.getTransforms().addAll(groupRotY, groupRotX); Loading
target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class (3.12 KiB) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/GraphicsAndWindowsTest$2.class (830 B) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/GraphicsAndWindowsTest.class +237 B (6.28 KiB) File changed.No diff preview for this file type. View original file View changed file