Browse Source

load mesh data and structure meshes

server-collision
FatBoy-DOTC 11 months ago
parent
commit
83606046ba
  1. 18
      src/engine/CollisionEngine/Mesh.java
  2. 5
      src/engine/devcmd/cmds/ColliderCmd.java
  3. 5
      src/engine/gameManager/BuildingManager.java

18
src/engine/CollisionEngine/Mesh.java

@ -32,13 +32,13 @@ public class Mesh { @@ -32,13 +32,13 @@ public class Mesh {
}
this.triangles = new ArrayList<>();
double radian = (double)rotation;
int degrees = (int)Math.toDegrees(rotation);
for(Triangle tri : CollisionManager.mesh_triangles.get(this.mesh_id)){
Triangle newTri = new Triangle();
Vector3f rotatedPoint1 = Vector3f.rotateAroundPoint(new Vector3f(tri.point1.x,mesh_location.y,tri.point1.y),mesh_location,radian);
Vector3f rotatedPoint2 = Vector3f.rotateAroundPoint(new Vector3f(tri.point2.x,mesh_location.y,tri.point2.y),mesh_location,radian);
Vector3f rotatedPoint3 = Vector3f.rotateAroundPoint(new Vector3f(tri.point3.x,mesh_location.y,tri.point3.y),mesh_location,radian);
Vector3f rotatedPoint1 = Vector3f.rotateAroundPoint(new Vector3f(tri.point1.x,mesh_location.y,tri.point1.y),mesh_location,degrees);
Vector3f rotatedPoint2 = Vector3f.rotateAroundPoint(new Vector3f(tri.point2.x,mesh_location.y,tri.point2.y),mesh_location,degrees);
Vector3f rotatedPoint3 = Vector3f.rotateAroundPoint(new Vector3f(tri.point3.x,mesh_location.y,tri.point3.y),mesh_location,degrees);
newTri.point1 = new Point2D.Float(rotatedPoint1.x,rotatedPoint1.z);
newTri.point2 = new Point2D.Float(rotatedPoint2.x,rotatedPoint2.z);
@ -48,15 +48,17 @@ public class Mesh { @@ -48,15 +48,17 @@ public class Mesh {
newTri.sides.add(new Line2D.Float(newTri.point1,newTri.point2));
newTri.sides.add(new Line2D.Float(newTri.point2,newTri.point3));
newTri.sides.add(new Line2D.Float(newTri.point3,newTri.point1));
this.triangles.add(newTri);
}
}
public void MakeBounds(float rotation){
double radian = (double)rotation;
Vector3f rotatedEnd = Vector3f.rotateAroundPoint(new Vector3f(this.mesh_end_point.x,mesh_location.y,this.mesh_end_point.z),mesh_location,radian);
Vector3f rotatedRef = Vector3f.rotateAroundPoint(new Vector3f(this.mesh_ref_point.x,mesh_location.y,this.mesh_ref_point.z),mesh_location,radian);
int degrees = (int)Math.toDegrees(rotation);
Vector3f rotatedEnd = Vector3f.rotateAroundPoint(new Vector3f(this.mesh_end_point.x,mesh_location.y,this.mesh_end_point.z),mesh_location,degrees);
Vector3f rotatedRef = Vector3f.rotateAroundPoint(new Vector3f(this.mesh_ref_point.x,mesh_location.y,this.mesh_ref_point.z),mesh_location,degrees);
this.mesh_bounds = new Rectangle2D.Float();
this.mesh_bounds.setRect(rotatedEnd.x,rotatedEnd.z,Math.abs(rotatedEnd.x) - Math.abs(rotatedRef.x),Math.abs(rotatedEnd.z) - Math.abs(rotatedRef.z));
this.mesh_bounds.setRect(rotatedEnd.x,rotatedEnd.z,Math.abs(Math.abs(rotatedRef.x) - rotatedEnd.x),Math.abs(rotatedEnd.z) - Math.abs(rotatedRef.z));
}
}

5
src/engine/devcmd/cmds/ColliderCmd.java

@ -33,13 +33,14 @@ public class ColliderCmd extends AbstractDevCmd { @@ -33,13 +33,14 @@ public class ColliderCmd extends AbstractDevCmd {
output = "Collision Info:" + newline;
output += "Total Meshes: " + building.buildingMeshes.size() + newline;
for(Mesh mesh : building.buildingMeshes){
output += "-----------------------------";
output += "-----------------------------" + newline;
output += "Mesh ID: " + mesh.mesh_id + newline;
output += "Mesh Location: " + mesh.mesh_location + newline;
output += "Mesh Scale: " + mesh.mesh_scale + newline;
output += "Mesh Min/Max: " + mesh.mesh_min_y + "/" + mesh.mesh_max_y + newline;
output += "Mesh Triangle Count: " + mesh.triangles.size() + newline;
output += "Mesh Rect: " + mesh.mesh_bounds + newline;
output += "-----------------------------";
output += "-----------------------------" + newline;
}
throwbackInfo(pc,output);

5
src/engine/gameManager/BuildingManager.java

@ -981,7 +981,7 @@ public enum BuildingManager { @@ -981,7 +981,7 @@ public enum BuildingManager {
public static void BakeBuildingColliders(Building building){
if(CollisionManager.structure_meshes.containsKey(building.meshUUID) == false) {
Logger.error("No Meshes Found Fro Structure: " + building.meshUUID);
Logger.error("No Meshes Found For Structure: " + building.meshUUID);
return;
}
@ -990,6 +990,9 @@ public enum BuildingManager { @@ -990,6 +990,9 @@ public enum BuildingManager {
//create the actual meshes from the stored mesh data
for(MeshData meshData : CollisionManager.structure_meshes.get(building.meshUUID)){
if(meshData.meshID == 0)
continue;
Mesh generatedMesh = new Mesh();
generatedMesh.mesh_end_point = new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc).add(meshData.endPoint);
generatedMesh.mesh_ref_point = new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc).add(meshData.refPoint);

Loading…
Cancel
Save