创建对象TriangulatedMesh时出错

问题描述 投票:0回答:1

enter image description here我想创建一个字母T形式的图形当我用这些要点创建对象时,异常会掉落有人遇到过这个吗?我使用FXyz3D

final List<Point3D> points = new ArrayList<>(//I am trying to create an array of points (x, y, 0)
Arrays.asList(
new Point3D(0,150,0),
new Point3D(0, 90,0),
new Point3D(10,90,0),
new Point3D(30,90,0),
new Point3D(40,90,0),
new Point3D(10,0,0),
new Point3D(30,0,0),
new Point3D(40,150,0))
            );
TriangulatedMesh customShape = new 
TriangulatedMesh(points,20);//Exception falls on this place

这是运行程序时的控制台输出

我不明白是什么问题。

Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: Intersecting Constraints
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:657)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.edgeEvent(DTSweep.java:631)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.edgeEvent(DTSweep.java:626)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.edgeEvent(DTSweep.java:348)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.sweep(DTSweep.java:110)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.triangulate(DTSweep.java:72)
	at org.poly2tri.Poly2Tri.triangulate(Poly2Tri.java:108)
	at org.poly2tri.Poly2Tri.triangulate(Poly2Tri.java:60)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.createMesh(TriangulatedMesh.java:285)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.createMesh(TriangulatedMesh.java:218)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.updateMesh(TriangulatedMesh.java:112)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:103)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:93)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:90)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:82)
	at sampleFxyz3D.Sample.start(Sample.java:89)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
	... 1 more
Exception running application sampleFxyz3D.Sample
java javafx geometry javafx-8 javafx-3d
1个回答
0
投票
final List<Point3D> points = new ArrayList<>(Arrays.asList(

            new Point3D(0, 90,0),
            new Point3D(0,150,0),

            new Point3D(40,150,0),
            new Point3D(40,90,0),

            new Point3D(30,90,0),
            new Point3D(30,0,0),

            new Point3D(10,0,0),
            new Point3D(10,90,0)
    )
            );

重要的是,点必须形成闭合的多边形。

© www.soinside.com 2019 - 2024. All rights reserved.