Browse Source

load mesh data and structure meshes

server-collision
FatBoy-DOTC 10 months ago
parent
commit
8b095976ef
  1. 9
      src/engine/CollisionEngine/Mesh.java
  2. 11
      src/engine/gameManager/BuildingManager.java

9
src/engine/CollisionEngine/Mesh.java

@ -53,12 +53,11 @@ public class Mesh {
} }
} }
public void MakeBounds(float rotation){ public void MakeBounds(){
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 = new Rectangle2D.Float();
this.mesh_bounds.setRect(rotatedEnd.x,rotatedEnd.z,Math.abs(Math.abs(rotatedRef.x) - rotatedEnd.x),Math.abs(rotatedEnd.z) - Math.abs(rotatedRef.z)); float width = this.mesh_ref_point.subtract(this.mesh_location).x * 2;
float height = this.mesh_ref_point.subtract(this.mesh_location).z * 2;
this.mesh_bounds.setRect(this.mesh_ref_point.x,this.mesh_ref_point.z,width, height);
} }
} }

11
src/engine/gameManager/BuildingManager.java

@ -993,10 +993,13 @@ public enum BuildingManager {
if(meshData.meshID == 0) if(meshData.meshID == 0)
continue; continue;
int degrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY);
Mesh generatedMesh = new Mesh(); 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); generatedMesh.mesh_end_point = Vector3f.rotateAroundPoint(new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc.add(meshData.endPoint)),new Vector3f(building.loc.x,building.loc.y,building.loc.z),degrees);
generatedMesh.mesh_location = new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc); generatedMesh.mesh_ref_point = Vector3f.rotateAroundPoint(new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc.add(meshData.refPoint)),new Vector3f(building.loc.x,building.loc.y,building.loc.z),degrees);
generatedMesh.mesh_location = Vector3f.rotateAroundPoint(new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc),new Vector3f(building.loc.x,building.loc.y,building.loc.z),degrees);
generatedMesh.mesh_max_y = building.loc.y + meshData.maxY; generatedMesh.mesh_max_y = building.loc.y + meshData.maxY;
generatedMesh.mesh_min_y = building.loc.y + meshData.minY; generatedMesh.mesh_min_y = building.loc.y + meshData.minY;
generatedMesh.mesh_scale = meshData.scale; generatedMesh.mesh_scale = meshData.scale;
@ -1005,7 +1008,7 @@ public enum BuildingManager {
generatedMesh.parent_structure_id = building.meshUUID; generatedMesh.parent_structure_id = building.meshUUID;
generatedMesh.parentUUID = building.getObjectUUID(); generatedMesh.parentUUID = building.getObjectUUID();
generatedMesh.AdoptTriangles(building.getBounds().getQuaternion().angleY); generatedMesh.AdoptTriangles(building.getBounds().getQuaternion().angleY);
generatedMesh.MakeBounds(building.getBounds().getQuaternion().angleY); generatedMesh.MakeBounds();
building.buildingMeshes.add(generatedMesh); building.buildingMeshes.add(generatedMesh);
} }
} }

Loading…
Cancel
Save