private void loadCamera(Scene scene) { //initialize camera camera = new PerspectiveCamera(true); camera.setVerticalFieldOfView(RUN_JASON); //setup camera transform for rotational support cameraTransform.setTranslate(0, 0, 0); cameraTransform.getChildren().add(camera); camera.setNearClip(0.1); camera.setFarClip(100000.0); camera.setTranslateZ(-5000); cameraTransform.ry.setAngle(0.0); cameraTransform.rx.setAngle(-45.0); //add a Point Light for better viewing of the grid coordinate system PointLight light = new PointLight(Color.GAINSBORO); cameraTransform.getChildren().add(light); cameraTransform.getChildren().add(new AmbientLight(Color.WHITE)); light.setTranslateX(camera.getTranslateX()); light.setTranslateY(camera.getTranslateY()); light.setTranslateZ(camera.getTranslateZ()); //attach camera to scene scene.setCamera(camera); }
private void init(){ redMaterial.setDiffuseColor(Color.DARKRED); redMaterial.setSpecularColor(Color.RED); greenMaterial.setDiffuseColor(Color.DARKGREEN); greenMaterial.setSpecularColor(Color.GREEN); blueMaterial.setDiffuseColor(Color.DARKBLUE); blueMaterial.setSpecularColor(Color.BLUE); buildAxes(axesSize, axesThickness); buildPanels(axesSize); buildGrids(axesSize, gridLineSpacing); buildEventHandlers(); getChildren().add(cubeWorldChildren); //Holds ScatterPlot data if(selfLightEnabled) { AmbientLight light = new AmbientLight(Color.WHITE); getChildren().add(light); } }
public AmbientLight getAmbient() { return new GetAction<AmbientLight>() { @Override public void run(Object... os) throws Exception { setResult(vl.getAmbient()); } }.dispatch(Root.ROOT.getEnvironment()); }
/** * <p> * Creates scene elements that aren't meant to be manipulated by the user * (markers, camera, etc.) * </p> */ protected void setupSceneInternals(Group parent) { // Create scene plane for frame of reference. Box box = new Box(1000, 0, 1000); box.setMouseTransparent(true); box.setDrawMode(DrawMode.LINE); box.setMaterial(new PhongMaterial(Color.ANTIQUEWHITE)); AmbientLight ambientLight = new AmbientLight(Color.rgb(100, 100, 100)); PointLight light1 = new PointLight(Color.ANTIQUEWHITE); light1.setMouseTransparent(true); light1.setTranslateY(-350); PointLight light2 = new PointLight(Color.ANTIQUEWHITE); light2.setMouseTransparent(true); light2.setTranslateZ(350); PointLight light3 = new PointLight(Color.ANTIQUEWHITE); light3.setMouseTransparent(true); light3.setTranslateZ(-350); PointLight light4 = new PointLight(Color.ANTIQUEWHITE); light4.setMouseTransparent(true); light4.setTranslateZ(350); TransformGizmo gizmo = new TransformGizmo(1000); gizmo.showHandles(false); parent.getChildren().addAll(gizmo, box, light1, light2, light3, light4, ambientLight); }
@Override protected void setupSceneInternals(Group parent) { // Create scene plane for frame of reference. plane = new Box(1000, 0, 1000); plane.setMouseTransparent(true); plane.setDrawMode(DrawMode.LINE); plane.setMaterial(new PhongMaterial(Color.ANTIQUEWHITE)); AmbientLight ambientLight = new AmbientLight(Color.rgb(100, 100, 100)); PointLight light1 = new PointLight(Color.ANTIQUEWHITE); light1.setMouseTransparent(true); light1.setTranslateY(-350); PointLight light2 = new PointLight(Color.ANTIQUEWHITE); light2.setMouseTransparent(true); light2.setTranslateZ(350); PointLight light3 = new PointLight(Color.ANTIQUEWHITE); light3.setMouseTransparent(true); light3.setTranslateZ(-350); PointLight light4 = new PointLight(Color.ANTIQUEWHITE); light4.setMouseTransparent(true); light4.setTranslateZ(350); axes = new TransformGizmo(1000); axes.showHandles(false); parent.getChildren().addAll(axes, plane, light1, light2, light3, light4, ambientLight); }
/** * <p> * Creates scene elements that aren't meant to be manipulated by the user * (markers, camera, etc.) * </p> */ @Override protected void setupSceneInternals(Group parent) { // Create the ambient light AmbientLight ambientLight = new AmbientLight(Color.rgb(100, 100, 100)); // Create the point lights PointLight light1 = new PointLight(Color.ANTIQUEWHITE); light1.setMouseTransparent(true); light1.setTranslateY(-350); PointLight light2 = new PointLight(Color.ANTIQUEWHITE); light2.setMouseTransparent(true); light2.setTranslateZ(350); PointLight light3 = new PointLight(Color.ANTIQUEWHITE); light3.setMouseTransparent(true); light3.setTranslateZ(-350); PointLight light4 = new PointLight(Color.ANTIQUEWHITE); light4.setMouseTransparent(true); light4.setTranslateZ(350); // Create the background grid gizmo = new AxisGridGizmo(SCALE); // Add everything to the scene parent.getChildren().addAll(gizmo, light1, light2, light3, light4, ambientLight); }
public ShapeContainer(T shape) { this.shape = shape; this.material = new PhongMaterial(); this.emissive = new PointLight(); this.selfIllumination = new AmbientLight(); this.selfIllumination.getScope().add(ShapeContainer.this); initialize(); }
@Test public void testGetAmbientLightAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(AmbientLight.class); assertThat(adjuster, is(instanceOf(NodeAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Node.class))); }
private void buildLights() { AmbientLight ambientLight = new AmbientLight(Color.color(0.5, 0.5, 0.5)); // Since this is attached to root, X is right, Y is down, Z is back PointLight light1 = new PointLight(Color.WHITE); light1.setTranslateX(20); // right light1.setTranslateY(-20); // up light1.setTranslateZ(-20); // forward PointLight light2 = new PointLight(Color.color(0.6, 0.6, 0.6)); light2.setTranslateX(-20); // left light2.setTranslateY(-20); // up // light2.setTranslateZ(-20); // forward // PointLight light3 = new PointLight(Color.color(0.3, 0.3, 0.3)); // light3.setTranslateY(20); // bottom root.getChildren().addAll(ambientLight, light1, light2); }
@Override public void start(Stage stage) throws Exception { camera = new PerspectiveCamera(true); // setup camera transform for rotational support camera.setNearClip(0.1); camera.setFarClip(10000.0); camera.setTranslateZ(-20); makeYUp(camera); cameraTransform.setTranslate(0, 0, 0); cameraTransform.getChildren().add(camera); // cameraTransform.ry.setAngle(-45.0); // cameraTransform.rx.setAngle(-10.0); // add a Point Light for better viewing of the grid coordinate system PointLight point = new PointLight(Color.LIGHTSTEELBLUE); AmbientLight ambient = new AmbientLight(Color.LIGHTSKYBLUE); cameraTransform.getChildren().addAll(point, ambient); point.setTranslateX(camera.getTranslateX()); point.setTranslateY(camera.getTranslateY()); point.setTranslateZ(camera.getTranslateZ()); Group group = new Group(cameraTransform); Group sceneRoot = new Group(group); Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED); this.pointLight = point; this.ambientLight = ambient; configSceneColor(scene, point, ambient, cameraTransform); scene.setCamera(camera); makeObjects(group); setActions(scene); lastEffect = System.nanoTime(); AnimationTimer timerEffect = makeAnimation(); stage.setScene(scene); stage.show(); timerEffect.start(); }
@Override protected void configSceneColor(Scene scene, PointLight point, AmbientLight ambient, CameraTransformer lights) { scene.setFill(GRAY); // int c = 128; // int d = 192; // point.setColor(rgb(c, c, c + 32, 0.2)); // ambient.setColor(rgb(d, d, d, 0.9)); // point.setColor(rgb(221, 221, 221)); // point.setColor(rgb(240, 240, 240)); // ambient.setColor(rgb(51, 51, 51)); // ambient.setColor(rgb(201, 201, 201)); // ambient.setColor(rgb(78, 78, 78));// 0.3f ambient.setColor(rgb(240, 240, 240, 0.95)); point.setColor(rgb(179, 204, 204)); // 0.7, 0.8, 0.8 // point.setColor(BLACK); // ambient.setColor(BLUE); // AmbientLight ambient2 = new AmbientLight(Color.WHITE); // ambient2.setTranslateZ(1); // ambient2.setTranslateY(3); // lights.getChildren().add(ambient2); // scene.setOnKeyPressed(e -> { // KeyCode keyCode = e.getCode(); // }); // scene.setOnMouseClicked(e -> { // if (e.isSecondaryButtonDown()) { // brightness -= 0.1; // if (brightness < 0.1) brightness = 1; // } else { // saturation += 0.1; // if (saturation > 1) { // saturation = 0; // hue += 10; // } // } // // setMaterial(material, Color.hsb(hue, saturation, brightness)); // }); }
public AmbientLight getAmbient(){ if(type==LightType.Point){ return null; } return (AmbientLight)lightBase; }
public Parent createContent() throws Exception { Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm()); Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm()); Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm()); Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm()); material = new PhongMaterial(); material.setDiffuseColor(Color.WHITE); material.diffuseMapProperty().bind( Bindings.when(diffuseMap).then(dImage).otherwise((Image) null)); material.setSpecularColor(Color.TRANSPARENT); material.specularMapProperty().bind( Bindings.when(specularMap).then(sImage).otherwise((Image) null)); material.bumpMapProperty().bind( Bindings.when(bumpMap).then(nImage).otherwise((Image) null)); material.selfIlluminationMapProperty().bind( Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null)); earth = new Sphere(5); earth.setMaterial(material); earth.setRotationAxis(Rotate.Y_AXIS); // Create and position camera PerspectiveCamera camera = new PerspectiveCamera(true); camera.getTransforms().addAll( new Rotate(-20, Rotate.Y_AXIS), new Rotate(-20, Rotate.X_AXIS), new Translate(0, 0, -20)); sun = new PointLight(Color.rgb(255, 243, 234)); sun.translateXProperty().bind(sunDistance.multiply(-0.82)); sun.translateYProperty().bind(sunDistance.multiply(-0.41)); sun.translateZProperty().bind(sunDistance.multiply(-0.41)); sun.lightOnProperty().bind(sunLight); AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1)); // Build the Scene Graph Group root = new Group(); root.getChildren().add(camera); root.getChildren().add(earth); root.getChildren().add(sun); root.getChildren().add(ambient); RotateTransition rt = new RotateTransition(Duration.seconds(24), earth); rt.setByAngle(360); rt.setInterpolator(Interpolator.LINEAR); rt.setCycleCount(Animation.INDEFINITE); rt.play(); // Use a SubScene SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED); subScene.setFill(Color.TRANSPARENT); subScene.setCamera(camera); return new Group(subScene); }
public PolyLine3D(List<Point3D> points, int width, Color color) { this.points = points; this.width = width; this.color = color; setDepthTest(DepthTest.ENABLE); mesh = new TriangleMesh(); //add each point. For each point add another point shifted on Z axis by width //This extra point allows us to build triangles later for(Point3D point: points) { mesh.getPoints().addAll(point.x,point.y,point.z); mesh.getPoints().addAll(point.x,point.y,point.z+width); } //add dummy Texture Coordinate mesh.getTexCoords().addAll(0,0); //Now generate trianglestrips for each line segment for(int i=2;i<points.size()*2;i+=2) { //add each segment //Vertices wound counter-clockwise which is the default front face of any Triange //These triangles live on the frontside of the line facing the camera mesh.getFaces().addAll(i,0,i-2,0,i+1,0); //add primary face mesh.getFaces().addAll(i+1,0,i-2,0,i-1,0); //add secondary Width face //Add the same faces but wind them clockwise so that the color looks correct when camera is rotated //These triangles live on the backside of the line facing away from initial the camera mesh.getFaces().addAll(i+1,0,i-2,0,i,0); //add primary face mesh.getFaces().addAll(i-1,0,i-2,0,i+1,0); //add secondary Width face } //Need to add the mesh to a MeshView before adding to our 3D scene meshView = new MeshView(mesh); meshView.setDrawMode(DrawMode.FILL); //Fill so that the line shows width material = new PhongMaterial(color); material.setDiffuseColor(color); material.setSpecularColor(color); meshView.setMaterial(material); //Make sure you Cull the Back so that no black shows through meshView.setCullFace(CullFace.BACK); //Add some ambient light so folks can see it AmbientLight light = new AmbientLight(Color.WHITE); light.getScope().add(meshView); getChildren().add(light); getChildren().add(meshView); }
@Override public AmbientLight getSelfIlluminationLight() { return selfIllumination; }
@Override public Group scene3D() { Group group = new Group(); String[] ac = { /* Our star */ "Soleil", /* Planets */ "Mercure", "Venus", "Earth", "Mars", "Jupiter", "Saturne", "Uranus", "Neptune", /* Satellites */ "Moon", "Io", /* Others */ "Pluton", }; Planetoid[] astres = new Planetoid[ac.length]; int i = 0; double x = 0.0, dx = 20.0; for(String planetoid : ac) { System.out.println(planetoid); AstralCorpseBean bean = new AstralCorpseBean(); bean.load(MediaHelper.getURLForFile("/Solar System/" + planetoid + "/" + planetoid + ".ac")); bean.setRadius(10 /*bean.getRadius()*/); System.out.println(bean); final Planetoid corpse = new Planetoid(planetoid, bean.getRadius()); PlanetoidEnlightment.setTexture(corpse, "Solar System/" + planetoid + "/" + planetoid + ".png"); corpse.setTranslateX(x += dx); // corpse.animate(); astres[i++] = corpse; } Pivot p0 = new Pivot( 0, 0, 0); Pivot p1 = new Pivot(100, 100, 100); AmbientLight ambient = new AmbientLight(Color.WHITE); // PointLight light = new PointLight(Color.WHITE); // p1.getChildren().add(light); group.getChildren().addAll(ambient); group.getChildren().addAll(astres); // group.getChildren().addAll(new UniverseBox("redsky", 1e5)); group.getChildren().addAll(buildAxes(p0, 10), buildAxes(p1, 50)); return group; }
@Override public Group testObject3D() { root.getChildren().add(new AmbientLight(Color.color(0.1, 0.1, 0.1))); buildAxes(axis); Pivot p1 = new Pivot(-AXIS_LENGTH / 2, 0, -AXIS_LENGTH / 2); buildAxes(p1); Pivot p2 = new Pivot(AXIS_LENGTH / 2, 0, -AXIS_LENGTH / 2); buildAxes(p2); Pivot p3 = new Pivot(-AXIS_LENGTH / 2, 0, AXIS_LENGTH / 2); buildAxes(p3); Pivot p4 = new Pivot(AXIS_LENGTH / 2, 0, AXIS_LENGTH / 2); buildAxes(p4); Sphere s = new Sphere(100); s.setMaterial(PhongPhactory.fromImage("data/ball.jpg")); earth.getChildren().add(s); root.getChildren().add(earth); camera.getChildren().add(cam); PointLight l = new PointLight(Color.WHITE); light.getChildren().add(l); light.setPosition(300, -200, -300); buildAxes(light); // adding the axis will add light pivot to scene PointLight rl = new PointLight(Color.DARKRED); redLight.getChildren().add(rl); redLight.setPosition(-300, -200, 300); buildAxes(redLight); Box b = new Box(1200, 600, 1200); box.getChildren().add(b); box.setPosition(0, 0, 0); b.setCullFace(CullFace.FRONT); b.setMaterial(PhongPhactory.fromImage("/data/crate.jpg")); root.getChildren().add(box); Timeline t = new Timeline(new KeyFrame(Duration.millis(20), e -> { a = a + 0.02; earth.setEularRotation(a, -a * 4, -a); axis.setPosition(Math.cos(a) * (AXIS_LENGTH / 2), 0, Math.sin(a) * (AXIS_LENGTH / 2)); camera.setPosition(Math.cos(-a / 4) * (AXIS_LENGTH * 4), -AXIS_LENGTH, Math.sin(-a / 4) * (AXIS_LENGTH * 4)); camera.lookAt(axis.getPosition(), up); })); t.setCycleCount(Timeline.INDEFINITE); t.play(); return root; }
@Override public void start(Stage primaryStage) throws Exception { final PhongMaterial red = new PhongMaterial(Color.RED); final PhongMaterial green = new PhongMaterial(Color.GREEN); final PhongMaterial blue = new PhongMaterial(Color.BLUE); final Box cube = new Box(200, 200, 200); cube.setLayoutX(150); cube.setLayoutY(800); cube.setDrawMode(DrawMode.LINE); cube.setMaterial(red); final Cylinder cylinder = new Cylinder(150, 50); cylinder.setLayoutX(500); cylinder.setLayoutY(800); cylinder.setDrawMode(DrawMode.LINE); cylinder.setMaterial(green); final Sphere sphere = new Sphere(100); sphere.setLayoutX(850); sphere.setLayoutY(800); sphere.setDrawMode(DrawMode.LINE); sphere.setMaterial(blue); final AmbientLight light = new AmbientLight(Color.WHITE); final Pane root = new Pane(); root.setStyle("-fx-background-color: transparent;"); root.getChildren().addAll(cube, cylinder, sphere, light); final int[] tesselations = {1, 5, 10, 50, 100}; for (int index = 0; index < tesselations.length; index++) { final int dx = 1000 / tesselations.length; final int tesselation = tesselations[index]; final Sphere tesselatedSphere = new Sphere(75, tesselation); tesselatedSphere.setDrawMode(DrawMode.LINE); root.getChildren().add(tesselatedSphere); tesselatedSphere.setTranslateX(100 + dx * index); tesselatedSphere.setTranslateY(400); final Cylinder tesselatedCylinder = new Cylinder(75, 50, tesselation); tesselatedCylinder.setDrawMode(DrawMode.LINE); root.getChildren().add(tesselatedCylinder); tesselatedCylinder.setTranslateX(100 + dx * index); tesselatedCylinder.setTranslateY(100); } final Scene scene = new Scene(root, 1000, 1000); scene.setFill(Color.BLACK); scene.setCamera(new PerspectiveCamera()); primaryStage.setScene(scene); primaryStage.setTitle("Test_Triangle"); primaryStage.show(); }
public AmbientLight getAmbientLight() { return ambientLight; }
private Parent createContent() { Cube c = new Cube(1, Color.GREEN); c.setTranslateX(-1); c.setRotationAxis(Rotate.Y_AXIS); c.setRotate(45); Cube c2 = new Cube(1, Color.BLUE); c2.setTranslateX(1); c2.setRotationAxis(Rotate.Y_AXIS); c2.setRotate(45); Cube c3 = new Cube(1, Color.RED); c3.setRotationAxis(Rotate.Y_AXIS); c3.setRotate(45); camera = new PerspectiveCamera(true); translate = new Translate(0, 0, -10); rotate = new Rotate(0, new Point3D(0, 1, 0)); camera.getTransforms().addAll(translate, rotate); PointLight light = new PointLight(Color.WHITE); light.setTranslateX(3); light.setTranslateZ(-5); TranslateTransition tt = new TranslateTransition(Duration.seconds(2), light); tt.setFromX(-3); tt.setToX(3); tt.setAutoReverse(true); tt.setCycleCount(Animation.INDEFINITE); AmbientLight globalLight = new AmbientLight(Color.WHITE.deriveColor(0, 1, 0.2, 1)); worldRoot.getChildren().addAll(c, c2, c3, globalLight, light); SubScene subScene = new SubScene(worldRoot, 800, 600, true, SceneAntialiasing.BALANCED); subScene.setCamera(camera); tt.play(); return new Group(new Rectangle(800, 600), subScene); }
protected void configSceneColor(Scene scene, PointLight point, AmbientLight ambient, CameraTransformer lights) { scene.setFill(Color.BLACK); }
@Override public void start(Stage primaryStage) throws Exception { try { currentStage = primaryStage; ultraRoot = new Group(); // Create camera camera = new PerspectiveCamera(true); camera.setFarClip(100000); // and position it camera.getTransforms().addAll( new Rotate(0, Rotate.Y_AXIS), new Rotate(0, Rotate.X_AXIS), new Translate(0, 0, -50)); // add camera as node to scene graph VBox guiGroup = addGuiElements(); // Setup a scene SubScene subscene = createScene3D(ultraRoot, camera); VBox layout = new VBox( guiGroup, subscene); subscene.heightProperty().bind(layout.heightProperty()); subscene.widthProperty().bind(layout.widthProperty()); layout.setSpacing(0.0); scene = new Scene(layout, 1024, 768, true); scene.setFill(Color.DARKGRAY.darker().darker().darker().darker()); //Add the scene to the stage and show the stage PointLight light2 = new PointLight(Color.LIGHTGRAY); ultraRoot.getChildren().add(light2); light2.getTransforms().add(new Translate(-50, 10, -520)); AmbientLight light3 = new AmbientLight(new Color(0.35,0.35,0.35,1.0)); ultraRoot.getChildren().add(light3); primaryStage.setScene(scene); primaryStage.show(); handleKeyboard(scene, camera); //handleMouse(scene, camera); listener = new LeapMotionListener(); controller = new Controller(); controller.addListener(listener); addGlobalLeapMotionPropertyListener(); for (int i = 0; i < cArray.length; i++) { //initialize the cylinder array for the hand bones cArray[i] = new Cylinder(1, 1, 20); //using a fixed size array for the hand bones avoids memory issues cArray[i].setMouseTransparent(true); //but limits the max. amount of hands that can be registered at the same time //set it mouse transparent, so that it wont block the mouse click events by the robot cArray[i].setMaterial(handSphereMat); } } catch (Exception e) { e.printStackTrace(System.out); System.exit(1); } }
/**Creates a visualization of a .stl file. * * @param filePath the absolute file path of the .stl file * @param color the color the visualized file should have * @param ambient enables ambient light on the geometry * @param fill renders the faces or just shows the lines * @return the visualized STL file as a group node */ private Group buildSTL (String filePath,Color color, boolean ambient, boolean fill){ STLReader reader = new STLReader(filePath); reader.start(); reader.getFacetPoints(0); reader.getNormal(0); // reader.readFromAscii(); float[] vertices = reader.getVerticesFloatArray(); float[] normals = reader.getNormalsFloatArray(); TriangleMesh mesh = new TriangleMesh(); mesh.getPoints().addAll(vertices); mesh.getTexCoords().addAll(0,0); for (int i = 0; i < vertices.length/3 ; i+=3) { mesh.getFaces().addAll(i,0, i+1,0,i+2,0); } MeshView meshView = new MeshView(mesh); Group customGroup2 = new Group(); customGroup2.getChildren().add(meshView); if (null != color) { PhongMaterial material = new PhongMaterial(color); meshView.setMaterial(material); } if (ambient) { AmbientLight light = new AmbientLight(Color.WHITE); light.getScope().add(meshView); customGroup2.getChildren().add(light); } if(fill) { meshView.setDrawMode(DrawMode.FILL); } else { meshView.setDrawMode(DrawMode.LINE); //show lines only by default } meshView.setCullFace(CullFace.BACK); //Removing culling to show back lines return customGroup2; }
public AmbientLight getSelfIlluminationLight();