Commit 35a4486b authored by Sergio Emanuel Rodriguez Rivera's avatar Sergio Emanuel Rodriguez Rivera
Browse files

full motion with camera

parent d07cc99e
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -281,9 +281,24 @@ public class GraphicsAndWindowsTest extends Application {
            for (MovingObject o : objects) {
                double x = releaseX - anchorX;
                double y = releaseY - anchorY;
                double z = o.getVelocityVec()[2];  // Assume Z is initially unaffected
                x = min(x, 50);
                y = min(y, 50);
                o.setVelocityVec(x,y,o.getVelocityVec()[2]);

                // Calculate new coordinates based on the rotation of the camera
                double cosX = Math.cos(Math.toRadians(groupRotX.getAngle()));
                double sinX = Math.sin(Math.toRadians(groupRotX.getAngle()));
                double cosY = Math.cos(Math.toRadians(groupRotY.getAngle()));
                double sinY = Math.sin(Math.toRadians(groupRotY.getAngle()));

                // Apply transformations
                double newX = x * cosY + z * sinY;
                double newZ = z * cosY - x * sinY;
                double newY = y * cosX + newZ * sinX;
                newZ = newZ * cosX - y * sinX;

                // Set the new velocity vector
                o.setVelocityVec(newX, newY, newZ);
            }

            // Remove the sling visualization line
+20 −6
Original line number Diff line number Diff line
@@ -236,12 +236,26 @@ public class MillionTriangle extends Application {
            //System.out.println("Mouse released at: " + releaseX + ", " + releaseY);

            for (MovingObject o : objects) {

                double x = releaseX - anchorX;
                double y = releaseY - anchorY;
                double z = o.getVelocityVec()[2];  // Assume Z is initially unaffected
                x = min(x, 50);
                y = min(y, 50);
                o.setVelocityVec(x,y,o.getVelocityVec()[2]);

                // Calculate new coordinates based on the rotation of the camera
                double cosX = Math.cos(Math.toRadians(groupRotX.getAngle()));
                double sinX = Math.sin(Math.toRadians(groupRotX.getAngle()));
                double cosY = Math.cos(Math.toRadians(groupRotY.getAngle()));
                double sinY = Math.sin(Math.toRadians(groupRotY.getAngle()));

                // Apply transformations
                double newX = x * cosY + z * sinY;
                double newZ = z * cosY - x * sinY;
                double newY = y * cosX + newZ * sinX;
                newZ = newZ * cosX - y * sinX;

                // Set the new velocity vector
                o.setVelocityVec(newX, newY, newZ);
            }

            // Remove the sling visualization line
Loading