/** * Note that calling this method will clear the palette when {@link #autoClear} is equal to true. */ @Override public Image getColorPalette() { WritableImage ret = colorPalette; if (PRINT_PALETTE) { // save for testing purposes try { ImageIO.write(SwingFXUtils.fromFXImage(colorPalette, null), "png", new File("palette.png")); } catch (IOException ex) { ex.printStackTrace(); } } if (autoClear) clearPalette(); return ret; } }
/** * Note that calling this method will clear the palette when {@link #autoClear} is equal to true. */ @Override public Image getColorPalette() { WritableImage ret = colorPalette; if (PRINT_PALETTE) { // save for testing purposes try { ImageIO.write(SwingFXUtils.fromFXImage(colorPalette, null), "png", new File("palette.png")); } catch (IOException ex) { ex.printStackTrace(); } } if (autoClear) clearPalette(); return ret; } }
private void processBodyPath(List<? extends Point3DReadOnly> bodyPath) { if (bodyPath == null || bodyPath.isEmpty()) { bodyPathMeshToRender.set(new Pair<>(null, null)); activeBodyPathReference.set(null); if (VERBOSE) 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); }
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); }
private void processOccupancyMapMessage(FootstepPlannerOccupancyMapMessage message) { palette.clearPalette(); JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(palette); Object<FootstepPlannerCellMessage> occupiedCells = message.getOccupiedCells(); for (int i = 0; i < occupiedCells.size(); i++) { FootstepPlannerCellMessage cell = occupiedCells.get(i); double x = cell.getXIndex() * FootstepNode.gridSizeXY; double y = cell.getYIndex() * FootstepNode.gridSizeXY; double z = getHeightAtPoint(x, y) + nodeOffsetZ; RigidBodyTransform transform = new RigidBodyTransform(); transform.setTranslation(x, y, z); if (cell.getNodeIsValid()) meshBuilder.addPolygon(transform, cellPolygon, validCellColor); else meshBuilder.addPolygon(transform, cellPolygon, rejectedCellColor); } footstepGraphToRender.set(new Pair<>(meshBuilder.generateMesh(), meshBuilder.generateMaterial())); }