public static Graphics3DAddMeshDataInstruction createMeshDataInstruction(MeshDataHolder meshData, AppearanceDefinition meshAppearance) { if (meshData == null) { meshData = new MeshDataHolder(new Point3D32[0], new TexCoord2f[0], new int[0], new Vector3D32[0]); meshData.setName("nullMesh"); } Graphics3DAddMeshDataInstruction instruction = new Graphics3DAddMeshDataInstruction(meshData, meshAppearance); return instruction; }
@Override public void update() { if (numberOfPoints.getIntegerValue() < 3) { instruction.setMesh(EMPTY_MESH); return; } for (int i = 0; i < numberOfPoints.getIntegerValue(); i++) ccwOrderedPoints.get(i).set(ccwOrderedYoFramePoints[i]); instruction.setMesh(MeshDataGenerator.Polygon(ccwOrderedPoints, numberOfPoints.getIntegerValue())); instruction.setAppearance(appearance); }
@Override protected void doAddMeshDataInstruction(final Graphics3DAddMeshDataInstruction graphics3dObjectAddMeshData) MeshDataHolder meshData = graphics3dObjectAddMeshData.getMeshData(); AppearanceDefinition appearance = graphics3dObjectAddMeshData.getAppearance(); graphics3dObjectAddMeshData.setMeshChangedListener(new MeshChangedListener()
@Override protected void doAddMeshDataInstruction(Graphics3DAddMeshDataInstruction graphics3DAddMeshData) { graphics3DAddMeshData.getMeshData().getVertices(); TriangleMesh outputMesh = interpretMeshData(graphics3DAddMeshData.getMeshData()); Material outputMaterial = convertMaterial(graphics3DAddMeshData.getAppearance()); MeshView meshView = new MeshView(); meshView.setMesh(outputMesh); meshView.setMaterial(outputMaterial); Group meshGroup = new Group(meshView); currentGroup.getChildren().add(meshGroup); currentGroup = meshGroup; }
public Graphics3DAddMeshDataInstruction(MeshDataHolder meshData, AppearanceDefinition appearance) { this.meshData = meshData; setAppearance(appearance); }
@Override public void update() { if (hasChanged.getAndSet(false)) { if ((!pointOne.containsNaN()) && (!pointTwo.containsNaN()) && (!pointThree.containsNaN())) { instruction.setMesh(MeshDataGenerator.Polygon(new Point3DReadOnly[] { pointOne, pointTwo, pointThree })); } else { instruction.setMesh(null); } } }
@Override protected void doAddMeshDataInstruction(final Graphics3DAddMeshDataInstruction graphics3dObjectAddMeshData) MeshDataHolder meshData = graphics3dObjectAddMeshData.getMeshData(); AppearanceDefinition appearance = graphics3dObjectAddMeshData.getAppearance(); graphics3dObjectAddMeshData.setMeshChangedListener(new MeshChangedListener()
public Graphics3DAddMeshDataInstruction(MeshDataHolder meshData, AppearanceDefinition appearance) { this.meshData = meshData; setAppearance(appearance); }
@Override public void update() { verticesToDisplay.clear(); for (int i = yoFrameConvexPolygon2d.getNumberOfVertices() - 1; i >= 0; i--) { /* * Using the unsafe getter as this instance of the polygon might not be * recognized as up-to-date. This can occur when displaying a remote * YoGraphic. In such scenario, the coordinates of the vertices are * updated under the hood and this polygon only serves as a data * holder. */ verticesToDisplay.add(yoFrameConvexPolygon2d.getVertexUnsafe(i)); } instruction.setMesh(MeshDataGenerator.ExtrudedPolygon(verticesToDisplay, height)); }
/** * Update the mesh that will display a portion of the {@link PlanarRegionsList} being processed. * This method only reads the YoVariables to update the mesh. * * When used as a remote YoGraphic, only this method should be called. */ @Override public void update() { if (yoGraphicJob == YoGraphicJob.READER) { // Notify the updater that a reader exists and the updater must synchronize. waitForReader.set(true); hasReaderProcessedMesh.set(true); } if (currentMeshIndex.getIntegerValue() == -1) return; MeshDataHolder polygonMesh = createCurrentMesh(); polygonMesh.setName("PlanarRegion"); AppearanceDefinition appearance = getCurrentAppearance(); Graphics3DAddMeshDataInstruction instructionToUpdate = meshBuffer.get(currentMeshIndex.getIntegerValue()); instructionToUpdate.setMesh(polygonMesh); instructionToUpdate.setAppearance(appearance); if (isPlanarRegionsListComplete.getBooleanValue()) { // Clear the rest of meshes that are not needed. for (int meshIndex = currentMeshIndex.getIntegerValue() + 1; meshIndex < meshBufferSize; meshIndex++) meshBuffer.get(meshIndex).setMesh(null); } }
public static Graphics3DAddMeshDataInstruction createMeshDataInstruction(MeshDataHolder meshData, AppearanceDefinition meshAppearance) { if (meshData == null) { meshData = new MeshDataHolder(new Point3f[0], new TexCoord2f[0], new int[0], new Vector3f[0]); meshData.setName("nullMesh"); } Graphics3DAddMeshDataInstruction instruction = new Graphics3DAddMeshDataInstruction(meshData, meshAppearance); return instruction; }
public void updateAppearance(AppearanceDefinition appearance) { instruction.setAppearance(appearance); }
@Override public void update() { if (yoFrameConvexPolygon2d.getHasChangedAndReset()) { instruction.setMesh(MeshDataGenerator.ExtrudedPolygon(yoFrameConvexPolygon2d.getConvexPolygon2d(), height)); } }
meshBuffer.get(meshIndex).setMesh(null); clear.set(false); return; meshBuffer.get(meshIndex).setMesh(null); if (!waitForReader.getBooleanValue()) clear.set(false); instructionToUpdate.setMesh(polygonMesh); instructionToUpdate.setAppearance(appearance); meshBuffer.get(meshIndex).setMesh(null);
public YoGraphicPolygon3D(String name, YoInteger numberOfPoints, YoFramePoint3D[] ccwOrderedYoFramePoints, double height, AppearanceDefinition appearance) { super(name); this.numberOfPoints = numberOfPoints; this.ccwOrderedYoFramePoints = ccwOrderedYoFramePoints; ccwOrderedPoints = new ArrayList<>(ccwOrderedYoFramePoints.length); for (int i = 0; i < ccwOrderedYoFramePoints.length; i++) ccwOrderedPoints.add(new Point3D()); this.height = height; this.appearance = appearance; graphics3dObject = new Graphics3DObject(); graphics3dObject.setChangeable(true); instruction = new Graphics3DAddMeshDataInstruction(EMPTY_MESH, appearance); graphics3dObject.addInstruction(instruction); }
public void updateAppearance(AppearanceDefinition appearance) { instruction.setAppearance(appearance); }
@Override public void update() { if (hasChanged.getAndSet(false)) { if ((!pointOne.containsNaN()) && (!pointTwo.containsNaN()) && (!pointThree.containsNaN())) { instruction.setMesh(MeshDataGenerator.Polygon(new Point3d[] { pointOne.getPoint3dCopy(), pointTwo.getPoint3dCopy(), pointThree.getPoint3dCopy() })); } else { instruction.setMesh(null); } } }
meshDataInstruction.setMesh(null); dirtyGraphic.set(false); return; meshDataInstruction.setAppearance(BLACK_APPEARANCE); break; case VELOCITY_BASED: graphics3DAddMeshDataInstructions[i].setAppearance(colorPalette[colorIndex]); graphics3DAddMeshDataInstructions[i].setAppearance(colorPalette[colorIndex]); segmentedLine3DMeshGenerator.compute(intermediatePositions, intermediateVelocities); for (int i = 0; i < resolution - 1; i++) graphics3DAddMeshDataInstructions[i].setMesh(segmentedLine3DMeshGenerator.getMeshDataHolders()[i]); break; pointCloud3DMeshGenerator.compute(intermediatePositions); for (int i = 0; i < resolution - 1; i++) graphics3DAddMeshDataInstructions[i].setMesh(pointCloud3DMeshGenerator.getMeshDataHolders()[i]); break; default:
public void addPolygons(RigidBodyTransform transform, List<? extends ConvexPolygon2DReadOnly> convexPolygon2D, AppearanceDefinition appearance) { transform(transform); for (int i = 0; i < convexPolygon2D.size(); i++) { ConvexPolygon2DReadOnly convexPolygon = convexPolygon2D.get(i); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(convexPolygon, -0.0001); addInstruction(new Graphics3DAddMeshDataInstruction(meshDataHolder, appearance)); } transform = new RigidBodyTransform(transform); transform.invert(); transform(transform); }
private YoGraphicPolygon(String name, YoVariable<?>[] yoVariables, double[] constants, AppearanceDefinition appearance) { /* * 2 * (int) constants[1] + 1 => constants[1] is the size of the 2D vertex * buffer so we have 2 * YoVariables, the "+ 1" is for the YoInteger that * keeps track of the actual polygon size. */ super(name, Arrays.copyOfRange(yoVariables, 2 * (int) constants[1] + 1, yoVariables.length), constants[0]); int constantIndex = 1; // 0 corresponds to the scale factor int vertexBufferSize = (int) constants[constantIndex++]; // Ensuring backward compatibility this.height = constants.length == 3 ? constants[constantIndex++] : DEFAULT_HEIGHT; int yoIndex = 0; YoInteger numberOfVertices = (YoInteger) yoVariables[yoIndex++]; List<YoFramePoint2D> yoFrameVertices = new ArrayList<>(); while (yoFrameVertices.size() < vertexBufferSize) { YoDouble xVariable = (YoDouble) yoVariables[yoIndex++]; YoDouble yVariable = (YoDouble) yoVariables[yoIndex++]; yoFrameVertices.add(new YoFramePoint2D(xVariable, yVariable, worldFrame)); } yoFrameConvexPolygon2d = new YoFrameConvexPolygon2D(yoFrameVertices, numberOfVertices, worldFrame); verticesToDisplay = new ArrayList<>(yoFrameConvexPolygon2d.getMaxNumberOfVertices()); this.appearance = appearance; graphics3dObject = new Graphics3DObject(); graphics3dObject.setChangeable(true); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(yoFrameConvexPolygon2d, height); instruction = new Graphics3DAddMeshDataInstruction(meshDataHolder, appearance); graphics3dObject.addInstruction(instruction); }