Java Code Examples for javafx.scene.shape.MeshView#setTranslateX()

The following examples show how to use javafx.scene.shape.MeshView#setTranslateX() . 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: CatmaidJsonLoader.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
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 2
Source File: ObjLoader.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
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();
		});
	}