Commit 26323df8 authored by Louis  Jimenez-Hernandez's avatar Louis Jimenez-Hernandez
Browse files

Shapes spawn in center

parent d946ad03
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import javafx.stage.Stage;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import static java.lang.Math.*;

@@ -141,7 +142,11 @@ public class GraphicsAndWindowsTest extends Application {
        group3D.getChildren().add(floor);
        obs.addToGroup(group3D);
        for (MovingObject o : objects ) {
            o.setTranslate(sceneWindow.getXOffset(), sceneWindow.getYOffset(),0);
            Bounds boundsO = o.getMesh().getBoundsInParent();
            double centerX = ((double) sceneWindow.getWindowSize() /2) - (boundsO.getMinX() + boundsO.getMaxX()) / 2;
            double centerY = ((double) sceneWindow.getWindowSize() /2) - (boundsO.getMinY() + boundsO.getMaxY()) / 2;
            double centerZ = ((double) sceneWindow.getWindowSize() /2) - (boundsO.getMinZ() + boundsO.getMaxZ()) / 2 ;
            o.setTranslate(sceneWindow.getXOffset() + centerX, sceneWindow.getYOffset() + centerY,centerZ);
            group3D.getChildren().add(o.getMesh());
        }

@@ -459,7 +464,15 @@ public class GraphicsAndWindowsTest extends Application {
                                    break;

                                case "TOP":
                                    //y = direction[i][1] + (obBounds.getMaxY() - (meshBounds[i].getMinY() - y));
                                    //y = direction[i][1] + (winTopYBound - (meshBounds[i].getMinY() + y) Reference from above
                                    //y = direction[i][1] + (obBounds.getMaxY() - (meshBounds[i].getMinY() + y));
//                                    Random rand = new Random();
//                                    double randomValue = -1 + 2 * rand.nextDouble();
//                                    direction[i][1] += 1;
//                                    direction[i][0] += randomValue;

                                    //direction[i][1] = abs(direction[i][1]) + 1; BEST ALTERNATIVE SO FAR

                                    direction[i][1] = abs(direction[i][1]);
                                    break;