Browse Source

load mesh data and structure meshes

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

7
src/engine/CollisionEngine/Mesh.java

@ -23,6 +23,9 @@ public class Mesh {
public int parent_prop_id; public int parent_prop_id;
public int parent_structure_id; public int parent_structure_id;
public int parentUUID; public int parentUUID;
public float rectWidth;
public float rectHeight;
public Rectangle2D.Float mesh_bounds; public Rectangle2D.Float mesh_bounds;
public void AdoptTriangles(float rotation){ public void AdoptTriangles(float rotation){
@ -56,8 +59,6 @@ public class Mesh {
public void MakeBounds(){ public void MakeBounds(){
this.mesh_bounds = new Rectangle2D.Float(); this.mesh_bounds = new Rectangle2D.Float();
float width = this.mesh_ref_point.subtract(this.mesh_location).x * 2; this.mesh_bounds.setRect(this.mesh_ref_point.x,this.mesh_ref_point.z,this.rectWidth, this.rectHeight);
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);
} }
} }

10
src/engine/gameManager/BuildingManager.java

@ -996,10 +996,12 @@ public enum BuildingManager {
int degrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY); int degrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY);
Mesh generatedMesh = new Mesh(); Mesh generatedMesh = new Mesh();
Vector3f buildingLoc = new Vector3f(building.loc.x,building.loc.y,building.loc.z);
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 = Vector3f.rotateAroundPoint(buildingLoc.add(meshData.loc),buildingLoc,degrees);
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_end_point = Vector3f.rotateAroundPoint(generatedMesh.mesh_location.add(meshData.endPoint),buildingLoc,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_ref_point = Vector3f.rotateAroundPoint(generatedMesh.mesh_location.add(meshData.refPoint),buildingLoc,degrees);
generatedMesh.rectWidth = meshData.refPoint.x * 2;
generatedMesh.rectHeight = meshData.refPoint.z * 2;
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;

Loading…
Cancel
Save