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; }
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 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 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); }
public YoGraphicPolygon3D(String name, int maxNumberOfPolygonVertices, double height, AppearanceDefinition appearance, YoVariableRegistry registry) { super(name); ccwOrderedYoFramePoints = new YoFramePoint3D[maxNumberOfPolygonVertices]; ccwOrderedPoints = new ArrayList<>(maxNumberOfPolygonVertices); for (int i = 0; i < maxNumberOfPolygonVertices; i++) { ccwOrderedYoFramePoints[i] = new YoFramePoint3D(name + "Point" + i, ReferenceFrame.getWorldFrame(), registry); ccwOrderedYoFramePoints[i].setToNaN(); ccwOrderedPoints.add(new Point3D()); } this.height = height; this.appearance = appearance; numberOfPoints = new YoInteger(name + "NumberOfPoints", registry); graphics3dObject = new Graphics3DObject(); graphics3dObject.setChangeable(true); instruction = new Graphics3DAddMeshDataInstruction(EMPTY_MESH, appearance); graphics3dObject.addInstruction(instruction); }
private YoGraphicPolygon(String name, YoFrameConvexPolygon2D yoFrameConvexPolygon2d, YoFramePoint3D framePoint, YoFrameYawPitchRoll yawPitchRoll, YoFrameQuaternion quaternion, double scale, double height, AppearanceDefinition appearance) { super(name, framePoint, yawPitchRoll, quaternion, scale); if (yoFrameConvexPolygon2d.getNumberOfVertices() <= 0) yoFrameConvexPolygon2d.set(Vertex2DSupplier.emptyVertex2DSupplier()); this.yoFrameConvexPolygon2d = yoFrameConvexPolygon2d; this.appearance = appearance; this.height = height; verticesToDisplay = new ArrayList<>(yoFrameConvexPolygon2d.getMaxNumberOfVertices()); graphics3dObject = new Graphics3DObject(); graphics3dObject.setChangeable(true); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(yoFrameConvexPolygon2d, height); instruction = new Graphics3DAddMeshDataInstruction(meshDataHolder, appearance); graphics3dObject.addInstruction(instruction); }
/** * Adds a PlanarRegion transforming from the current coordinate system. * Uses the given appearances in order, one for each Polygon in the PlanarRegion. Then loops on the appearances. * * @param planarRegion */ public void addPlanarRegion(PlanarRegion planarRegion, AppearanceDefinition... appearances) { int numberOfConvexPolygons = planarRegion.getNumberOfConvexPolygons(); RigidBodyTransform transform = new RigidBodyTransform(); planarRegion.getTransformToWorld(transform); transform(transform); for (int i = 0; i < numberOfConvexPolygons; i++) { ConvexPolygon2d convexPolygon = planarRegion.getConvexPolygon(i); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(convexPolygon, 0.005); addInstruction(new Graphics3DAddMeshDataInstruction(meshDataHolder, appearances[i % appearances.length])); } transform.invert(); transform(transform); }
public YoGraphicPolygon(String name, YoFrameConvexPolygon2d yoFrameConvexPolygon2d, YoFramePoint framePoint, YoFrameOrientation orientation, double scale, double height, AppearanceDefinition appearance) { super(name, framePoint, orientation, scale); if (yoFrameConvexPolygon2d.getNumberOfVertices() <= 0) yoFrameConvexPolygon2d.setConvexPolygon2d(new ConvexPolygon2d(new Point2d[] {new Point2d()})); this.yoFrameConvexPolygon2d = yoFrameConvexPolygon2d; this.appearance = appearance; this.height = height; graphics3dObject = new Graphics3DObject(); graphics3dObject.setChangeable(true); ConvexPolygon2d convexPolygon2d = yoFrameConvexPolygon2d.getConvexPolygon2d(); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(convexPolygon2d, height); instruction = new Graphics3DAddMeshDataInstruction(meshDataHolder, appearance); graphics3dObject.addInstruction(instruction); }
/** * Adds a PlanarRegion transforming from the current coordinate system. * Uses the given appearances in order, one for each Polygon in the PlanarRegion. Then loops on the appearances. * * @param planarRegion */ public static void addPlanarRegion(Graphics3DObject graphics3DObject, PlanarRegion planarRegion, AppearanceDefinition... appearances) { int numberOfConvexPolygons = planarRegion.getNumberOfConvexPolygons(); RigidBodyTransform transform = new RigidBodyTransform(); planarRegion.getTransformToWorld(transform); graphics3DObject.transform(transform); for (int i = 0; i < numberOfConvexPolygons; i++) { ConvexPolygon2D convexPolygon = planarRegion.getConvexPolygon(i); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(convexPolygon, -0.0001); graphics3DObject.addInstruction(new Graphics3DAddMeshDataInstruction(meshDataHolder, appearances[i % appearances.length])); } transform.invert(); graphics3DObject.transform(transform); }