import java.io.File; import javafx.animation.Interpolator; import javafx.animation.RotateTransition; import javafx.animation.Timeline; import javafx.application.Application; import javafx.geometry.Point3D; import javafx.scene.AmbientLight; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.PointLight; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Sphere; import javafx.stage.Stage; import javafx.util.Duration; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author yaow */ public class RT31455 extends Application { public void start(Stage primaryStage) { Image bumpMap = new Image("/resources/Orange-bumpmap.png"); Image diffuseMap = new Image("/resources/Orange-diffusemap.png"); Color diffuseColor = Color.ORANGE; Color specularLight = Color.rgb(55, 55, 55); PhongMaterial material = new PhongMaterial(); // material.setSpecularColor(specularLight); material.setDiffuseMap(diffuseMap); material.setBumpMap(bumpMap); Sphere sphere = new Sphere(200); sphere.setMaterial(material); sphere.setLayoutX(300); sphere.setLayoutY(300); AmbientLight ambientLight = new AmbientLight(); ambientLight.setColor(Color.rgb(255, 255, 255, 0.15)); PointLight pointLight = new PointLight(); pointLight.setColor(Color.WHITE); pointLight.setLayoutX(200); pointLight.setLayoutY(-100); pointLight.setTranslateZ(-1100); pointLight.getScope().add(sphere); Group content = new Group(); content.getChildren().addAll(sphere, pointLight, ambientLight); Scene scene = new Scene(content, 600, 600, true); scene.setFill(Color.BLACK); PerspectiveCamera camera = new PerspectiveCamera(false); scene.setCamera(camera); primaryStage.setTitle("3D World"); primaryStage.setScene(scene); primaryStage.show(); RotateTransition rotateTransition = new RotateTransition(); rotateTransition.setAxis(new Point3D(0, 1, 0)); rotateTransition.setDuration(Duration.seconds(30)); rotateTransition.setByAngle(360); rotateTransition.setCycleCount(Timeline.INDEFINITE); rotateTransition.setInterpolator(Interpolator.LINEAR); rotateTransition.setNode(sphere); rotateTransition.play(); } public static void main(String[] args) { launch(args); } }