javafx.scene.shape.CullFace Java Examples
The following examples show how to use
javafx.scene.shape.CullFace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArbitraryMeshConfigSerializer.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public ArbitraryMeshConfig.MeshInfo deserialize( final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException { final JsonObject map = json.getAsJsonObject(); final String path = resolveIfRelative(map.get(PATH_KEY).getAsString(), projectDirectory.get()); final String className = map.get(FORMAT_KEY).getAsString(); try { final ArbitraryMeshConfig.MeshInfo meshInfo = new ArbitraryMeshConfig.MeshInfo( Paths.get(path), ((Class<TriangleMeshFormat>)Class.forName(className)).getConstructor().newInstance()); if (map.has(NAME_KEY)) meshInfo.nameProperty().set(map.get(NAME_KEY).getAsString()); if (map.has(IS_VISIBLE_KEY)) meshInfo.isVisibleProperty().set(map.get(IS_VISIBLE_KEY).getAsBoolean()); if (map.has(COLOR_KEY)) meshInfo.colorProperty().set(Color.web(map.get(COLOR_KEY).getAsString())); if (map.has(SCALE_KEY)) meshInfo.scaleProperty().set(map.get(SCALE_KEY).getAsDouble()); if (map.has(TRANSLATE_X_KEY)) meshInfo.translateXProperty().set(map.get(TRANSLATE_X_KEY).getAsDouble()); if (map.has(TRANSLATE_Y_KEY)) meshInfo.translateYProperty().set(map.get(TRANSLATE_Y_KEY).getAsDouble()); if (map.has(TRANSLATE_Z_KEY)) meshInfo.translateZProperty().set(map.get(TRANSLATE_Z_KEY).getAsDouble()); if (map.has(CULL_FACE_KEY)) meshInfo.cullFaceProperty().set(context.deserialize(map.get(CULL_FACE_KEY), CullFace.class)); if (map.has(DRAW_MODE_KEY)) meshInfo.drawModeProperty().set(context.deserialize(map.get(DRAW_MODE_KEY), DrawMode.class)); return meshInfo; } catch (Exception e) { throw new JsonParseException(e); } }
Example #2
Source File: MeshSettingsSerializer.java From paintera with GNU General Public License v2.0 | 6 votes |
public static MeshSettings deserializeInto( final JsonObject map, final MeshSettings settings, final JsonDeserializationContext context) { Optional.ofNullable(map.get(COARSEST_SCALE_LEVEL_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setCoarsetsScaleLevel); Optional.ofNullable(map.get(FINEST_SCALE_LEVEL_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setFinestScaleLevel); Optional.ofNullable(map.get(SIMPLIFICATION_ITERATIONS_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setSimplificationIterations); Optional.ofNullable(map.get(SMOOTHING_ITERATIONS_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setSmoothingIterations); Optional.ofNullable(map.get(SMOOTHING_LAMBDA_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setSmoothingLambda); Optional.ofNullable(map.get(OPACITY_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setOpacity); Optional.ofNullable(map.get(INFLATE_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setInflate); Optional.ofNullable(map.get(DRAW_MODE_KEY)).map(el -> (DrawMode) context.deserialize(el, DrawMode.class)).ifPresent(settings::setDrawMode); Optional.ofNullable(map.get(CULL_FACE_KEY)).map(el -> (CullFace) context.deserialize(el, CullFace.class)).ifPresent(settings::setCullFace); Optional.ofNullable(map.get(IS_VISIBLE_KEY)).map(JsonElement::getAsBoolean).ifPresent(settings::setVisible); Optional.ofNullable(map.get(MIN_LABEL_RATIO_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setMinLabelRatio); Optional.ofNullable(map.get(LEVEL_OF_DETAIL_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setLevelOfDetail); return settings; }
Example #3
Source File: MeshGeneratorJobManager.java From paintera with GNU General Public License v2.0 | 6 votes |
private static MeshView makeMeshView(final PainteraTriangleMesh verticesAndNormals) { final float[] vertices = verticesAndNormals.getVertices(); final float[] normals = verticesAndNormals.getNormals(); final TriangleMesh mesh = new TriangleMesh(); mesh.getPoints().addAll(vertices); mesh.getNormals().addAll(normals); mesh.getTexCoords().addAll(0, 0); mesh.setVertexFormat(VertexFormat.POINT_NORMAL_TEXCOORD); final int[] faceIndices = new int[vertices.length]; for (int i = 0, k = 0; i < faceIndices.length; i += 3, ++k) { faceIndices[i + 0] = k; faceIndices[i + 1] = k; faceIndices[i + 2] = 0; } mesh.getFaces().addAll(faceIndices); final PhongMaterial material = Meshes.painteraPhongMaterial(); final MeshView mv = new MeshView(mesh); mv.setOpacity(1.0); mv.setCullFace(CullFace.FRONT); mv.setMaterial(material); mv.setDrawMode(DrawMode.FILL); return mv; }
Example #4
Source File: KnotMesh.java From FXyzLib with GNU General Public License v3.0 | 6 votes |
public KnotMesh(double majorRadius, double minorRadius, double wireRadius, double p, double q, int rDivs, int tDivs, int lengthCrop, int wireCrop) { setMajorRadius(majorRadius); setMinorRadius(minorRadius); setWireRadius(wireRadius); setP(p); setQ(q); setLengthDivisions(rDivs); setWireDivisions(tDivs); setLengthCrop(lengthCrop); setWireCrop(wireCrop); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #5
Source File: IcosahedronMesh.java From FXyzLib with GNU General Public License v3.0 | 6 votes |
public IcosahedronMesh(int level, float diameter){ setLevel(level); setDiameter(diameter); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); diameterProperty().addListener((obs,f0,f1)->{ if(mesh!=null && f0!=null && f1!=null && f0.floatValue()>0 && f1.floatValue()>0){ updateVertices(f1.floatValue()/f0.floatValue()); } }); levelProperty().addListener((obs,i0,i1)->{ if(mesh!=null && i1!=null && i1.intValue()>=0){ updateMesh(); } }); }
Example #6
Source File: SpringMesh.java From FXyzLib with GNU General Public License v3.0 | 6 votes |
public SpringMesh(double meanRadius, double wireRadius, double pitch, double length, int rDivs, int tDivs, int lengthCrop, int wireCrop) { setMeanRadius(meanRadius); setWireRadius(wireRadius); setPitch(pitch); setLength(length); factor=length/pitch; setLengthDivisions(rDivs); setWireDivisions(tDivs); setLengthCrop(lengthCrop); setWireCrop(wireCrop); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #7
Source File: CurvedSpringMesh.java From FXyzLib with GNU General Public License v3.0 | 6 votes |
public CurvedSpringMesh(double majorRadius, double minorRadius, double wireRadius, double pitch, double length, int rDivs, int tDivs, int lengthCrop, int wireCrop) { setMajorRadius(majorRadius); setMinorRadius(minorRadius); setWireRadius(wireRadius); setPitch(pitch); setLength(length); setLengthDivisions(rDivs); setWireDivisions(tDivs); setLengthCrop(lengthCrop); setWireCrop(wireCrop); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #8
Source File: CuboidMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public CuboidMesh(double width, double height, double depth, int level, Point3D center){ setWidth(width); setHeight(height); setDepth(depth); setLevel(level); setCenter(center); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #9
Source File: TriangulatedMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public TriangulatedMesh(List<Point3D> points, List<List<Point3D>> pointsHole, int level, double height, double holeRadius, Bounds bounds) { this.pointsExterior=points; this.pointsHoles=pointsHole; setLevel(level); setHeight(height); setHoleRadius(holeRadius); setBounds(bounds); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #10
Source File: SurfacePlotMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public SurfacePlotMesh(Function<Point2D,Number> function, double rangeX, double rangeY, int divisionsX, int divisionsY, double functionScale) { setFunction2D(function); setRangeX(rangeX); setRangeY(rangeY); setDivisionsX(divisionsX); setDivisionsY(divisionsY); setFunctionScale(functionScale); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #11
Source File: PrismMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public PrismMesh(double radius, double height, int level, Point3D pIni, Point3D pEnd){ setAxisOrigin(pIni==null?new Point3D(0,(float)height/2f,0):pIni); setAxisEnd(pEnd==null?new Point3D(0,-(float)height/2f,0):pEnd); setRadius(radius); setHeight(getAxisEnd().substract(getAxisOrigin()).magnitude()); setLevel(level); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #12
Source File: SegmentedTorusMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public SegmentedTorusMesh(int rDivs, int tDivs, int crop, double majorRadius, double minorRadius) { setMajorRadiusDivisions(rDivs); setMinorRadiusDivisions(tDivs); setMajorRadiusCrop(crop); setMajorRadius(majorRadius); setMinorRadius(minorRadius); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #13
Source File: CSGMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public CSGMesh(CSG primitive){ this.primitive=primitive; updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #14
Source File: BezierMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public BezierMesh(BezierHelper spline, double wireRadius, int rDivs, int tDivs, int lengthCrop, int wireCrop) { setSpline(spline); setWireRadius(wireRadius); setLengthDivisions(rDivs); setWireDivisions(tDivs); setLengthCrop(lengthCrop); setWireCrop(wireCrop); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #15
Source File: SegmentedSphereMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public SegmentedSphereMesh(int tDivs, int cropX, int cropY, double radius, Point3D center) { setRadiusDivisions(tDivs); setRadiusCropX(cropX); setRadiusCropY(cropY); setRadius(radius); setzOffset(1); setCenter(center); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #16
Source File: FrustumMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public FrustumMesh(double majorRadius, double minorRadius, double height, int level, Point3D pIni, Point3D pEnd){ setAxisOrigin(pIni==null?new Point3D(0,(float)height/2f,0):pIni); setAxisEnd(pEnd==null?new Point3D(0,-(float)height/2f,0):pEnd); setMajorRadius(majorRadius); setMinorRadius(minorRadius); setLevel(level); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #17
Source File: TetrahedraMesh.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public TetrahedraMesh(double height, int level, Point3D center){ setHeight(height); setLevel(level); setCenter(center); updateMesh(); setCullFace(CullFace.BACK); setDrawMode(DrawMode.FILL); setDepthTest(DepthTest.ENABLE); }
Example #18
Source File: MeshGeneratorJobManager.java From paintera with GNU General Public License v2.0 | 5 votes |
private Node createBlockShape(final ShapeKey<T> key) { final Interval keyInterval = key.interval(); final double[] worldMin = new double[3], worldMax = new double[3]; Arrays.setAll(worldMin, d -> keyInterval.min(d)); Arrays.setAll(worldMax, d -> keyInterval.min(d) + keyInterval.dimension(d)); unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMin, worldMin); unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMax, worldMax); final RealInterval blockWorldInterval = new FinalRealInterval(worldMin, worldMax); final double[] blockWorldSize = new double[blockWorldInterval.numDimensions()]; Arrays.setAll(blockWorldSize, d -> blockWorldInterval.realMax(d) - blockWorldInterval.realMin(d)); // the standard Box primitive is made up of triangles, so the unwanted diagonals are visible when using DrawMode.Line // final Box box = new Box( // blockWorldSize[0], // blockWorldSize[1], // blockWorldSize[2] // ); final PolygonMeshView box = new PolygonMeshView(Meshes.createQuadrilateralMesh( (float) blockWorldSize[0], (float) blockWorldSize[1], (float) blockWorldSize[2] )); final double[] blockWorldTranslation = new double[blockWorldInterval.numDimensions()]; Arrays.setAll(blockWorldTranslation, d -> blockWorldInterval.realMin(d) + blockWorldSize[d] * 0.5); box.setTranslateX(blockWorldTranslation[0]); box.setTranslateY(blockWorldTranslation[1]); box.setTranslateZ(blockWorldTranslation[2]); final PhongMaterial material = Meshes.painteraPhongMaterial(); box.setCullFace(CullFace.NONE); box.setMaterial(material); box.setDrawMode(DrawMode.LINE); return box; }
Example #19
Source File: DevoxxBillboardLogo.java From TweetwallFX with MIT License | 5 votes |
public DevoxxBillboardLogo() { this.mat.setDiffuseMap(image); this.mesh = createMesh(); this.setMesh(mesh); this.setMaterial(mat); this.setCullFace(CullFace.NONE); this.updateThread.setRunnable(() -> { if (isAnimated() && updateThread.getCurrentTime() >= (updateThread.getUpdateDelay())) { updateMesh(); updateThread.setUpdateDelay((updateThread.getCurrentTime() + 80000000)); } }); updateThread.start(); this.sceneProperty().addListener(new ChangeListener<Scene>() { @Override public void changed(ObservableValue<? extends Scene> observable, Scene oldValue, Scene newValue) { if (newValue != null) { otherNode = getScene().getCamera(); startBillboardBehavior(); sceneProperty().removeListener(this); } } }); }
Example #20
Source File: SegmentMeshInfoNode.java From paintera with GNU General Public License v2.0 | 5 votes |
public SegmentMeshInfoNode(final DataSource<?, ?> source, final SegmentMeshInfo meshInfo) { this.source = source; this.meshInfo = meshInfo; this.settings = meshInfo.getMeshSettings(); LOG.debug("Initializing MeshinfoNode with draw mode {}", settings.drawModeProperty()); visibleCheckBox = new CheckBox(); levelOfDetailSlider = new NumericSliderWithField(MeshSettings.Defaults.Values.getMinLevelOfDetail(), MeshSettings.Defaults.Values.getMaxLevelOfDetail(), settings.getLevelOfDetail()); coarsestScaleLevelSlider = new NumericSliderWithField(0, settings.getNumScaleLevels() - 1, settings.getCoarsetsScaleLevel()); finestScaleLevelSlider = new NumericSliderWithField(0, settings.getNumScaleLevels() - 1, settings.getFinestScaleLevel()); smoothingLambdaSlider = new NumericSliderWithField(0.0, 1.0, settings.getSmoothingLambda()); smoothingIterationsSlider = new NumericSliderWithField(0, 10, settings.getSmoothingIterations()); minLabelRatioSlider = new NumericSliderWithField(0.0, 1.0, settings.getMinLabelRatio()); this.opacitySlider = new NumericSliderWithField(0, 1.0, settings.getOpacity()); this.inflateSlider = new NumericSliderWithField(0.5, 2.0, settings.getInflate()); this.drawModeChoice = new ComboBox<>(FXCollections.observableArrayList(DrawMode.values())); this.drawModeChoice.setValue(settings.getDrawMode()); this.cullFaceChoice = new ComboBox<>(FXCollections.observableArrayList(CullFace.values())); this.cullFaceChoice.setValue(settings.getCullFace()); bindSlidersToSettings(); this.contents = createContents(); }
Example #21
Source File: ObjImporter.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
public MeshView buildMeshView(String key) { MeshView meshView = new MeshView(); meshView.setId(key); meshView.setMaterial(materials.get(key)); meshView.setMesh(meshes.get(key)); meshView.setCullFace(CullFace.NONE); return meshView; }
Example #22
Source File: Fx3DRawDataFileDataset.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public Fx3DRawDataFileDataset(RawDataFile dataFile, float[][] intensityValues, int rtResolution, int mzResolution, double maxBinnedIntensity, String fileName, Color peakColor) { super(dataFile, fileName, peakColor); this.intensityValues = intensityValues; this.rtResolution = rtResolution; this.mzResolution = mzResolution; this.maxBinnedIntensity = maxBinnedIntensity; mesh = new TriangleMesh(); peakListIndices = new int[rtResolution][mzResolution]; float factorX = (float) SIZE / rtResolution; float factorZ = (float) SIZE / mzResolution; for (int i = 0; i < rtResolution; i++) { for (int j = 0; j < mzResolution; j++) { if (maxIntensityValue < intensityValues[i][j]) { maxIntensityValue = intensityValues[i][j]; } } } for (int x = 0; x < rtResolution; x++) { for (int z = 0; z < mzResolution; z++) { mesh.getPoints().addAll((float) x * factorX, -intensityValues[x][z] * AMPLIFI, (float) z * factorZ); if (intensityValues[x][z] > 0.022 * maxIntensityValue) { peakListIndices[x][z] = 1; } } } int rtLength = rtResolution; int mzLength = mzResolution; float rtTotal = rtLength; float mzTotal = mzLength; for (float x = 0; x < rtLength - 1; x++) { for (float y = 0; y < mzLength - 1; y++) { float x0 = x / rtTotal; float y0 = y / mzTotal; float x1 = (x + 1) / rtTotal; float y1 = (y + 1) / mzTotal; mesh.getTexCoords().addAll( // x0, y0, // 0, top-left x0, y1, // 1, bottom-left x1, y0, // 2, top-right x1, y1 // 3, bottom-right ); } } // faces for (int x = 0; x < rtLength - 1; x++) { for (int z = 0; z < mzLength - 1; z++) { int tl = x * mzLength + z; // top-left int bl = x * mzLength + z + 1; // bottom-left int tr = (x + 1) * mzLength + z; // top-right int br = (x + 1) * mzLength + z + 1; // bottom-right int offset = (x * (mzLength - 1) + z) * 8 / 2; // div 2 because // we have u AND // v in the list // working mesh.getFaces().addAll(bl, offset + 1, tl, offset + 0, tr, offset + 2); mesh.getFaces().addAll(tr, offset + 2, br, offset + 3, bl, offset + 1); } } setNodeColor(peakColor); meshView.setMesh(mesh); meshView.setCullFace(CullFace.NONE); meshView.setDrawMode(DrawMode.FILL); meshView.setDepthTest(DepthTest.ENABLE); LOG.finest("Plot mesh is ready."); }
Example #23
Source File: Pyramid.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public final void setCullFace(CullFace value) { mesh.setCullFace(value); }
Example #24
Source File: Octahedron.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public final void setCullFace(CullFace value) { mesh.setCullFace(value); }
Example #25
Source File: Torus.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public final void setCullFace(CullFace value) { mesh.setCullFace(value); }
Example #26
Source File: Trapezoid.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public final void setCullFace(CullFace value) { mesh.setCullFace(value); }
Example #27
Source File: Spheroid.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public final void setCullFace(CullFace value) { mesh.setCullFace(value); }
Example #28
Source File: Tetrahedron.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public final void setCullFace(CullFace value) { mesh.setCullFace(value); }
Example #29
Source File: CatmaidJsonLoader.java From paintera with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws IOException { PlatformImpl.startup(() -> {}); final Path path = Paths.get(System.getProperty("user.home"), "Downloads", "catmaid-meshes", "Block3.json"); final TriangleMesh mesh = new CatmaidJsonLoader().loadMesh(path); final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY}; final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY}; for (int i = 0; i < mesh.getPoints().size(); i += 3) { for (int d = 0; d < 3; ++d) { min[d] = Math.min(min[d], mesh.getPoints().get(i + d)); max[d] = Math.max(max[d], mesh.getPoints().get(i + d)); } } System.out.print(Arrays.toString(min) +" " + Arrays.toString(max)); final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max)); final MeshView mv = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE)); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); final Viewer3DFX viewer = new Viewer3DFX(800, 600); viewer.meshesEnabledProperty().set(true); mv.setOpacity(1.0); viewer.setInitialTransformToInterval(interval); final MeshView mv2 = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial()); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); mv2.setTranslateX(100); viewer.meshesGroup().getChildren().addAll(mv, mv2); Platform.setImplicitExit(true); Platform.runLater(() -> { final Scene scene = new Scene(viewer); final Stage stage = new Stage(); stage.setScene(scene); stage.setWidth(800); stage.setHeight(600); stage.show(); }); // final String mesh = "<IndexedTriangleSet index='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35'><Coordinate point='440474 99212 136120 440474 119212 136120 460474 99212 136120 460474 99212 136120 440474 119212 136120 460474 119212 136120 440474 99212 136120 460474 99212 136120 460474 99212 156120 440474 99212 136120 460474 99212 156120 440474 99212 156120 440474 119212 136120 440474 119212 156120 460474 119212 156120 440474 119212 136120 460474 119212 156120 460474 119212 136120 440474 99212 156120 460474 119212 156120 440474 119212 156120 440474 99212 156120 460474 99212 156120 460474 119212 156120 440474 99212 136120 440474 119212 156120 440474 119212 136120 440474 99212 136120 440474 99212 156120 440474 119212 156120 460474 99212 136120 460474 119212 136120 460474 99212 156120 460474 119212 136120 460474 119212 156120 460474 99212 156120'/></IndexedTriangleSet>"; // final Document doc = Jsoup.parse(mesh); // System.out.println(doc); // System.out.println(doc.select("IndexedTriangleSet").attr("index")); }
Example #30
Source File: ObjLoader.java From paintera with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws IOException { PlatformImpl.startup(() -> {}); // https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html // final String objFile = "al.obj"; // final String objFile = "diamond.obj"; final String objFile = "alfa147.obj"; final Path path = Paths.get(System.getProperty("user.home"), "Downloads", objFile); final TriangleMesh mesh = new ObjLoader().loadMesh(path); final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY}; final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY}; for (int i = 0; i < mesh.getPoints().size(); i += 3) { for (int d = 0; d < 3; ++d) { min[d] = Math.min(min[d], mesh.getPoints().get(i + d)); max[d] = Math.max(max[d], mesh.getPoints().get(i + d)); } } final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max)); final MeshView mv = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE)); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); final Viewer3DFX viewer = new Viewer3DFX(800, 600); viewer.meshesEnabledProperty().set(true); mv.setOpacity(1.0); viewer.setInitialTransformToInterval(interval); final MeshView mv2 = new MeshView(mesh); mv.setMaterial(Meshes.painteraPhongMaterial()); mv.setDrawMode(DrawMode.FILL); mv.setCullFace(CullFace.BACK); mv2.setTranslateX(100); viewer.meshesGroup().getChildren().addAll(mv, mv2); // final double factor = 1; // final double w = 1*factor, h = 2*factor, d = 3*factor; // final Box box = new Box(w, h, d); // box.setCullFace(CullFace.NONE); // box.setOpacity(1.0); // box.setMaterial(Meshes.painteraPhongMaterial(Color.RED)); // viewer.meshesGroup().getChildren().add(box); Platform.setImplicitExit(true); Platform.runLater(() -> { final Scene scene = new Scene(viewer); final Stage stage = new Stage(); stage.setScene(scene); stage.setWidth(800); stage.setHeight(600); stage.show(); }); }