Loading src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +57 −9 Original line number Diff line number Diff line Loading @@ -199,22 +199,70 @@ public class GraphicsAndWindowsTest extends Application { double maxZ = meshBounds.getMaxZ() + directionZ; //Number is roughly 1 mill divided by 60 if (now - lastUpdate >= 16_000_000) { // Roughly 60 frames per second double newY = translate.getY() + directionY; translate.setY(newY); double newX = translate.getX() + directionX; translate.setX(newX); double newZ = translate.getZ() + directionZ; translate.setZ(newZ); double cubeMin = 300, cubeMax = 600; // Reverse direction at bounds if (minX < cubeMin+300 || maxX > cubeMax+300) directionX *= -1; if (minY < cubeMin || maxY > cubeMax) directionY *= -1; if (minZ < cubeMin-300 || maxZ > cubeMax-300) directionZ *= -1; if (minX < cubeMin+300 || maxX > cubeMax+300) { // load the vertices of the mesh float[] points = mesh.getPoints().toArray(null); // find the vertices which come close to the bounding box threshold and squish them into the mesh for (int j = 0; j < points.length; j += 3) { if (Math.abs(points[j] + translate.getX() + directionX - minX) < 10 || Math.abs(points[j] + translate.getX() + directionX - maxX) < 10) { points[j] += -directionX*5; } } //update the direction of the mesh and set the new coordinates directionX *= -1; mesh.getPoints().setAll(points); } if (minY < cubeMin || maxY > cubeMax) { // load the vertices of the mesh float[] points = mesh.getPoints().toArray(null); // find the vertices which come close to the bounding box threshold and squish them into the mesh for (int j = 1; j < points.length; j += 3) { if (Math.abs(points[j] + translate.getY() + directionY - minY) < 10 || Math.abs(points[j] + translate.getY() + directionY - maxY) < 10) { points[j] += -directionY*5; } } //update the direction of the mesh and set the new coordinates directionY *= -1; mesh.getPoints().setAll(points); } if (minZ < cubeMin-300 || maxZ > cubeMax-300) { // load the vertices of the mesh float[] points = mesh.getPoints().toArray(null); // find the vertices which come close to the bounding box threshold and squish them into the mesh for (int j = 2; j < points.length; j += 3) { if (Math.abs(points[j] + translate.getZ() + directionZ - minZ) < 10 || Math.abs(points[j] + translate.getZ() + directionZ - maxZ) < 10) { points[j] += -directionZ*5; } } //update the direction of the mesh and set the new coordinates directionZ *= -1; mesh.getPoints().setAll(points); } // if (newZ < 0 || newZ >300) { // directionZ = -directionZ; // } double newY = translate.getY() + directionY; translate.setY(newY); double newX = translate.getX() + directionX; translate.setX(newX); double newZ = translate.getZ() + directionZ; translate.setZ(newZ); lastUpdate = now; } if (fpsTimer == 0) { Loading Loading
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +57 −9 Original line number Diff line number Diff line Loading @@ -199,22 +199,70 @@ public class GraphicsAndWindowsTest extends Application { double maxZ = meshBounds.getMaxZ() + directionZ; //Number is roughly 1 mill divided by 60 if (now - lastUpdate >= 16_000_000) { // Roughly 60 frames per second double newY = translate.getY() + directionY; translate.setY(newY); double newX = translate.getX() + directionX; translate.setX(newX); double newZ = translate.getZ() + directionZ; translate.setZ(newZ); double cubeMin = 300, cubeMax = 600; // Reverse direction at bounds if (minX < cubeMin+300 || maxX > cubeMax+300) directionX *= -1; if (minY < cubeMin || maxY > cubeMax) directionY *= -1; if (minZ < cubeMin-300 || maxZ > cubeMax-300) directionZ *= -1; if (minX < cubeMin+300 || maxX > cubeMax+300) { // load the vertices of the mesh float[] points = mesh.getPoints().toArray(null); // find the vertices which come close to the bounding box threshold and squish them into the mesh for (int j = 0; j < points.length; j += 3) { if (Math.abs(points[j] + translate.getX() + directionX - minX) < 10 || Math.abs(points[j] + translate.getX() + directionX - maxX) < 10) { points[j] += -directionX*5; } } //update the direction of the mesh and set the new coordinates directionX *= -1; mesh.getPoints().setAll(points); } if (minY < cubeMin || maxY > cubeMax) { // load the vertices of the mesh float[] points = mesh.getPoints().toArray(null); // find the vertices which come close to the bounding box threshold and squish them into the mesh for (int j = 1; j < points.length; j += 3) { if (Math.abs(points[j] + translate.getY() + directionY - minY) < 10 || Math.abs(points[j] + translate.getY() + directionY - maxY) < 10) { points[j] += -directionY*5; } } //update the direction of the mesh and set the new coordinates directionY *= -1; mesh.getPoints().setAll(points); } if (minZ < cubeMin-300 || maxZ > cubeMax-300) { // load the vertices of the mesh float[] points = mesh.getPoints().toArray(null); // find the vertices which come close to the bounding box threshold and squish them into the mesh for (int j = 2; j < points.length; j += 3) { if (Math.abs(points[j] + translate.getZ() + directionZ - minZ) < 10 || Math.abs(points[j] + translate.getZ() + directionZ - maxZ) < 10) { points[j] += -directionZ*5; } } //update the direction of the mesh and set the new coordinates directionZ *= -1; mesh.getPoints().setAll(points); } // if (newZ < 0 || newZ >300) { // directionZ = -directionZ; // } double newY = translate.getY() + directionY; translate.setY(newY); double newX = translate.getX() + directionX; translate.setX(newX); double newZ = translate.getZ() + directionZ; translate.setZ(newZ); lastUpdate = now; } if (fpsTimer == 0) { Loading