/** * Add a 3D line with a color gradient to this builder. * @param x0 x-coordinate of the line start. * @param y0 y-coordinate of the line start. * @param z0 z-coordinate of the line start. * @param xf x-coordinate of the line end. * @param yf y-coordinate of the line end. * @param zf z-coordinate of the line end. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(double x0, double y0, double z0, double xf, double yf, double zf, double lineWidth, Color startColor, Color endColor) { addLine((float) x0, (float) y0, (float) z0, (float) xf, (float) yf, (float) zf, (float) lineWidth, startColor, endColor); }
/** * Add a 3D line with a color gradient to this builder. * @param x0 x-coordinate of the line start. * @param y0 y-coordinate of the line start. * @param z0 z-coordinate of the line start. * @param xf x-coordinate of the line end. * @param yf y-coordinate of the line end. * @param zf z-coordinate of the line end. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(double x0, double y0, double z0, double xf, double yf, double zf, double lineWidth, Color startColor, Color endColor) { addLine((float) x0, (float) y0, (float) z0, (float) xf, (float) yf, (float) zf, (float) lineWidth, startColor, endColor); }
/** * Add a series of connected 3D lines to this builder. * @param points coordinates of the line end points. Not modified. * @param lineWidth width of the lines. * @param color color of the multi-line. Color accuracy depends on the color palette in use. * @param close whether the end of the given array of points should be connected to the beginning or not. */ public void addMultiLine(Point3DReadOnly[] points, double lineWidth, Color color, boolean close) { if (points.length < 2) return; for (int i = 1; i < points.length; i++) { Point3DReadOnly start = points[i - 1]; Point3DReadOnly end = points[i]; addLine(start, end, lineWidth, color); } if (close) { Point3DReadOnly start = points[points.length - 1]; Point3DReadOnly end = points[0]; addLine(start, end, lineWidth, color); } }
/** * Add a series of connected 3D lines to this builder. * @param points coordinates of the line end points. Not modified. * @param lineWidth width of the lines. * @param color color of the multi-line. Color accuracy depends on the color palette in use. * @param close whether the end of the given array of points should be connected to the beginning or not. */ public void addMultiLine(List<? extends Point3DReadOnly> points, double lineWidth, Color color, boolean close) { if (points.size() < 2) return; for (int i = 1; i < points.size(); i++) { Point3DReadOnly start = points.get(i - 1); Point3DReadOnly end = points.get(i); addLine(start, end, lineWidth, color); } if (close) { Point3DReadOnly start = points.get(points.size() - 1); Point3DReadOnly end = points.get(0); addLine(start, end, lineWidth, color); } }
/** * Add a series of connected 3D lines to this builder. * @param points coordinates of the line end points. Not modified. * @param lineWidth width of the lines. * @param color color of the multi-line. Color accuracy depends on the color palette in use. * @param close whether the end of the given array of points should be connected to the beginning or not. */ public void addMultiLine(List<Point3d> points, double lineWidth, Color color, boolean close) { if (points.size() < 2) return; for (int i = 1; i < points.size(); i++) { Point3d start = points.get(i - 1); Point3d end = points.get(i); addLine(start, end, lineWidth, color); } if (close) { Point3d start = points.get(points.size() - 1); Point3d end = points.get(0); addLine(start, end, lineWidth, color); } }
private void addLine(JavaFXMultiColorMeshBuilder meshBuilder) { Point3d start = new Point3d(0.3, 0.0, -0.); Point3d end = new Point3d(0.0, 0.3, 0.0); double lineWidth = 0.01; Color color = Color.RED; meshBuilder.addLine(start, end, lineWidth, color); }
private void processBodyPath(List<Point3DReadOnly> bodyPath) { if (bodyPath == null || bodyPath.isEmpty()) { bodyPathMeshToRender.set(new Pair<>(null, null)); activeBodyPathReference.set(null); PrintTools.warn("Received body path that is null."); return; } // First let's make a deep copy for later usage. bodyPath = bodyPath.stream().map(Point3D::new).collect(Collectors.toList()); if (VERBOSE) PrintTools.info(this, "Building mesh for body path."); double totalPathLength = PathTools.computePathLength(bodyPath); double currentLength = 0.0; palette.clearPalette(); JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(palette); for (int segmentIndex = 0; segmentIndex < bodyPath.size() - 1; segmentIndex++) { Point3DReadOnly lineStart = bodyPath.get(segmentIndex); Point3DReadOnly lineEnd = bodyPath.get(segmentIndex + 1); double lineStartHue = EuclidCoreTools.interpolate(startColorHue, goalColorHue, currentLength / totalPathLength); currentLength += lineStart.distance(lineEnd); double lineEndHue = EuclidCoreTools.interpolate(startColorHue, goalColorHue, currentLength / totalPathLength); meshBuilder.addLine(lineStart, lineEnd, BODYPATH_LINE_THICKNESS, Color.hsb(lineStartHue, 1.0, 0.5), Color.hsb(lineEndHue, 1.0, 1.0)); } bodyPathMeshToRender.set(new Pair<>(meshBuilder.generateMesh(), meshBuilder.generateMaterial())); activeBodyPathReference.set(bodyPath); currentWalkerDistanceInPath.set(0.0); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param color color of the line. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3f start, Tuple3f end, float lineWidth, Color color) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, color); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param color color of the line. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3DReadOnly start, Tuple3DReadOnly end, float lineWidth, Color color) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, color); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param color color of the line. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3d start, Tuple3d end, double lineWidth, Color color) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, color); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3DReadOnly start, Tuple3DReadOnly end, double lineWidth, Color startColor, Color endColor) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, startColor, endColor); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3DReadOnly start, Tuple3DReadOnly end, float lineWidth, Color startColor, Color endColor) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, startColor, endColor); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param color color of the line. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3DReadOnly start, Tuple3DReadOnly end, double lineWidth, Color color) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, color); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3d start, Tuple3d end, double lineWidth, Color startColor, Color endColor) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, startColor, endColor); }
/** * Add a 3D line to this builder. * @param start start coordinate of the line. Not modified. * @param end end coordinate of the line. Not modified. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(Tuple3f start, Tuple3f end, float lineWidth, Color startColor, Color endColor) { addLine(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), lineWidth, startColor, endColor); }
private Node createPriorityQueueGraphics(PlanarRegionSegmentationRawData rawData, ConcaveHullFactoryResult concaveHullFactoryResult) { JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(512)); Point3D planeOrigin = rawData.getOrigin(); Quaternion planeOrientation = rawData.getOrientation(); Color regionColor = OcTreeMeshBuilder.getRegionColor(rawData.getRegionId()); for (ConcaveHullVariables intermediateVariables : concaveHullFactoryResult.getIntermediateVariables()) { PriorityQueue<Pair<QuadEdge, QuadEdgeTriangle>> queue = intermediateVariables.getSortedByLengthQueue(); for (Pair<QuadEdge, QuadEdgeTriangle> edgeAndTriangle : queue) { QuadEdge edge = edgeAndTriangle.getLeft(); Point3D dest = PolygonizerTools.toPointInWorld(edge.dest().getX(), edge.dest().getY(), planeOrigin, planeOrientation); Point3D orig = PolygonizerTools.toPointInWorld(edge.orig().getX(), edge.orig().getY(), planeOrigin, planeOrientation); boolean isEdgeTooLong = dest.distance(orig) > parameters.getEdgeLengthThreshold(); Color lineColor = Color.hsb(regionColor.getHue(), regionColor.getSaturation(), isEdgeTooLong ? 0.25 : regionColor.getBrightness()); meshBuilder.addLine(dest, orig, 0.0015, lineColor); QuadEdgeTriangle triangle = edgeAndTriangle.getRight(); List<Point2D> triangleVerticesLocal = Arrays.stream(triangle.getVertices()).map(v -> new Point2D(v.getX(), v.getY())).collect(Collectors.toList()); List<Point3D> triangleVerticesWorld = PolygonizerTools.toPointsInWorld(triangleVerticesLocal, planeOrigin, planeOrientation); double hue = 360.0 * random.nextDouble(); double saturation = 0.8 * random.nextDouble() + 0.1; double brightness = 0.9; meshBuilder.addPolyon(triangleVerticesWorld, Color.hsb(hue, saturation, brightness)); } } MeshView trianglesMeshView = new MeshView(meshBuilder.generateMesh()); trianglesMeshView.setMaterial(meshBuilder.generateMaterial()); return trianglesMeshView; }
private Node createIntersectionsGraphics(PlanarRegionSegmentationRawData rawData) { JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(32)); List<LineSegment2D> intersections2d = rawData.getIntersections(); Point3D planeOrigin = rawData.getOrigin(); Vector3D planeNormal = rawData.getNormal(); List<LineSegment3D> intersections = PolygonizerTools.toLineSegmentsInWorld(intersections2d, planeOrigin, planeNormal); for (LineSegment3D intersection : intersections) { meshBuilder.addLine(intersection.getFirstEndpoint(), intersection.getSecondEndpoint(), 0.0025, Color.RED); } MeshView meshView = new MeshView(meshBuilder.generateMesh()); meshView.setMaterial(meshBuilder.generateMaterial()); meshView.visibleProperty().bind(showIntersections); return meshView; }
@SuppressWarnings("unchecked") private static Node createPrimaryEdgesGraphics(QuadEdgeSubdivision quadEdgeSubdivision, PlanarRegionSegmentationRawData rawData) { List<QuadEdge> primaryEdges = (List<QuadEdge>) quadEdgeSubdivision.getPrimaryEdges(false); int regionId = rawData.getRegionId(); JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(16)); Point3D planeOrigin = rawData.getOrigin(); Quaternion planeOrientation = rawData.getOrientation(); Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId); for (QuadEdge edge : primaryEdges) { Point3D dest = PolygonizerTools.toPointInWorld(edge.dest().getX(), edge.dest().getY(), planeOrigin, planeOrientation); Point3D orig = PolygonizerTools.toPointInWorld(edge.orig().getX(), edge.orig().getY(), planeOrigin, planeOrientation); meshBuilder.addLine(dest, orig, 0.0015, regionColor); } MeshView meshView = new MeshView(meshBuilder.generateMesh()); meshView.setMaterial(meshBuilder.generateMaterial()); meshView.setMouseTransparent(true); return meshView; }
@SuppressWarnings("unchecked") private static Node createEdgesGraphics(QuadEdgeSubdivision quadEdgeSubdivision, PlanarRegionSegmentationRawData rawData) { List<QuadEdge> edges = (List<QuadEdge>) quadEdgeSubdivision.getEdges(); int regionId = rawData.getRegionId(); JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(16)); Point3D planeOrigin = rawData.getOrigin(); Quaternion planeOrientation = rawData.getOrientation(); Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId); for (QuadEdge edge : edges) { Point3D dest = PolygonizerTools.toPointInWorld(edge.dest().getX(), edge.dest().getY(), planeOrigin, planeOrientation); Point3D orig = PolygonizerTools.toPointInWorld(edge.orig().getX(), edge.orig().getY(), planeOrigin, planeOrientation); meshBuilder.addLine(dest, orig, 0.0015, regionColor); } MeshView meshView = new MeshView(meshBuilder.generateMesh()); meshView.setMaterial(meshBuilder.generateMaterial()); meshView.setMouseTransparent(true); return meshView; }
private Node createBorderEdgesGraphics(PlanarRegionSegmentationRawData rawData, ConcaveHullFactoryResult concaveHullFactoryResult) { int regionId = rawData.getRegionId(); JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(16)); Point3D planeOrigin = rawData.getOrigin(); Quaternion planeOrientation = rawData.getOrientation(); Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId); for (ConcaveHullVariables intermediateVariables : concaveHullFactoryResult.getIntermediateVariables()) { Set<QuadEdge> borderEdges = intermediateVariables.getBorderEdges(); for (QuadEdge edge : borderEdges) { Point3D dest = PolygonizerTools.toPointInWorld(edge.dest().getX(), edge.dest().getY(), planeOrigin, planeOrientation); Point3D orig = PolygonizerTools.toPointInWorld(edge.orig().getX(), edge.orig().getY(), planeOrigin, planeOrientation); boolean isEdgeTooLong = dest.distance(orig) > parameters.getEdgeLengthThreshold(); Color lineColor = Color.hsb(regionColor.getHue(), regionColor.getSaturation(), isEdgeTooLong ? 0.25 : regionColor.getBrightness()); meshBuilder.addLine(dest, orig, 0.0015, lineColor); } } MeshView meshView = new MeshView(meshBuilder.generateMesh()); meshView.setMaterial(meshBuilder.generateMaterial()); meshView.setMouseTransparent(true); return meshView; }