diff --git a/application/pom.xml b/application/pom.xml new file mode 100644 index 0000000..f523d75 --- /dev/null +++ b/application/pom.xml @@ -0,0 +1,17 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-master + 1.0.0 + + mc-mesh-application + 0.0.1 + pom + + + visualizer + + \ No newline at end of file diff --git a/application/visualizer/Test1/dependency-reduced-pom.xml b/application/visualizer/Test1/dependency-reduced-pom.xml new file mode 100644 index 0000000..413447f --- /dev/null +++ b/application/visualizer/Test1/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-1 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshTest + + + + + + + + diff --git a/application/visualizer/Test1/pom.xml b/application/visualizer/Test1/pom.xml new file mode 100644 index 0000000..bfb8fc7 --- /dev/null +++ b/application/visualizer/Test1/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-1 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshTest + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshTest.java b/application/visualizer/Test1/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshTest.java similarity index 80% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshTest.java rename to application/visualizer/Test1/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshTest.java index 881fd5d..b50a7c2 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshTest.java +++ b/application/visualizer/Test1/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshTest.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.io.BufferedReader; import java.io.File; @@ -8,12 +8,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.bukkit.util.Vector; - -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.ChunkLocation; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Facet; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.MeshBuilder; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.Point; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Facet; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.MeshBuilder; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Vector3d; public class MeshTest { private static final File BASE = new File( System.getProperty( "user.dir" ) ); @@ -34,7 +33,7 @@ public class MeshTest { private static void doStuff( File file ) { String name = file.getName(); String[] split = name.split( "," ); - ChunkLocation location = new ChunkLocation( split[ 0 ], Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); + Point location = new Point( Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); System.out.println( "Parsing chunk " + location ); @@ -105,14 +104,14 @@ public class MeshTest { private static List< Facet > generateFacetsFor( AABB box ) { List< Facet > facets = new ArrayList< Facet >(); - Vector p1 = new Vector( box.xmin, box.ymin, box.zmin ); - Vector p2 = new Vector( box.xmin, box.ymin, box.zmax ); - Vector p3 = new Vector( box.xmin, box.ymax, box.zmin ); - Vector p4 = new Vector( box.xmin, box.ymax, box.zmax ); - Vector p5 = new Vector( box.xmax, box.ymin, box.zmin ); - Vector p6 = new Vector( box.xmax, box.ymin, box.zmax ); - Vector p7 = new Vector( box.xmax, box.ymax, box.zmin ); - Vector p8 = new Vector( box.xmax, box.ymax, box.zmax ); + Vector3d p1 = new Vector3d( box.xmin, box.ymin, box.zmin ); + Vector3d p2 = new Vector3d( box.xmin, box.ymin, box.zmax ); + Vector3d p3 = new Vector3d( box.xmin, box.ymax, box.zmin ); + Vector3d p4 = new Vector3d( box.xmin, box.ymax, box.zmax ); + Vector3d p5 = new Vector3d( box.xmax, box.ymin, box.zmin ); + Vector3d p6 = new Vector3d( box.xmax, box.ymin, box.zmax ); + Vector3d p7 = new Vector3d( box.xmax, box.ymax, box.zmin ); + Vector3d p8 = new Vector3d( box.xmax, box.ymax, box.zmax ); { Facet facet = new Facet(); @@ -120,7 +119,7 @@ public class MeshTest { facet.points.add( p2 ); facet.points.add( p4 ); facet.points.add( p3 ); - facet.normal = new Vector( -1, 0, 0 ); + facet.normal = new Vector3d( -1, 0, 0 ); facets.add( facet ); } @@ -130,7 +129,7 @@ public class MeshTest { facet.points.add( p6 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 1, 0, 0 ); + facet.normal = new Vector3d( 1, 0, 0 ); facets.add( facet ); } @@ -140,7 +139,7 @@ public class MeshTest { facet.points.add( p2 ); facet.points.add( p6 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, -1, 0 ); + facet.normal = new Vector3d( 0, -1, 0 ); facets.add( facet ); } @@ -150,7 +149,7 @@ public class MeshTest { facet.points.add( p4 ); facet.points.add( p7 ); facet.points.add( p8 ); - facet.normal = new Vector( 0, 1, 0 ); + facet.normal = new Vector3d( 0, 1, 0 ); facets.add( facet ); } @@ -160,7 +159,7 @@ public class MeshTest { facet.points.add( p3 ); facet.points.add( p7 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, 0, -1 ); + facet.normal = new Vector3d( 0, 0, -1 ); facets.add( facet ); } @@ -170,7 +169,7 @@ public class MeshTest { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p6 ); - facet.normal = new Vector( 0, 0, 1 ); + facet.normal = new Vector3d( 0, 0, 1 ); facets.add( facet ); } diff --git a/application/visualizer/Test2/dependency-reduced-pom.xml b/application/visualizer/Test2/dependency-reduced-pom.xml new file mode 100644 index 0000000..75c19a5 --- /dev/null +++ b/application/visualizer/Test2/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-2 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest2 + + + + + + + + diff --git a/application/visualizer/Test2/pom.xml b/application/visualizer/Test2/pom.xml new file mode 100644 index 0000000..3e7b6de --- /dev/null +++ b/application/visualizer/Test2/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-2 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest2 + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest2.java b/application/visualizer/Test2/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest2.java similarity index 93% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest2.java rename to application/visualizer/Test2/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest2.java index 36f49e5..7e37ea2 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest2.java +++ b/application/visualizer/Test2/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest2.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.awt.BorderLayout; import java.awt.Color; @@ -35,8 +35,6 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; -import org.bukkit.util.Vector; - import com.aaaaahhhhhhh.bananapuncher714.mesh.Chain; import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh; import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh.MeshChainEventHandler; @@ -48,10 +46,10 @@ import com.aaaaahhhhhhh.bananapuncher714.mesh.Vector2d; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionRuleWinding; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple.GluWindingRule; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.ChunkLocation; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Facet; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.MeshBuilder; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Facet; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.MeshBuilder; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Vector3d; /** * Chunk data meshing visualizer @@ -170,7 +168,7 @@ public class MeshingTest2 extends JPanel { private static List< Plane > mesh( File file ) { String name = file.getName(); String[] split = name.split( "," ); - ChunkLocation location = new ChunkLocation( split[ 0 ], Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); + Point location = new Point( Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); System.out.println( "Parsing chunk " + location ); @@ -564,8 +562,8 @@ public class MeshingTest2 extends JPanel { { final Plane plane = new Plane(); - plane.normal = new Vector( 0, 0, 1 ); - plane.point = new Vector( 1, 0, 0 ); + plane.normal = new Vector3d( 0, 0, 1 ); + plane.point = new Vector3d( 1, 0, 0 ); // plane.polygons.add( new Polygon( Arrays.asList( // new Point( 1, 0 ), @@ -656,8 +654,8 @@ public class MeshingTest2 extends JPanel { { final Plane plane = new Plane(); - plane.normal = new Vector( 0, 0, 1 ); - plane.point = new Vector( 1, 0, 0 ); + plane.normal = new Vector3d( 0, 0, 1 ); + plane.point = new Vector3d( 1, 0, 0 ); plane.polygons.add( new Polygon( Arrays.asList( new Point( 0, 0 ), @@ -682,8 +680,8 @@ public class MeshingTest2 extends JPanel { { final Plane plane = new Plane(); - plane.normal = new Vector( 0, 0, 1 ); - plane.point = new Vector( 1, 0, 0 ); + plane.normal = new Vector3d( 0, 0, 1 ); + plane.point = new Vector3d( 1, 0, 0 ); plane.polygons.add( new Polygon( Arrays.asList( new Point( 0, 0 ), @@ -707,14 +705,14 @@ public class MeshingTest2 extends JPanel { private static List< Facet > generateFacetsFor( AABB box ) { List< Facet > facets = new ArrayList< Facet >(); - Vector p1 = new Vector( box.xmin, box.ymin, box.zmin ); - Vector p2 = new Vector( box.xmin, box.ymin, box.zmax ); - Vector p3 = new Vector( box.xmin, box.ymax, box.zmin ); - Vector p4 = new Vector( box.xmin, box.ymax, box.zmax ); - Vector p5 = new Vector( box.xmax, box.ymin, box.zmin ); - Vector p6 = new Vector( box.xmax, box.ymin, box.zmax ); - Vector p7 = new Vector( box.xmax, box.ymax, box.zmin ); - Vector p8 = new Vector( box.xmax, box.ymax, box.zmax ); + Vector3d p1 = new Vector3d( box.xmin, box.ymin, box.zmin ); + Vector3d p2 = new Vector3d( box.xmin, box.ymin, box.zmax ); + Vector3d p3 = new Vector3d( box.xmin, box.ymax, box.zmin ); + Vector3d p4 = new Vector3d( box.xmin, box.ymax, box.zmax ); + Vector3d p5 = new Vector3d( box.xmax, box.ymin, box.zmin ); + Vector3d p6 = new Vector3d( box.xmax, box.ymin, box.zmax ); + Vector3d p7 = new Vector3d( box.xmax, box.ymax, box.zmin ); + Vector3d p8 = new Vector3d( box.xmax, box.ymax, box.zmax ); { Facet facet = new Facet(); @@ -722,7 +720,7 @@ public class MeshingTest2 extends JPanel { facet.points.add( p2 ); facet.points.add( p4 ); facet.points.add( p3 ); - facet.normal = new Vector( -1, 0, 0 ); + facet.normal = new Vector3d( -1, 0, 0 ); facets.add( facet ); } @@ -732,7 +730,7 @@ public class MeshingTest2 extends JPanel { facet.points.add( p6 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 1, 0, 0 ); + facet.normal = new Vector3d( 1, 0, 0 ); facets.add( facet ); } @@ -742,7 +740,7 @@ public class MeshingTest2 extends JPanel { facet.points.add( p2 ); facet.points.add( p6 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, -1, 0 ); + facet.normal = new Vector3d( 0, -1, 0 ); facets.add( facet ); } @@ -752,7 +750,7 @@ public class MeshingTest2 extends JPanel { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 0, 1, 0 ); + facet.normal = new Vector3d( 0, 1, 0 ); facets.add( facet ); } @@ -762,7 +760,7 @@ public class MeshingTest2 extends JPanel { facet.points.add( p3 ); facet.points.add( p7 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, 0, -1 ); + facet.normal = new Vector3d( 0, 0, -1 ); facets.add( facet ); } @@ -772,7 +770,7 @@ public class MeshingTest2 extends JPanel { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p6 ); - facet.normal = new Vector( 0, 0, 1 ); + facet.normal = new Vector3d( 0, 0, 1 ); facets.add( facet ); } diff --git a/application/visualizer/Test3/dependency-reduced-pom.xml b/application/visualizer/Test3/dependency-reduced-pom.xml new file mode 100644 index 0000000..eb4b69e --- /dev/null +++ b/application/visualizer/Test3/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-3 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest3 + + + + + + + + diff --git a/application/visualizer/Test3/pom.xml b/application/visualizer/Test3/pom.xml new file mode 100644 index 0000000..a7a787f --- /dev/null +++ b/application/visualizer/Test3/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-3 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest3 + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest3.java b/application/visualizer/Test3/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest3.java similarity index 82% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest3.java rename to application/visualizer/Test3/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest3.java index 429a080..a7411ba 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest3.java +++ b/application/visualizer/Test3/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest3.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.io.BufferedReader; import java.io.File; @@ -11,18 +11,16 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.bukkit.util.Vector; - import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh; import com.aaaaahhhhhhh.bananapuncher714.mesh.Polygon; +import com.aaaaahhhhhhh.bananapuncher714.mesh.Point; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Facet; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.MeshBuilder; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Vector3d; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionRuleWinding; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple.GluWindingRule; -import com.aaaaahhhhhhh.bananapuncher714.minietest.MeshingTest2.AABB; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.ChunkLocation; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Facet; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.MeshBuilder; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Plane; /** * Mesh speed test @@ -113,7 +111,7 @@ public class MeshingTest3 { private static List< Plane > mesh( File file, final StringBuilder stringBuilder ) { String name = file.getName(); String[] split = name.split( "," ); - ChunkLocation location = new ChunkLocation( split[ 0 ], Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); + Point location = new Point( Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); // First parse the file to get a list of all bounding boxes that we can use List< AABB > boxes = new ArrayList< AABB >(); @@ -161,14 +159,14 @@ public class MeshingTest3 { private static List< Facet > generateFacetsFor( AABB box ) { List< Facet > facets = new ArrayList< Facet >(); - Vector p1 = new Vector( box.xmin, box.ymin, box.zmin ); - Vector p2 = new Vector( box.xmin, box.ymin, box.zmax ); - Vector p3 = new Vector( box.xmin, box.ymax, box.zmin ); - Vector p4 = new Vector( box.xmin, box.ymax, box.zmax ); - Vector p5 = new Vector( box.xmax, box.ymin, box.zmin ); - Vector p6 = new Vector( box.xmax, box.ymin, box.zmax ); - Vector p7 = new Vector( box.xmax, box.ymax, box.zmin ); - Vector p8 = new Vector( box.xmax, box.ymax, box.zmax ); + Vector3d p1 = new Vector3d( box.xmin, box.ymin, box.zmin ); + Vector3d p2 = new Vector3d( box.xmin, box.ymin, box.zmax ); + Vector3d p3 = new Vector3d( box.xmin, box.ymax, box.zmin ); + Vector3d p4 = new Vector3d( box.xmin, box.ymax, box.zmax ); + Vector3d p5 = new Vector3d( box.xmax, box.ymin, box.zmin ); + Vector3d p6 = new Vector3d( box.xmax, box.ymin, box.zmax ); + Vector3d p7 = new Vector3d( box.xmax, box.ymax, box.zmin ); + Vector3d p8 = new Vector3d( box.xmax, box.ymax, box.zmax ); { Facet facet = new Facet(); @@ -176,7 +174,7 @@ public class MeshingTest3 { facet.points.add( p2 ); facet.points.add( p4 ); facet.points.add( p3 ); - facet.normal = new Vector( -1, 0, 0 ); + facet.normal = new Vector3d( -1, 0, 0 ); facets.add( facet ); } @@ -186,7 +184,7 @@ public class MeshingTest3 { facet.points.add( p6 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 1, 0, 0 ); + facet.normal = new Vector3d( 1, 0, 0 ); facets.add( facet ); } @@ -196,7 +194,7 @@ public class MeshingTest3 { facet.points.add( p2 ); facet.points.add( p6 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, -1, 0 ); + facet.normal = new Vector3d( 0, -1, 0 ); facets.add( facet ); } @@ -206,7 +204,7 @@ public class MeshingTest3 { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 0, 1, 0 ); + facet.normal = new Vector3d( 0, 1, 0 ); facets.add( facet ); } @@ -216,7 +214,7 @@ public class MeshingTest3 { facet.points.add( p3 ); facet.points.add( p7 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, 0, -1 ); + facet.normal = new Vector3d( 0, 0, -1 ); facets.add( facet ); } @@ -226,10 +224,25 @@ public class MeshingTest3 { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p6 ); - facet.normal = new Vector( 0, 0, 1 ); + facet.normal = new Vector3d( 0, 0, 1 ); facets.add( facet ); } return facets; } + + static class AABB { + double xmin, ymin, zmin; + double xmax, ymax, zmax; + + AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) { + this.xmin = xmin; + this.ymax = ymin; + this.zmin = zmin; + + this.xmax = xmax; + this.ymax = ymax; + this.zmax = zmax; + } + } } diff --git a/application/visualizer/Test4/dependency-reduced-pom.xml b/application/visualizer/Test4/dependency-reduced-pom.xml new file mode 100644 index 0000000..fb09f93 --- /dev/null +++ b/application/visualizer/Test4/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-4 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest4 + + + + + + + + diff --git a/application/visualizer/Test4/pom.xml b/application/visualizer/Test4/pom.xml new file mode 100644 index 0000000..f895433 --- /dev/null +++ b/application/visualizer/Test4/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-4 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest4 + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest4.java b/application/visualizer/Test4/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest4.java similarity index 86% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest4.java rename to application/visualizer/Test4/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest4.java index 46bfcff..dfcca9d 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest4.java +++ b/application/visualizer/Test4/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest4.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.io.BufferedReader; import java.io.File; @@ -19,18 +19,16 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.bukkit.util.Vector; - import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh; import com.aaaaahhhhhhh.bananapuncher714.mesh.Polygon; +import com.aaaaahhhhhhh.bananapuncher714.mesh.Point; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionRuleWinding; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple.GluWindingRule; -import com.aaaaahhhhhhh.bananapuncher714.minietest.MeshingTest2.AABB; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.ChunkLocation; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Facet; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.MeshBuilder; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Facet; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.MeshBuilder; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Vector3d; /** * Mesh chunk data to ply2 format @@ -98,7 +96,7 @@ public class MeshingTest4 { List< VectorRef > refs = new ArrayList< VectorRef >(); } - Map< Vector, VectorRef > vertices = new HashMap< Vector, VectorRef >(); + Map< Vector3d, VectorRef > vertices = new HashMap< Vector3d, VectorRef >(); Collection< Triangle > triangles = new HashSet< Triangle >(); // Convert each facet to a triangle @@ -108,10 +106,10 @@ public class MeshingTest4 { } final Triangle triangle = new Triangle(); - for ( final Vector vec : facet.points ) { + for ( final Vector3d vec : facet.points ) { VectorRef ref = null; - for ( final Entry< Vector, VectorRef > entry : vertices.entrySet() ) { - final Vector existingVec = entry.getKey(); + for ( final Entry< Vector3d, VectorRef > entry : vertices.entrySet() ) { + final Vector3d existingVec = entry.getKey(); if ( existingVec.distanceSquared( vec ) < 1e-8 ) { ref = entry.getValue(); @@ -130,10 +128,10 @@ public class MeshingTest4 { } // Sort the vertices - final List< Entry< Vector, VectorRef > > sorted = new ArrayList< Entry< Vector, VectorRef > >( vertices.entrySet() ); + final List< Entry< Vector3d, VectorRef > > sorted = new ArrayList< Entry< Vector3d, VectorRef > >( vertices.entrySet() ); Collections.sort( sorted, ( aEntry, bEntry ) -> { - final Vector a = aEntry.getKey(); - final Vector b = bEntry.getKey(); + final Vector3d a = aEntry.getKey(); + final Vector3d b = bEntry.getKey(); final double xDiff = a.getX() - b.getX(); if ( xDiff == 0 ) { @@ -162,10 +160,10 @@ public class MeshingTest4 { // Write vertices for ( int i = 0; i < sorted.size(); ++i ) { - final Entry< Vector, VectorRef > entry = sorted.get( i ); + final Entry< Vector3d, VectorRef > entry = sorted.get( i ); entry.getValue().index = i; - final Vector vector = entry.getKey(); + final Vector3d vector = entry.getKey(); writer.println( String.format( "%f %f %f", vector.getX(), vector.getY(), vector.getZ() ) ); } @@ -233,7 +231,7 @@ public class MeshingTest4 { private static List< Plane > mesh( File file, final StringBuilder stringBuilder ) { String name = file.getName(); String[] split = name.split( "," ); - ChunkLocation location = new ChunkLocation( split[ 0 ], Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); + Point location = new Point( Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); // First parse the file to get a list of all bounding boxes that we can use List< AABB > boxes = new ArrayList< AABB >(); @@ -317,14 +315,14 @@ public class MeshingTest4 { private static List< Facet > generateFacetsFor( AABB box ) { List< Facet > facets = new ArrayList< Facet >(); - Vector p1 = new Vector( box.xmin, box.ymin, box.zmin ); - Vector p2 = new Vector( box.xmin, box.ymin, box.zmax ); - Vector p3 = new Vector( box.xmin, box.ymax, box.zmin ); - Vector p4 = new Vector( box.xmin, box.ymax, box.zmax ); - Vector p5 = new Vector( box.xmax, box.ymin, box.zmin ); - Vector p6 = new Vector( box.xmax, box.ymin, box.zmax ); - Vector p7 = new Vector( box.xmax, box.ymax, box.zmin ); - Vector p8 = new Vector( box.xmax, box.ymax, box.zmax ); + Vector3d p1 = new Vector3d( box.xmin, box.ymin, box.zmin ); + Vector3d p2 = new Vector3d( box.xmin, box.ymin, box.zmax ); + Vector3d p3 = new Vector3d( box.xmin, box.ymax, box.zmin ); + Vector3d p4 = new Vector3d( box.xmin, box.ymax, box.zmax ); + Vector3d p5 = new Vector3d( box.xmax, box.ymin, box.zmin ); + Vector3d p6 = new Vector3d( box.xmax, box.ymin, box.zmax ); + Vector3d p7 = new Vector3d( box.xmax, box.ymax, box.zmin ); + Vector3d p8 = new Vector3d( box.xmax, box.ymax, box.zmax ); { Facet facet = new Facet(); @@ -332,7 +330,7 @@ public class MeshingTest4 { facet.points.add( p2 ); facet.points.add( p4 ); facet.points.add( p3 ); - facet.normal = new Vector( -1, 0, 0 ); + facet.normal = new Vector3d( -1, 0, 0 ); facets.add( facet ); } @@ -342,7 +340,7 @@ public class MeshingTest4 { facet.points.add( p6 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 1, 0, 0 ); + facet.normal = new Vector3d( 1, 0, 0 ); facets.add( facet ); } @@ -352,7 +350,7 @@ public class MeshingTest4 { facet.points.add( p2 ); facet.points.add( p6 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, -1, 0 ); + facet.normal = new Vector3d( 0, -1, 0 ); facets.add( facet ); } @@ -362,7 +360,7 @@ public class MeshingTest4 { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p7 ); - facet.normal = new Vector( 0, 1, 0 ); + facet.normal = new Vector3d( 0, 1, 0 ); facets.add( facet ); } @@ -372,7 +370,7 @@ public class MeshingTest4 { facet.points.add( p3 ); facet.points.add( p7 ); facet.points.add( p5 ); - facet.normal = new Vector( 0, 0, -1 ); + facet.normal = new Vector3d( 0, 0, -1 ); facets.add( facet ); } @@ -382,11 +380,25 @@ public class MeshingTest4 { facet.points.add( p4 ); facet.points.add( p8 ); facet.points.add( p6 ); - facet.normal = new Vector( 0, 0, 1 ); + facet.normal = new Vector3d( 0, 0, 1 ); facets.add( facet ); } return facets; } + static class AABB { + double xmin, ymin, zmin; + double xmax, ymax, zmax; + + AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) { + this.xmin = xmin; + this.ymax = ymin; + this.zmin = zmin; + + this.xmax = xmax; + this.ymax = ymax; + this.zmax = zmax; + } + } } diff --git a/application/visualizer/Test5/dependency-reduced-pom.xml b/application/visualizer/Test5/dependency-reduced-pom.xml new file mode 100644 index 0000000..deea201 --- /dev/null +++ b/application/visualizer/Test5/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-5 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest5 + + + + + + + + diff --git a/application/visualizer/Test5/pom.xml b/application/visualizer/Test5/pom.xml new file mode 100644 index 0000000..23b8407 --- /dev/null +++ b/application/visualizer/Test5/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-5 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest5 + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest5.java b/application/visualizer/Test5/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest5.java similarity index 91% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest5.java rename to application/visualizer/Test5/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest5.java index 6817642..232d0fc 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest5.java +++ b/application/visualizer/Test5/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest5.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.io.BufferedReader; import java.io.File; @@ -15,17 +15,16 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import org.bukkit.util.Vector; - import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh; import com.aaaaahhhhhhh.bananapuncher714.mesh.Polygon; +import com.aaaaahhhhhhh.bananapuncher714.mesh.Point; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionRuleWinding; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple.GluWindingRule; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.ChunkLocation; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Facet; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.MeshBuilder; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Facet; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.MeshBuilder; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Vector3d; /** * Mesh speed test for facets @@ -120,7 +119,7 @@ public class MeshingTest5 { private static List< Plane > mesh( File file, final StringBuilder stringBuilder ) { final String name = file.getName().substring( 0, file.getName().indexOf( '.' ) ); final String[] split = name.split( "," ); - final ChunkLocation location = new ChunkLocation( split[ 0 ], Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); + final Point location = new Point( Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); // First parse the file to get a list of all facets final List< Facet > facets = new ArrayList< Facet >(); @@ -135,7 +134,7 @@ public class MeshingTest5 { final double nz = Double.parseDouble( values[ 3 ] ); final Facet facet = new Facet(); - facet.normal = new Vector( nx, ny, nz ); + facet.normal = new Vector3d( nx, ny, nz ); int point = 0; while ( point < facetCount && ( line = reader.readLine() ) != null ) { @@ -144,7 +143,7 @@ public class MeshingTest5 { final double px = Double.parseDouble( values2[ 0 ] ); final double py = Double.parseDouble( values2[ 1 ] ); final double pz = Double.parseDouble( values2[ 2 ] ); - facet.points.add( new Vector( px, py, pz ) ); + facet.points.add( new Vector3d( px, py, pz ) ); ++point; } } diff --git a/application/visualizer/Test6/dependency-reduced-pom.xml b/application/visualizer/Test6/dependency-reduced-pom.xml new file mode 100644 index 0000000..1da9763 --- /dev/null +++ b/application/visualizer/Test6/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-6 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest6 + + + + + + + + diff --git a/application/visualizer/Test6/pom.xml b/application/visualizer/Test6/pom.xml new file mode 100644 index 0000000..cff9ab8 --- /dev/null +++ b/application/visualizer/Test6/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-6 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest6 + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest6.java b/application/visualizer/Test6/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest6.java similarity index 95% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest6.java rename to application/visualizer/Test6/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest6.java index 5ffa52d..19ae69f 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest6.java +++ b/application/visualizer/Test6/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest6.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.awt.BorderLayout; import java.awt.Color; @@ -34,8 +34,6 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; -import org.bukkit.util.Vector; - import com.aaaaahhhhhhh.bananapuncher714.mesh.Chain; import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh; import com.aaaaahhhhhhh.bananapuncher714.mesh.Mesh.MeshChainEventHandler; @@ -47,10 +45,10 @@ import com.aaaaahhhhhhh.bananapuncher714.mesh.Vector2d; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionRuleWinding; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple; import com.aaaaahhhhhhh.bananapuncher714.mesh.region.simple.RegionSimple.GluWindingRule; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.ChunkLocation; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Facet; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.MeshBuilder; -import com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Facet; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.MeshBuilder; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Plane; +import com.aaaaahhhhhhh.bananapuncher714.mesh.base.Vector3d; /** * Facet meshing visualizer @@ -169,7 +167,7 @@ public class MeshingTest6 extends JPanel { private static List< Plane > mesh( File file ) { final String name = file.getName().substring( 0, file.getName().indexOf( '.' ) ); final String[] split = name.split( "," ); - final ChunkLocation location = new ChunkLocation( split[ 0 ], Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); + final Point location = new Point( Integer.parseInt( split[ 1 ] ), Integer.parseInt( split[ 2 ] ) ); System.out.println( "Parsing chunk " + location ); @@ -186,7 +184,7 @@ public class MeshingTest6 extends JPanel { final double nz = Double.parseDouble( values[ 3 ] ); final Facet facet = new Facet(); - facet.normal = new Vector( nx, ny, nz ); + facet.normal = new Vector3d( nx, ny, nz ); int point = 0; while ( point < facetCount && ( line = reader.readLine() ) != null ) { @@ -195,7 +193,7 @@ public class MeshingTest6 extends JPanel { final double px = Double.parseDouble( values2[ 0 ] ); final double py = Double.parseDouble( values2[ 1 ] ); final double pz = Double.parseDouble( values2[ 2 ] ); - facet.points.add( new Vector( px, py, pz ) ); + facet.points.add( new Vector3d( px, py, pz ) ); ++point; } } @@ -581,8 +579,8 @@ public class MeshingTest6 extends JPanel { private static Plane getTestPlane() { final Plane plane = new Plane(); - plane.normal = new Vector( 0, 0, 1 ); - plane.point = new Vector( 1, 0, 0 ); + plane.normal = new Vector3d( 0, 0, 1 ); + plane.point = new Vector3d( 1, 0, 0 ); // plane.polygons.add( new Polygon( Arrays.asList( // new Point( 1, 0 ), diff --git a/application/visualizer/Test7/dependency-reduced-pom.xml b/application/visualizer/Test7/dependency-reduced-pom.xml new file mode 100644 index 0000000..ec40e68 --- /dev/null +++ b/application/visualizer/Test7/dependency-reduced-pom.xml @@ -0,0 +1,47 @@ + + + + mc-mesh-application-visualizer + com.aaaaahhhhhhh.bananapuncher714 + 0.0.1 + + 4.0.0 + mc-mesh-application-visualizer-test-7 + 0.0.1 + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + maven-compiler-plugin + 3.14.1 + + 8 + + + + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest7 + + + + + + + + diff --git a/application/visualizer/Test7/pom.xml b/application/visualizer/Test7/pom.xml new file mode 100644 index 0000000..f5ed28a --- /dev/null +++ b/application/visualizer/Test7/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application-visualizer + 0.0.1 + + mc-mesh-application-visualizer-test-7 + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + compile + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-base + 0.0.1 + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + true + com.aaaaahhhhhhh.bananapuncher714.mesh.test.MeshingTest7 + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest7.java b/application/visualizer/Test7/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest7.java similarity index 98% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest7.java rename to application/visualizer/Test7/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest7.java index 050f7ca..9ead6f6 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/MeshingTest7.java +++ b/application/visualizer/Test7/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/test/MeshingTest7.java @@ -1,4 +1,4 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest; +package com.aaaaahhhhhhh.bananapuncher714.mesh.test; import java.io.BufferedReader; import java.io.File; diff --git a/application/visualizer/pom.xml b/application/visualizer/pom.xml new file mode 100644 index 0000000..deadf1d --- /dev/null +++ b/application/visualizer/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-application + 0.0.1 + + mc-mesh-application-visualizer + 0.0.1 + pom + + + Test1 + Test2 + Test3 + Test4 + Test5 + Test6 + Test7 + + \ No newline at end of file diff --git a/base/pom.xml b/base/pom.xml new file mode 100644 index 0000000..e515818 --- /dev/null +++ b/base/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-master + 1.0.0 + + mc-mesh-base + 0.0.1 + + + + com.aaaaahhhhhhh.bananapuncher714 + mc-mesh-core + 0.0.1 + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + + + + \ No newline at end of file diff --git a/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Facet.java b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Facet.java new file mode 100644 index 0000000..0c3840b --- /dev/null +++ b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Facet.java @@ -0,0 +1,9 @@ +package com.aaaaahhhhhhh.bananapuncher714.mesh.base; + +import java.util.ArrayList; +import java.util.List; + +public class Facet { + public Vector3d normal; + public List< Vector3d > points = new ArrayList< Vector3d >(); +} diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/LineSegment.java b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/LineSegment.java similarity index 77% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/LineSegment.java rename to base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/LineSegment.java index fba5bb9..5dd718d 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/LineSegment.java +++ b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/LineSegment.java @@ -1,11 +1,9 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh; - -import org.bukkit.util.Vector; +package com.aaaaahhhhhhh.bananapuncher714.mesh.base; public class LineSegment { - public Vector point1, point2; + public Vector3d point1, point2; - public LineSegment( Vector point1, Vector point2 ) { + public LineSegment( Vector3d point1, Vector3d point2 ) { if ( point1.getX() < point2.getX() ) { this.point1 = point1; this.point2 = point2; @@ -39,7 +37,7 @@ public class LineSegment { return point1.distance( point2 ); } - public Vector getVector() { - return point2.clone().subtract( point1 ); + public Vector3d getVector() { + return new Vector3d( point2 ).subtract( point1 ); } } diff --git a/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Matrix3d.java b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Matrix3d.java new file mode 100644 index 0000000..72f4e82 --- /dev/null +++ b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Matrix3d.java @@ -0,0 +1,19 @@ +package com.aaaaahhhhhhh.bananapuncher714.mesh.base; + +public class Matrix3d { + protected Vector3d[] rows = new Vector3d[ 3 ]; + + public Matrix3d( Vector3d col1, Vector3d col2, Vector3d col3 ) { + rows[ 0 ] = new Vector3d( col1.getX(), col2.getX(), col3.getX() ); + rows[ 1 ] = new Vector3d( col1.getY(), col2.getY(), col3.getY() ); + rows[ 2 ] = new Vector3d( col1.getZ(), col2.getZ(), col3.getZ() ); + } + + public Matrix3d transpose() { + return new Matrix3d( + rows[ 0 ], + rows[ 1 ], + rows[ 2 ] + ); + } +} \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/MeshBuilder.java b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/MeshBuilder.java similarity index 66% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/MeshBuilder.java rename to base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/MeshBuilder.java index 4084684..7cf5d30 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/MeshBuilder.java +++ b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/MeshBuilder.java @@ -1,11 +1,9 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh; +package com.aaaaahhhhhhh.bananapuncher714.mesh.base; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import org.bukkit.util.Vector; - public class MeshBuilder { public List< Plane > planes = new ArrayList< Plane >(); @@ -19,9 +17,9 @@ public class MeshBuilder { Plane plane = new Plane(); plane.normal = facet.normal; - Optional< Vector > ref = facet.points.stream().filter( v -> v.lengthSquared() > 0.001 && Math.abs( v.clone().normalize().dot( facet.normal ) ) < .999999 ).findAny(); + Optional< Vector3d > ref = facet.points.stream().filter( v -> v.lengthSquared() > 0.001 && Math.abs( new Vector3d( v ).normalize().dot( facet.normal ) ) < .999999 ).findAny(); if ( ref.isPresent() ) { - plane.point = ref.get(); + plane.point = ref.get(); } plane.addShape( facet ); planes.add( plane ); diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/Plane.java b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Plane.java similarity index 63% rename from plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/Plane.java rename to base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Plane.java index df6d965..1265d61 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/Plane.java +++ b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Plane.java @@ -1,20 +1,16 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh; +package com.aaaaahhhhhhh.bananapuncher714.mesh.base; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -import org.bukkit.util.Vector; -import org.joml.Matrix3d; -import org.joml.Vector3d; - import com.aaaaahhhhhhh.bananapuncher714.mesh.Point; import com.aaaaahhhhhhh.bananapuncher714.mesh.Polygon; public class Plane { - public Vector normal; - public Vector point; + public Vector3d normal; + public Vector3d point; public double distance; private boolean set = false; @@ -28,21 +24,17 @@ public class Plane { final Matrix3d mat = getProjectionMatrix(); List< Point > polygon = new ArrayList< Point >(); - for ( Vector p : facet.points ) { - double t = point.clone().subtract( p ).dot( normal ); - Vector i = normal.clone().multiply( t ).add( p ); - - Vector3d v = new Vector3d( i.getX(), i.getY(), i.getZ() ); - - Vector3d r = v.mul( mat ); + for ( Vector3d p : facet.points ) { + double t = new Vector3d( point ).subtract( p ).dot( normal ); + Vector3d r = new Vector3d( normal ).multiply( t ).add( p ).multiply( mat ); - polygon.add( new Point( r.x(), r.y() ) ); + polygon.add( new Point( r.getX(), r.getY() ) ); if ( !set ) { - distance = r.z(); + distance = r.getZ(); set = true; - } else if ( Math.abs( r.z() - distance ) > 1e-7 ) { + } else if ( Math.abs( r.getZ() - distance ) > 1e-7 ) { throw new IllegalStateException( "Bad point in facet!" ); } } @@ -50,12 +42,12 @@ public class Plane { polygons.add( new Polygon( polygon ) ); } - public Vector convert( final Point p ) { + public Vector3d convert( final Point p ) { final Vector3d plane = new Vector3d( p.getX(), p.getY(), distance ); - final Vector3d res = plane.mul( getInverseProjectionMatrix() ); + final Vector3d res = plane.multiply( getInverseProjectionMatrix() ); - return new Vector( res.x(), res.y(), res.z() ); + return res; } public Facet convert( final Polygon polygon ) { @@ -73,14 +65,13 @@ public class Plane { return polygons.parallelStream().map( this::convert ).collect( Collectors.toSet() ); } - public boolean matches( Vector normal, Vector point ) { - return Math.abs( this.normal.dot( normal ) ) > 0.99 && Math.abs( this.point.clone().subtract( point ).dot( normal ) ) < 0.01; + public boolean matches( Vector3d normal, Vector3d point ) { + return Math.abs( this.normal.dot( normal ) ) > 0.99 && Math.abs( new Vector3d( this.point ).subtract( point ).dot( normal ) ) < 0.01; } private Matrix3d getProjectionMatrix() { if ( mat == null ) { - final Vector basis1 = normal.clone().multiply( point.clone().multiply( -1 ).dot( normal ) ).add( point ).normalize(); - final Vector3d b1 = new Vector3d( basis1.getX(), basis1.getY(), basis1.getZ() ); + final Vector3d b1 = new Vector3d( normal ).multiply( new Vector3d( point ).multiply( -1 ).dot( normal ) ).add( point ).normalize(); final Vector3d b3 = new Vector3d( normal.getX(), normal.getY(), normal.getZ() ); final Vector3d b2 = new Vector3d( b1 ).cross( b3 ).normalize(); mat = new Matrix3d( b1, b2, b3 ).transpose(); diff --git a/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Vector3d.java b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Vector3d.java new file mode 100644 index 0000000..95ca948 --- /dev/null +++ b/base/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/base/Vector3d.java @@ -0,0 +1,138 @@ +package com.aaaaahhhhhhh.bananapuncher714.mesh.base; + +public class Vector3d { + private double x, y, z; + + public Vector3d( double x, double y, double z ) { + this.x = x; + this.y = y; + this.z = z; + } + + public Vector3d( Vector3d copy ) { + this.x = copy.x; + this.y = copy.y; + this.z = copy.z; + } + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public double getZ() { + return z; + } + + public void setX( double x ) { + this.x = x; + } + + public void setY( double y ) { + this.y = y; + } + + public void setZ( double z ) { + this.z = z; + } + + public double dot( Vector3d o ) { + return x * o.x + y * o.y + z * o.z; + } + + public Vector3d cross( Vector3d o ) { + return new Vector3d( + y * o.z - o.y * z, + z * o.x - o.z * x, + x * o.y - o.x * y + ); + } + + public double length() { + return Math.sqrt( lengthSquared() ); + } + + public double lengthSquared() { + return dot( this ); + } + + public Vector3d normalize() { + double length = length(); + + x /= length; + y /= length; + z /= length; + + return this; + } + + public Vector3d multiply( Matrix3d mat ) { + return new Vector3d( + dot( mat.rows[ 0 ] ), + dot( mat.rows[ 1 ] ), + dot( mat.rows[ 2 ] ) + ); + } + + public Vector3d multiply( double v ) { + x *= v; + y *= v; + z *= v; + + return this; + } + + public Vector3d add( double v ) { + x += v; + y += v; + z += v; + + return this; + } + + public Vector3d add( Vector3d o ) { + x += o.x; + y += o.y; + z += o.z; + + return this; + } + + public Vector3d subtract( Vector3d o ) { + x -= o.x; + y -= o.y; + z -= o.z; + + return this; + } + + public double distance( Vector3d o ) { + return new Vector3d( this ).subtract( o ).length(); + } + + public double distanceSquared( Vector3d o ) { + return new Vector3d( this ).subtract( o ).lengthSquared(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(x); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(y); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(z); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + return "Vector3d{x=" + x + ",y=" + y + ",z=" + z + "}"; + } +} \ No newline at end of file diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/Facet.java b/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/Facet.java deleted file mode 100644 index 913a494..0000000 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/objects/mesh/Facet.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.aaaaahhhhhhh.bananapuncher714.minietest.objects.mesh; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.util.Vector; - -public class Facet { - public Vector normal; - public List< Vector > points = new ArrayList< Vector >(); -} diff --git a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/util/BinaryWriter.java b/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/util/BinaryWriter.java index 963cf2c..dee06d2 100644 --- a/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/util/BinaryWriter.java +++ b/plugin/src/main/java/com/aaaaahhhhhhh/bananapuncher714/minietest/util/BinaryWriter.java @@ -2,7 +2,6 @@ package com.aaaaahhhhhhh.bananapuncher714.minietest.util; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; -import java.util.Arrays; /** * Big/little endian binary writer diff --git a/pom.xml b/pom.xml index 18786ed..d4e0e77 100644 --- a/pom.xml +++ b/pom.xml @@ -9,8 +9,10 @@ pom - plugin + core + base + application