package Shape; import javafx.geometry.Bounds; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Box; import javafx.scene.shape.Cylinder; import javafx.scene.shape.Sphere; import java.util.ArrayList; import java.util.HashSet; import java.util.Random; import java.util.Set; public class Obstacle { public Obstacle(int WindowSize, double xTranslation, double yTranslation, double zTranslation, int obSize, String shape, Color color){ this.obSize = obSize/2; this.WindowSize = WindowSize; this.xTranslation = xTranslation + (double) obSize/2; this.yTranslation = yTranslation + (double) obSize/2; this.zTranslation = zTranslation + (double) obSize/2; this.shape = makeNode(shape, color); this.shape.setTranslateX(xTranslation); this.shape.setTranslateY(yTranslation); this.shape.setTranslateZ(zTranslation); shapeBound = this.shape.getBoundsInParent(); } public Node makeNode(String shape, Color color){ if(shape.equals("Box")){ Box b = new Box(obSize,obSize,obSize); b.setMaterial(new PhongMaterial(color)); return b; } else if (shape.equals("Sphere")){ Sphere s = new Sphere(obSize); s.setMaterial(new PhongMaterial(color)); return s; } else { Cylinder c = new Cylinder(obSize,obSize); c.setMaterial(new PhongMaterial(color)); return c; } } public Node getShape(){ return shape; } public void addToGroup(Group group){ group.getChildren().add(shape); } public boolean checkCollision(Bounds otherBounds) { return shapeBound.intersects(otherBounds); } int WindowSize = 0; double xTranslation, yTranslation, zTranslation; Node shape; Bounds shapeBound; int obSize = 10; }