From 96b15b2e49b8af6f90d3ac1ab9fdbfe1b0836e86 Mon Sep 17 00:00:00 2001 From: SergioRodriguezRivera Date: Wed, 17 Apr 2024 21:17:59 -0400 Subject: [PATCH] Javadoc on MovingObject --- src/main/java/Shape/MovingObject.java | 51 ++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/main/java/Shape/MovingObject.java b/src/main/java/Shape/MovingObject.java index 2f08b42..e7cbd52 100644 --- a/src/main/java/Shape/MovingObject.java +++ b/src/main/java/Shape/MovingObject.java @@ -62,7 +62,7 @@ public class MovingObject { directionVec = fileObject.getDirection(); speed = fileObject.getSpeed(); initVelocity(); - initPhysics(1, speed); + //initPhysics(1, speed); velocityVec = getVelocityVec(); mesh.getPoints().setAll(fileObject.getVertices()); mesh.getFaces().setAll(fileObject.getFaces()); @@ -83,11 +83,11 @@ public class MovingObject { } */ - /*Verify if being called*/ + /* public void initPhysics(double grav, double speed) { gravity = 10; } - + */ /** * Sets the texture coordinates for the object's mesh. @@ -155,19 +155,31 @@ public class MovingObject { velocityVec[2] = z; } - + /** + * Updates the velocity of the object by applying gravity. + */ public void updateVelocity() { velocityVec[1] += gravity; } + /** + * Placeholder method for collision checking. + */ public void checkCollision() {} + /** + * Initializes the velocity vector based on the object's direction and speed. + */ public void initVelocity() { for (int ii = 0; ii < 3; ii++) { velocityVec[ii] = directionVec[ii] * speed; } } + /** + * Resets the file path for the readFile object and reloads mesh data. + * @param filePath New file path to set. + */ public void setNewFilePath(String filePath) { fileObject = new readFile(filePath); fileObject.makeMatrix(); @@ -180,16 +192,26 @@ public class MovingObject { setCentroid(); } + /** + * Sets default rendering settings for the object's mesh view. + */ public void setTempDefault() { triangleView.setCullFace(CullFace.NONE); triangleView.setMaterial(new PhongMaterial(Color.BLUE)); setTexCoords(0,0); } + /** + * Returns the mesh view associated with the object. + * @return MeshView of the object. + */ public MeshView getMesh() { return triangleView; } + /** + * Calculates and updates the centroid of the object based on its vertices. + */ public void setCentroid() { if (dirtyTranslate) { float[] vertices = fileObject.getVertices(); @@ -214,6 +236,10 @@ public class MovingObject { } } + /** + * Retrieves the updated centroid of the object considering its translation. + * @return Array of doubles representing the current centroid in 3D space. + */ public double[] getCentroid() { double[] baseCentroid = new double[3]; baseCentroid[0] = centroid[0] + translate.getX(); @@ -222,6 +248,9 @@ public class MovingObject { return baseCentroid; } + /** + * Updates the distances (rays) from the centroid to each vertex, potentially for collision detection or other calculations. + */ public void updateRays() { double X = translate.getX(); double Y = translate.getY(); @@ -234,6 +263,12 @@ public class MovingObject { } } + /** + * Applies a deformation to the object based on the specified side and axis. + * @param side Side of the deformation (either positive or negative direction). + * @param axis Axis of deformation (0 for X-axis, 1 for Y-axis, 2 for Z-axis). + * @param speed Magnitude of deformation. + */ public void deformShape(int side, int axis, double speed) { if (deformDir[axis+side] != null) { @@ -293,6 +328,9 @@ public class MovingObject { deformDir[axis+side] = newDeform; } + /** + * Reverses any deformations applied to the object. + */ public void unDeformShape() { float[] points = mesh.getPoints().toArray(null); for (Deformation d : deformDir) { @@ -324,6 +362,11 @@ public class MovingObject { } private class Deformation { + + /** + * Constructs a deformation with a specified magnitude. + * @param deform Magnitude of deformation. + */ Deformation(double deform) { deformed = false; layer1 = new HashSet<>(); -- GitLab