I want to make a game where you are a player on a 3D plane, who is able to collide with objects around him. I plan to do collisions by wrapping all 3D models in the game with invisible rectangles that cannot be entered. I have written code to calculate the min/max of the X,Y, and Z of each vertex to find the highest and lowest point of each vertex. How would I make this into a rectangular prism?
Here is my code so far:
public CollisionModel(List<Vector3f> vert) {
float xLow = 1000;
float xHigh = 0;
float yLow = 1000;
float yHigh = 0;
float zLow = 1000;
float zHigh = 0;
for(Vector3f v : vert) {
if(v.x > xHigh) {
xHigh = v.x;
} else if(v.x < xLow) {
xLow = v.x;
}
if(v.y > yHigh) {
yHigh = v.y;
} else if(v.y < yLow) {
yLow = v.y;
}
if(v.z > zHigh) {
zHigh = v.z;
} else if(v.z < zLow) {
zLow = v.z;
}
}
}