javafx.scene.AmbientLight#javafx.scene.PointLight源码实例Demo

下面列出了javafx.scene.AmbientLight#javafx.scene.PointLight 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FXyzLib   文件: Drag3DObject.java
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);

}
 
源代码2 项目: mzmine3   文件: Fx3DStageController.java
private void addLights() {
  top = new PointLight(Color.WHITE);
  top.setTranslateX(SIZE / 2);
  top.setTranslateZ(SIZE / 2);
  top.setTranslateY(-1000);

  bottom = new PointLight(Color.WHITE);
  bottom.setTranslateX(SIZE / 2);
  bottom.setTranslateZ(SIZE / 2);
  bottom.setTranslateY(1000);

  left = new PointLight(Color.WHITE);
  left.setTranslateX(-1000);
  left.setTranslateZ(-SIZE);
  left.setTranslateY(-500);

  right = new PointLight(Color.WHITE);
  right.setTranslateX(1500);
  right.setTranslateZ(-SIZE);
  right.setTranslateY(-500);

  front = new PointLight(Color.WHITE);
  front.setTranslateX(SIZE / 2);
  front.setTranslateZ(-1000);
  front.setTranslateY(-500);

  back = new PointLight(Color.WHITE);
  back.setTranslateX(SIZE / 2);
  back.setTranslateZ(1000);
  back.setTranslateY(-500);

  lights.getChildren().add(front);
  lights.getChildren().add(back);
  lights.getChildren().add(top);
  lights.getChildren().add(bottom);
}
 
源代码3 项目: mzmine2   文件: Fx3DStageController.java
private void addLights() {
    top = new PointLight(Color.WHITE);
    top.setTranslateX(SIZE / 2);
    top.setTranslateZ(SIZE / 2);
    top.setTranslateY(-1000);

    bottom = new PointLight(Color.WHITE);
    bottom.setTranslateX(SIZE / 2);
    bottom.setTranslateZ(SIZE / 2);
    bottom.setTranslateY(1000);

    left = new PointLight(Color.WHITE);
    left.setTranslateX(-1000);
    left.setTranslateZ(-SIZE);
    left.setTranslateY(-500);

    right = new PointLight(Color.WHITE);
    right.setTranslateX(1500);
    right.setTranslateZ(-SIZE);
    right.setTranslateY(-500);

    front = new PointLight(Color.WHITE);
    front.setTranslateX(SIZE / 2);
    front.setTranslateZ(-1000);
    front.setTranslateY(-500);

    back = new PointLight(Color.WHITE);
    back.setTranslateX(SIZE / 2);
    back.setTranslateZ(1000);
    back.setTranslateY(-500);

    lights.getChildren().add(front);
    lights.getChildren().add(back);
    lights.getChildren().add(top);
    lights.getChildren().add(bottom);
}
 
源代码4 项目: FXyzLib   文件: ShapeContainer.java
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();
}
 
源代码5 项目: FXyzLib   文件: CubeViewer.java
private void init(){
    buildAxes(axesSize, axesThickness);
    buildPanels(axesSize);
    buildGrids(axesSize, gridLineSpacing);
    buildEventHandlers();        
    getChildren().add(scatterDataGroup); //Holds ScatterPlot data
    if(selfLightEnabled) {
        PointLight light = new PointLight(Color.WHITE);
        getChildren().add(light);
    }
    setDepthTest(DepthTest.ENABLE);
}
 
源代码6 项目: mars-sim   文件: Simple3DSphereApp.java
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);
    }
 
源代码7 项目: FXTutorials   文件: Tutorial.java
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);
}
 
源代码8 项目: FXyzLib   文件: ShapeContainer.java
@Override
public PointLight getEmissiveLight() {
    return emissive;
}
 
源代码9 项目: FXyzLib   文件: AdvancedCamera.java
public PointLight getHeadLight() {
    return headLight;
}
 
源代码10 项目: FXyzLib   文件: BillBoardBehaviorTest.java
private void createSubscene(){        
    subScene = new SubScene(root, 800, 600, true, SceneAntialiasing.BALANCED);
    
    camera = new PerspectiveCamera(true);
    cameraTransform.setTranslate(0, 0, 0);
    cameraTransform.getChildren().addAll(camera);
    camera.setNearClip(0.1);
    camera.setFarClip(100000.0);
    camera.setFieldOfView(35);
    camera.setTranslateZ(-cameraDistance);
    cameraTransform.ry.setAngle(-45.0);
    cameraTransform.rx.setAngle(-10.0);
    //add a Point Light for better viewing of the grid coordinate system
    PointLight light = new PointLight(Color.WHITE);
    
    cameraTransform.getChildren().add(light);
    light.setTranslateX(camera.getTranslateX());
    light.setTranslateY(camera.getTranslateY());
    light.setTranslateZ(camera.getTranslateZ());
            
    root.getChildren().add(cameraTransform);
    subScene.setCamera(camera);
    
    initFirstPersonControls(subScene);
    
    skyBox = new Skybox(new Image("http://www.zfight.com/misc/images/textures/envmaps/violentdays_large.jpg"), 100000, camera);      
   
    //Make a bunch of semi random Torusesessses(toroids?) and stuff : from torustest
    Group torusGroup = new Group();        
    for (int i = 0; i < 10; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat() * 300) + 50);
        float randomTubeRadius = (float) ((r.nextFloat() * 100) + 1);
        int randomTubeDivisions = (int) ((r.nextFloat() * 64) + 1);
        int randomRadiusDivisions = (int) ((r.nextFloat() * 64) + 1);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        boolean ambientRandom = r.nextBoolean();
        boolean fillRandom = r.nextBoolean();
        
        if(i == 0){                
            torusGroup.getChildren().add(bill);
        }
        TorusMesh torus = new TorusMesh(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius);
        
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        torus.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        //torus.getTransforms().add(translate);
        torusGroup.getChildren().add(torus);
    }
    root.getChildren().addAll(skyBox, torusGroup);
    
    rootPane.getChildren().add(subScene);
    //Enable subScene resizing
    subScene.widthProperty().bind(rootPane.widthProperty());
    subScene.heightProperty().bind(rootPane.heightProperty());
    subScene.setFocusTraversable(true);
    
}
 
源代码11 项目: FXyzLib   文件: SpheroidTest.java
@Override
public void start(Stage stage) {
    
    Group spheroidGroup = new Group();        
    for (int i = 0; i < 50; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomMajorRadius = (float) ((r.nextFloat() * 300) + 50);
        float randomMinorRadius = (float) ((r.nextFloat() * 300) + 50);
        int randomDivisions = (int) ((r.nextFloat() * 64) + 1);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Spheroid sm = new Spheroid(randomDivisions, randomMajorRadius, randomMinorRadius, randomColor);               
        sm.setDrawMode(DrawMode.LINE);
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        sm.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        spheroidGroup.getChildren().add(sm);
    }
    root.getChildren().add(spheroidGroup);
    
    System.out.println(spheroidGroup.getChildren().size());
    
    camera = new PerspectiveCamera(true);
    cameraTransform.setTranslate(0, 0, 0);
    cameraTransform.getChildren().addAll(camera);
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setTranslateZ(cameraDistance);
    cameraTransform.ry.setAngle(-45.0);
    cameraTransform.rx.setAngle(-10.0);
    //add a Point Light for better viewing of the grid coordinate system
    PointLight light = new PointLight(Color.WHITE);
    
    cameraTransform.getChildren().add(light);
    light.setTranslateX(camera.getTranslateX());
    light.setTranslateY(camera.getTranslateY());
    light.setTranslateZ(camera.getTranslateZ());
    root.getChildren().add(cameraTransform);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    initFirstPersonControls(scene);
    
    stage.setTitle("Hello World!");
    stage.setScene(scene);
    stage.show();
}
 
源代码12 项目: FXyzLib   文件: SurfacePlotTest.java
@Override
public void start(Stage primaryStage) throws Exception {
    Group sceneRoot = new Group();
    Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
    scene.setFill(Color.BLACK);
    camera = new PerspectiveCamera(true);        
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setTranslateZ(-1000);
    scene.setCamera(camera);
    int size = 10;
    float [][] arrayY = new float[2*size][2*size];
    //The Sombrero
    for(int i=-size;i<size;i++) {
        for(int j=-size;j<size;j++) {
            double R = Math.sqrt((i * i)  + (j * j)) + 0.00000000000000001;
            arrayY[i+size][j+size] = ((float) -(Math.sin(R)/R)) * 100;
        }
    }
    surfacePlot = new SurfacePlot(arrayY, 10, Color.AQUA, false, false);

    sceneRoot.getChildren().addAll(surfacePlot);

    PointLight light = new PointLight(Color.WHITE);
    sceneRoot.getChildren().add(light);
    light.setTranslateZ(sceneWidth / 2);
    light.setTranslateY(-sceneHeight + 10);

    PointLight light2 = new PointLight(Color.WHITE);
    sceneRoot.getChildren().add(light2);
    light2.setTranslateZ(-sceneWidth + 10);
    light2.setTranslateY(-sceneHeight + 10);
    
    scene.setOnKeyPressed(event -> {
        double change = 10.0;
        //Add shift modifier to simulate "Running Speed"
        if(event.isShiftDown()) { change = 50.0; }
        //What key did the user press?
        KeyCode keycode = event.getCode();
        //Step 2c: Add Zoom controls
        if(keycode == KeyCode.W) { camera.setTranslateZ(camera.getTranslateZ() + change); }
        if(keycode == KeyCode.S) { camera.setTranslateZ(camera.getTranslateZ() - change); }
        //Step 2d:  Add Strafe controls
        if(keycode == KeyCode.A) { camera.setTranslateX(camera.getTranslateX() - change); }
        if(keycode == KeyCode.D) { camera.setTranslateX(camera.getTranslateX() + change); }
    });        
    
    //Add a Mouse Handler for Rotations
    Rotate xRotate = new Rotate(0, Rotate.X_AXIS);
    Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);
    Rotate zRotate = new Rotate(0, Rotate.Z_AXIS);
    
    surfacePlot.getTransforms().addAll(xRotate, yRotate, zRotate);
    //Use Binding so your rotation doesn't have to be recreated
    xRotate.angleProperty().bind(angleX);
    yRotate.angleProperty().bind(angleY);
    zRotate.angleProperty().bind(angleZ);
    
    //Start Tracking mouse movements only when a button is pressed
    scene.setOnMousePressed(event -> {
        scenex = event.getSceneX();
        sceney = event.getSceneY();
        fixedXAngle = angleX.get();
        fixedYAngle = angleY.get();
        if(event.isMiddleButtonDown()) {
            scenez = event.getSceneX();
            fixedZAngle = angleZ.get();
        }
        
    });
    //Angle calculation will only change when the button has been pressed
    scene.setOnMouseDragged(event -> {
        if(event.isMiddleButtonDown()) 
            angleZ.set(fixedZAngle - (scenez - event.getSceneY()));
        else
            angleX.set(fixedXAngle - (scenex - event.getSceneY()));
        angleY.set(fixedYAngle + sceney - event.getSceneX());
    });        
    
    primaryStage.setTitle("F(X)yz SurfacePlotTest");
    primaryStage.setScene(scene);
    primaryStage.show();        
}
 
源代码13 项目: FXyzLib   文件: ShapeContainerBase.java
public PointLight getEmissiveLight();