Loading .idea/misc.xml +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ </option> <option name="workspaceImportForciblyTurnedOn" value="true" /> </component> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="22" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="22" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> </project> No newline at end of file src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +27 −1 Original line number Diff line number Diff line Loading @@ -158,6 +158,8 @@ public class GraphicsAndWindowsTest extends Application { private long fpsTimer = 0; //Frame timer private long frameRate = 0; //Frames per second /** * Called at every frame while the {@link AnimationTimer} is active to update the scene's elements, * including object movements, boundary condition checks, mesh deformation on collision, and FPS counter updates. Loading Loading @@ -192,10 +194,30 @@ public class GraphicsAndWindowsTest extends Application { double WindowSize = sceneWindow.getWindowSize(); // Reverse direction at bounds for (int i = 0; i < objects.length; i++) { direction[i][1] += 1; double GRAVITY = 1; double AIRRESISTANCE = 0.05; //Physics updates //Gravity direction[i][1] += GRAVITY; //air resistance computation double mag = 0; for (int j = 0; j < 3; j++ ) { mag += Math.pow(direction[i][j],2); } mag = Math.sqrt(mag); double airResistance = mag * AIRRESISTANCE; direction[i][0] = direction[i][0] - (direction[i][0] / mag * airResistance); direction[i][1] = direction[i][1] - (direction[i][1] / mag * airResistance); direction[i][2] = direction[i][2] - (direction[i][2] / mag * airResistance); double x = direction[i][0]; double y = direction[i][1]; double z = direction[i][2]; // the following will be class methods in the future // Window Collision computation for X if (meshBounds[i].getMinX() + direction[i][0] < winLeftXBound || meshBounds[i].getMaxX() + direction[i][0] > winLeftXBound + WindowSize) { if (meshBounds[i].getMinX() + x < winLeftXBound) { Loading @@ -208,6 +230,8 @@ public class GraphicsAndWindowsTest extends Application { lastChanged = 1; } // Window Collision computation for Y if (meshBounds[i].getMinY() + direction[i][1] < winTopYBound || meshBounds[i].getMaxY() + direction[i][1] > winTopYBound + WindowSize) { if (meshBounds[i].getMinY() + y < winTopYBound) { Loading @@ -219,6 +243,8 @@ public class GraphicsAndWindowsTest extends Application { direction[i][1] *= -1; lastChanged = 2; } // Window Collision computation for Z if (meshBounds[i].getMinZ() + direction[i][2] < 0 || meshBounds[i].getMaxZ() + direction[i][2] > WindowSize) { if (meshBounds[i].getMinZ() + z < 0) { z = direction[i][2] + (0 - (meshBounds[i].getMinZ() + z)); Loading target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class +397 B (4.56 KiB) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/GraphicsAndWindowsTest.class (6.42 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
.idea/misc.xml +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ </option> <option name="workspaceImportForciblyTurnedOn" value="true" /> </component> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="22" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="22" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> </project> No newline at end of file
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +27 −1 Original line number Diff line number Diff line Loading @@ -158,6 +158,8 @@ public class GraphicsAndWindowsTest extends Application { private long fpsTimer = 0; //Frame timer private long frameRate = 0; //Frames per second /** * Called at every frame while the {@link AnimationTimer} is active to update the scene's elements, * including object movements, boundary condition checks, mesh deformation on collision, and FPS counter updates. Loading Loading @@ -192,10 +194,30 @@ public class GraphicsAndWindowsTest extends Application { double WindowSize = sceneWindow.getWindowSize(); // Reverse direction at bounds for (int i = 0; i < objects.length; i++) { direction[i][1] += 1; double GRAVITY = 1; double AIRRESISTANCE = 0.05; //Physics updates //Gravity direction[i][1] += GRAVITY; //air resistance computation double mag = 0; for (int j = 0; j < 3; j++ ) { mag += Math.pow(direction[i][j],2); } mag = Math.sqrt(mag); double airResistance = mag * AIRRESISTANCE; direction[i][0] = direction[i][0] - (direction[i][0] / mag * airResistance); direction[i][1] = direction[i][1] - (direction[i][1] / mag * airResistance); direction[i][2] = direction[i][2] - (direction[i][2] / mag * airResistance); double x = direction[i][0]; double y = direction[i][1]; double z = direction[i][2]; // the following will be class methods in the future // Window Collision computation for X if (meshBounds[i].getMinX() + direction[i][0] < winLeftXBound || meshBounds[i].getMaxX() + direction[i][0] > winLeftXBound + WindowSize) { if (meshBounds[i].getMinX() + x < winLeftXBound) { Loading @@ -208,6 +230,8 @@ public class GraphicsAndWindowsTest extends Application { lastChanged = 1; } // Window Collision computation for Y if (meshBounds[i].getMinY() + direction[i][1] < winTopYBound || meshBounds[i].getMaxY() + direction[i][1] > winTopYBound + WindowSize) { if (meshBounds[i].getMinY() + y < winTopYBound) { Loading @@ -219,6 +243,8 @@ public class GraphicsAndWindowsTest extends Application { direction[i][1] *= -1; lastChanged = 2; } // Window Collision computation for Z if (meshBounds[i].getMinZ() + direction[i][2] < 0 || meshBounds[i].getMaxZ() + direction[i][2] > WindowSize) { if (meshBounds[i].getMinZ() + z < 0) { z = direction[i][2] + (0 - (meshBounds[i].getMinZ() + z)); Loading
target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class +397 B (4.56 KiB) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/GraphicsAndWindowsTest.class (6.42 KiB) File changed.No diff preview for this file type. View original file View changed file