load mesh data and structure meshes
This commit is contained in:
@@ -9,6 +9,7 @@ import org.pmw.tinylog.Logger;
|
|||||||
|
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
|
|
||||||
|
import java.awt.geom.Path2D;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -62,27 +63,24 @@ public class Mesh {
|
|||||||
|
|
||||||
public void MakeBounds(){
|
public void MakeBounds(){
|
||||||
|
|
||||||
float minX = 0;
|
ArrayList<Rectangle2D> rects = new ArrayList<>();
|
||||||
float minZ = 0;
|
|
||||||
|
|
||||||
for(Triangle tri : this.triangles){
|
for(Triangle tri : this.triangles){
|
||||||
if(tri.point1.x < minX)
|
Path2D.Float path = new Path2D.Float();
|
||||||
minX = tri.point1.x;
|
path.lineTo(tri.point1.x,tri.point1.y);
|
||||||
if(tri.point2.x < minX)
|
path.lineTo(tri.point2.x,tri.point2.y);
|
||||||
minX = tri.point1.x;
|
path.lineTo(tri.point3.x,tri.point3.y);
|
||||||
if(tri.point3.x < minX)
|
path.closePath();
|
||||||
minX = tri.point1.x;
|
rects.add(path.getBounds());
|
||||||
if(tri.point1.y < minZ)
|
}
|
||||||
minZ = tri.point1.x;
|
Rectangle2D.Float boundsRect = new Rectangle2D.Float();
|
||||||
if(tri.point2.y < minZ)
|
boundsRect.setRect(rects.get(0));
|
||||||
minZ = tri.point1.x;
|
for(Rectangle2D rectangle : rects){
|
||||||
if(tri.point3.y < minZ)
|
boundsRect.add(rectangle);
|
||||||
minZ = tri.point1.x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mesh_bounds = new Rectangle2D.Float();
|
this.mesh_bounds = new Rectangle2D.Float();
|
||||||
float width = (this.mesh_location.x) - minX * 2;
|
float width = (float)boundsRect.getWidth();
|
||||||
float height = Math.abs((this.mesh_location.z) + minZ) * 2;
|
float height = (float)boundsRect.getHeight();
|
||||||
this.mesh_bounds.setRect(minX,minZ,width, height);
|
this.mesh_bounds.setRect(boundsRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user