Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Group2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EC504 Spring 2024 Group Projects
Group2
Commits
96b15b2e
Commit
96b15b2e
authored
1 year ago
by
Sergio Emanuel Rodriguez Rivera
Browse files
Options
Downloads
Patches
Plain Diff
Javadoc on MovingObject
parent
1969ea59
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/Shape/MovingObject.java
+47
-4
47 additions, 4 deletions
src/main/java/Shape/MovingObject.java
with
47 additions
and
4 deletions
src/main/java/Shape/MovingObject.java
+
47
−
4
View file @
96b15b2e
...
...
@@ -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
<>();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment