@Override protected void initKeys(Scene scene) { scene.addEventHandler(KeyEvent.ANY, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { switch (t.getText()) { case "1": setShape(Shape.Sphere); break; case "2": setShape(Shape.Box); break; case "3": setShape(Shape.Cylinder); break; } } }); }
private static Group buildGroup() { Sphere s = new Sphere(); s.setScaleX(SCALE); s.setScaleY(SCALE); s.setScaleZ(SCALE); PhongMaterial material = new PhongMaterial(); material.setDiffuseColor(Color.LIGHTGRAY); material.setSpecularColor(Color.rgb(30, 30, 30)); s.setMaterial(material); // PointLight pl = new PointLight(Color.AQUA); // pl.setTranslateZ(-1000); Group group = new Group(/*pl,*/ s); group.setTranslateX(SS_WIDTH / 2); group.setTranslateY(SS_HEIGHT / 2); return group; }
private Group buildMultipleShapes3D() { Box box = new Box(100, 100, 100); Sphere sphere = new Sphere(50); Cylinder cyl = new Cylinder(50, 100); Cone cone = new Cone(50, 100); box.setTranslateX(-100); box.setTranslateY(-150); sphere.setTranslateX(100); sphere.setTranslateY(-50); cyl.setTranslateX(-100); cyl.setTranslateY(50); cone.getMesh().setTranslateX(100); cone.getMesh().setTranslateY(150); nodes.add(box); nodes.add(sphere); nodes.add(cyl); nodes.add(cone.getMesh()); return new Group(box, sphere, cyl, cone.getMesh()); }
@Override protected void initScene() { DefaultMeshBuilder dmb = new DefaultMeshBuilder() { @Override protected double function(double fx, double fy) { return 1; } }; MeshView meshView = new MeshView(dmb.getTriangleMesh()); meshView.setScaleX(100); meshView.setScaleY(100); meshView.setScaleZ(100); Sphere s = new Sphere(50); s.setTranslateX(WIDTH / 2); s.setTranslateY(HEIGHT / 2); Group root = new Group(s, meshView); scene = createScene(root, WIDTH, HEIGHT); scene.setCamera(new PerspectiveCamera()); }
/** * @param data the xAxisData to set */ public void setxAxisData(ArrayList<Double> data) { xAxisData = data; scatterDataGroup.getChildren().clear(); for(int i=0;i<xAxisData.size();i++) { final Sphere dataSphere = new Sphere(scatterRadius); // final Box dataSphere = new Box(getScatterRadius(), getScatterRadius(), getScatterRadius()); double translateY = 0.0; double translateZ = 0.0; if(!yAxisData.isEmpty() && yAxisData.size() > i) translateY = yAxisData.get(i); if(!zAxisData.isEmpty() && zAxisData.size() > i) translateZ = zAxisData.get(i); dataSphere.setTranslateX(xAxisData.get(i)); dataSphere.setTranslateY(translateY); dataSphere.setTranslateZ(translateZ); scatterDataGroup.getChildren().add(dataSphere); } }
/** * @param data the yAxisData to set */ public void setyAxisData(ArrayList<Double> data) { yAxisData = data; scatterDataGroup.getChildren().clear(); for(int i=0;i<yAxisData.size();i++) { final Sphere dataSphere = new Sphere(scatterRadius); // final Box dataSphere = new Box(getScatterRadius(), getScatterRadius(), getScatterRadius()); double translateX = 0.0; double translateZ = 0.0; if(!xAxisData.isEmpty() && xAxisData.size() > i) translateX = xAxisData.get(i); if(!zAxisData.isEmpty() && zAxisData.size() > i) translateZ = zAxisData.get(i); dataSphere.setTranslateX(translateX); dataSphere.setTranslateY(yAxisData.get(i)); dataSphere.setTranslateZ(translateZ); scatterDataGroup.getChildren().add(dataSphere); } }
/** * @param data the zAxisData to set */ public void setzAxisData(ArrayList<Double> data) { zAxisData = data; scatterDataGroup.getChildren().clear(); for(int i=0;i<zAxisData.size();i++) { final Sphere dataSphere = new Sphere(scatterRadius); // final Box dataSphere = new Box(getScatterRadius(), getScatterRadius(), getScatterRadius()); double translateX = 0.0; double translateY = 0.0; if(!xAxisData.isEmpty() && xAxisData.size() > i) translateX = xAxisData.get(i); if(!yAxisData.isEmpty() && yAxisData.size() > i) translateY = yAxisData.get(i); dataSphere.setTranslateX(translateX); dataSphere.setTranslateY(translateY); dataSphere.setTranslateZ(zAxisData.get(i)); scatterDataGroup.getChildren().add(dataSphere); } }
private void drawLocus(Physical ball) { // Main スレッド以外で UI を操作するとエラーになるので、 Platform.runLater() を使って UI スレッドで処理を実行する Platform.runLater(() -> { Sphere sphere = this.createSphere(ball); Deque<Sphere> spheres = this.spheresMap.computeIfAbsent(ball, (key) -> new ArrayDeque<>()); spheres.addLast(sphere); this.group.getChildren().add(sphere); if (this.historySzie < spheres.size()) { Sphere removed = spheres.removeFirst(); this.group.getChildren().remove(removed); } }); }
public Bone(double scale, Point3D posJoint) { Box origin=new Box(10,10,10); origin.setMaterial(new PhongMaterial(Color.ORANGE)); Cylinder bone = new Cylinder(5, posJoint.magnitude()/scale); double angle = Math.toDegrees(Math.acos((new Point3D(0,1,0)).dotProduct(posJoint)/posJoint.magnitude())); Point3D axis = (new Point3D(0,1,0)).crossProduct(posJoint); bone.getTransforms().addAll(new Rotate(angle,0,0,0,axis), new Translate(0,posJoint.magnitude()/2d/scale, 0)); bone.setMaterial(new PhongMaterial(Color.CADETBLUE)); Sphere end = new Sphere(6); end.getTransforms().addAll(new Translate(posJoint.getX()/scale,posJoint.getY()/scale,posJoint.getZ()/scale)); end.setMaterial(new PhongMaterial(Color.YELLOW)); getChildren().addAll(origin, bone, end); getTransforms().add(new Scale(scale, scale, scale)); }
@Override public void start(Stage stage) { Box floor = new Box(1000, 10, 1000); floor.setTranslateY(150); root.getChildren().add(floor); Sphere s = new Sphere(150); s.setTranslateX(5); s.setPickOnBounds(true); root.getChildren().add(s); showStage(stage); }
@Override protected Group buildGroup() { material = new PhongMaterial(); material.setDiffuseColor(Color.LIGHTGRAY); material.setSpecularColor(Color.rgb(30, 30, 30)); grp = new Group(); setShape(Shape.Sphere); return grp; }
public Group buildGroup() { initMaterials(); meshView = new Shape3D[(int) Math.pow(side, 3) - (int) Math.pow(side - 2, 3)]; int i = 0; for (int x = 0; x < side; x++) { for (int y = 0; y < side; y++) { for (int z = 0; z < side; z++) { if (x == 0 || y == 0 || z == 0 || z == side - 1 || y == side - 1 || x == side - 1) { meshView[i] = new Sphere(radius); meshView[i].setMaterial(getMtrl(x, y, z)); meshView[i].setScaleX(SCALE); meshView[i].setScaleY(SCALE); meshView[i].setScaleZ(SCALE); meshView[i].setTranslateX((x - (side) / 2) * SCALE * 2 * radius + SCALE * radius); meshView[i].setTranslateY((y - (side) / 2) * SCALE * 2 * radius + SCALE * radius); meshView[i].setTranslateZ((z - (side) / 2) * SCALE * 2 * radius + SCALE * radius); i++; } } } } root = new Group(meshView); root.setFocusTraversable(true); grp = new Group(root); return grp; }
private static Group buildGroup() { Group grp = new Group(); Sphere s = new Sphere(); Box b = new Box(); s.setScaleX(SCALE); s.setScaleY(SCALE); s.setScaleZ(SCALE); s.setTranslateX(-130); b.setScaleX(SCALE); b.setScaleY(SCALE); b.setScaleZ(SCALE); b.setTranslateX(130); PhongMaterial material = new PhongMaterial(); material.setDiffuseColor(Color.LIGHTGRAY); material.setSpecularColor(Color.rgb(30, 30, 30)); s.setMaterial(material); b.setMaterial(material); PointLight pl = new PointLight(Color.AQUA); pl.setTranslateZ(-1000); Sphere lightBalance = new Sphere(); // lightBalance.setScaleX(0.1); // lightBalance.setScaleX(0.1); // lightBalance.setScaleX(0.1); lightBalance.setTranslateZ(1000); grp.getChildren().addAll(s, b,pl,lightBalance); return grp; }
private SubScene buildGroup(int num) { Sphere s = new Sphere(50); nodes[num] = s; Group grp = new Group(s); grp.setTranslateX(SS_WIDTH / 2); grp.setTranslateY(SS_HEIGHT / 2); roots[num] = grp; SubScene ss = createSubScene(grp, SS_WIDTH, SS_HEIGHT); ss.setCamera(new PerspectiveCamera()); return ss; }
@Override protected Shape3D[] getShapes() { Shape3D[] result = { new Sphere(1), new Sphere(1), }; result[1].setTranslateX(1); result[0].setTranslateX(-1); return result; }
@Override protected Shape3D[] getShapes() { Shape3D[] result = { new Sphere(1), new Sphere(1.5) }; result[1].setTranslateX(1.5); result[1].setTranslateY(1.5); return result; }
@Override protected Shape3D[] getShapes() { Shape3D[] result = { new Box(2, 2, 2), new Sphere(2) }; result[1].setTranslateX(1); result[1].setTranslateY(1); result[0].setRotationAxis(Rotate.Y_AXIS); result[0].setRotate(45); return result; }
@Override protected Shape3D[] getShapes() { Shape3D[] result = { new Cylinder(1.5, 4), new Sphere(1.5) }; result[1].setTranslateX(1); return result; }
private static Group buildLightGroup(VisibleLight vl) { vl.setTranslateZ(-140); Sphere balance = new Sphere(); // balance.setScaleX(SCALE); // balance.setScaleY(SCALE); // balance.setScaleZ(SCALE); balance.setTranslateZ(140); return new Group(vl, balance); }
public void initTestCase(TestCaseType type) { if (isThereTestCase) { root.getChildren().clear(); nodes.clear(); lights.clear(); movers.clear(); } switch (type) { case SINGLE_SPHERE_CASE: root.getChildren().add(buildSingle(new Sphere(50))); break; case SINGLE_BOX_CASE: root.getChildren().add(buildSingle(new Box(100, 100, 100))); break; case SINGLE_CYLINDER_CASE: root.getChildren().add(buildSingle(new Cylinder(50, 100))); break; case SINGLE_MESH_CASE: Cone cone = new Cone(50, 100); root.getChildren().add(buildSingle(cone.getMesh())); break; case MULTIPLE_SHAPE3D_CASE: root.getChildren().add(buildMultipleShapes3D()); break; case MULTIPLE_SHAPE_CASE: root.getChildren().add(buildMultipleShapes()); break; } isThereTestCase = true; }
private Group buildMultipleShapes() { Box box = new Box(100, 100, 100); Sphere sphere = new Sphere(50); Cylinder cyl = new Cylinder(50, 100); Cone cone = new Cone(50, 100); Rectangle rect = new Rectangle(50, 50); rect.setFill(Color.WHITESMOKE); box.setTranslateX(-100); box.setTranslateY(-150); sphere.setTranslateX(100); sphere.setTranslateY(-50); cyl.setTranslateX(-100); cyl.setTranslateY(50); cone.getMesh().setTranslateX(100); cone.getMesh().setTranslateY(150); rect.setTranslateX(-25); rect.setTranslateY(-25); rect.setRotationAxis(Rotate.Y_AXIS); rect.setRotate(45); nodes.add(box); nodes.add(sphere); nodes.add(cyl); nodes.add(cone.getMesh()); nodes.add(rect); return new Group(box, sphere, cyl, cone.getMesh(), rect); }
public void setLightType(VisibleLight.LightType lt) { vl = new VisibleLight(Color.ANTIQUEWHITE, lt); vl.setTranslateZ(-140); Sphere balance = new Sphere(); balance.setTranslateZ(140); lightGroup.getChildren().clear(); lightGroup.getChildren().addAll(vl, balance); }
private void buildAxes() { double length = 2d * dimModel; double width = dimModel / 100d; double radius = 2d * dimModel / 100d; final PhongMaterial redMaterial = new PhongMaterial(); redMaterial.setDiffuseColor(Color.DARKRED); redMaterial.setSpecularColor(Color.RED); final PhongMaterial greenMaterial = new PhongMaterial(); greenMaterial.setDiffuseColor(Color.DARKGREEN); greenMaterial.setSpecularColor(Color.GREEN); final PhongMaterial blueMaterial = new PhongMaterial(); blueMaterial.setDiffuseColor(Color.DARKBLUE); blueMaterial.setSpecularColor(Color.BLUE); Sphere xSphere = new Sphere(radius); Sphere ySphere = new Sphere(radius); Sphere zSphere = new Sphere(radius); xSphere.setMaterial(redMaterial); ySphere.setMaterial(greenMaterial); zSphere.setMaterial(blueMaterial); xSphere.setTranslateX(dimModel); ySphere.setTranslateY(dimModel); zSphere.setTranslateZ(dimModel); Box xAxis = new Box(length, width, width); Box yAxis = new Box(width, length, width); Box zAxis = new Box(width, width, length); xAxis.setMaterial(redMaterial); yAxis.setMaterial(greenMaterial); zAxis.setMaterial(blueMaterial); autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis); autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere); }
private void addAtom(LeafSubstructure<?> origin, Atom atom) { Sphere atomShape = new Sphere(1.0); atomShape.setMaterial(getMaterial(origin, atom)); atomShape.setTranslateX(atom.getPosition().getX()); atomShape.setTranslateY(atom.getPosition().getY()); atomShape.setTranslateZ(atom.getPosition().getZ()); // add tooltip Tooltip tooltip = new Tooltip(atom.getElement().getName() + " (" + (atom.getAtomName()) + ":" + atom.getAtomIdentifier() + ") of " + origin.getFamily().getThreeLetterCode() + ":" + origin.getIdentifier()); Tooltip.install(atomShape, tooltip); moleculeGroup.getChildren().add(atomShape); }
private Group buildScene() { Sphere mars = new Sphere(MARS_RADIUS); mars.setTranslateX(VIEWPORT_SIZE / 2d); mars.setTranslateY(VIEWPORT_SIZE / 2d); PhongMaterial material = new PhongMaterial(); material.setDiffuseMap( new Image(this.getClass().getResource(DIFFUSE_MAP).toExternalForm(), MAP_WIDTH, MAP_HEIGHT, true, true ) ); material.setBumpMap( new Image(this.getClass().getResource(NORMAL_MAP).toExternalForm(), MAP_WIDTH, MAP_HEIGHT, true, true ) ); /* material.setSpecularMap( new Image(this.getClass().getResource(SPECULAR_MAP).toExternalForm(), MAP_WIDTH, MAP_HEIGHT, true, true ) ); */ mars.setMaterial( material ); return new Group(mars); }
private Group buildScene() { Sphere earth = new Sphere(EARTH_RADIUS); earth.setTranslateX(VIEWPORT_SIZE / 2d); earth.setTranslateY(VIEWPORT_SIZE / 2d); PhongMaterial earthMaterial = new PhongMaterial(); earthMaterial.setDiffuseMap( new Image( DIFFUSE_MAP, MAP_WIDTH, MAP_HEIGHT, true, true ) ); earthMaterial.setBumpMap( new Image( NORMAL_MAP, MAP_WIDTH, MAP_HEIGHT, true, true ) ); earthMaterial.setSpecularMap( new Image( SPECULAR_MAP, MAP_WIDTH, MAP_HEIGHT, true, true ) ); earth.setMaterial( earthMaterial ); return new Group(earth); }
/** * The default constructor. * * @param model * The model which this view will display */ public FXVertexView(Vertex model) { this(); // Set the node's name node.setId(model.getProperty(MeshProperty.NAME)); // Get the model's transformation Transformation localTransform = model.getTransformation(); // Flatten the sphere into a circle localTransform.setScale(1, 1, 0.75); // Set the node's transformation node.getTransforms().setAll(Util.convertTransformation(localTransform)); // Create a Shape3D for the model mesh = new Sphere(1); // Set the sphere to the correct wireframe and opacity states if (transparent) { mesh.setOpacity(0d); } if (wireframe) { mesh.setDrawMode(DrawMode.LINE); } // Set the sphere to be the constructing material by default mesh.setMaterial(constructingMaterial); node.getChildren().add(mesh); }
/** * Remove the selected property from all selected parts and reset the * selection lists */ private void clearSelection() { // Remove the temporary vertices from the scene for (IController vertex : selectedVertices) { tempRoot.removeEntity(vertex); vertex.setProperty(MeshProperty.SELECTED, "False"); vertex.setProperty(MeshEditorMeshProperty.UNDER_CONSTRUCTION, "False"); vertex.refresh(); } // Remove the temporary edges from the scene and set them to // be unselected for (IController edge : tempEdges) { tempRoot.removeEntity(edge); edge.setProperty(MeshProperty.SELECTED, "False"); edge.setProperty(MeshEditorMeshProperty.UNDER_CONSTRUCTION, "False"); edge.refresh(); } // Remove the markers from the scene for (Sphere marker : vertexMarkers) { ((FXAttachment) attachmentManager.getAttachments().get(1)) .getFxNode().getChildren().remove(marker); } // Empty the lists selectedVertices.clear(); tempEdges.clear(); }
private Shape3D createDefaultNode(double radius) { switch(defaultNodeType) { case SPHERE: return new Sphere(radius); case CUBE: return new Box(radius, radius, radius); default: return new Box(radius, radius, radius); } }
public Axis3D() { super(); final PhongMaterial redMaterial = new PhongMaterial(); redMaterial.setDiffuseColor(Color.DARKRED); redMaterial.setSpecularColor(Color.RED); final PhongMaterial greenMaterial = new PhongMaterial(); greenMaterial.setDiffuseColor(Color.DARKGREEN); greenMaterial.setSpecularColor(Color.GREEN); final PhongMaterial blueMaterial = new PhongMaterial(); blueMaterial.setDiffuseColor(Color.DARKBLUE); blueMaterial.setSpecularColor(Color.BLUE); final Sphere red = new Sphere(50); red.setMaterial(redMaterial); final Sphere blue = new Sphere(50); blue.setMaterial(blueMaterial); xAxis = new Box(24.0, 0.05, 0.05); yAxis = new Box(0.05, 24.0, 0.05); zAxis = new Box(0.05, 0.05, 24.0); xAxis.setMaterial(redMaterial); yAxis.setMaterial(greenMaterial); zAxis.setMaterial(blueMaterial); getChildren().addAll(xAxis,yAxis,zAxis); }
public void addSphere(double x, double y, double z, Material material) { Sphere sphere = new Sphere(RADIUS); sphere.setTranslateX(x * SCALE_FACTOR); sphere.setTranslateY(y * SCALE_FACTOR); sphere.setTranslateZ(z * SCALE_FACTOR); sphere.setMaterial(material); getChildren().add(sphere); }
@Test public void testGetSphereAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(Sphere.class); assertThat(adjuster, is(instanceOf(NodeAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Node.class))); }