Advertisement
MagnusArias

KCK | Zad 6

Nov 8th, 2016
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 KB | None | 0 0
  1. package javafxapplication5;
  2.  
  3. import javafx.animation.RotateTransition;
  4. import javafx.application.Application;
  5. import javafx.scene.Group;
  6. import javafx.scene.PerspectiveCamera;
  7. import javafx.scene.Scene;
  8. import javafx.scene.SceneAntialiasing;
  9. import javafx.scene.image.Image;
  10. import javafx.scene.paint.Color;
  11. import javafx.scene.paint.PhongMaterial;
  12. import javafx.scene.shape.Cylinder;
  13. import javafx.scene.shape.Sphere;
  14. import javafx.scene.transform.Rotate;
  15. import javafx.stage.Stage;
  16. import javafx.util.Duration;
  17.  
  18. public class JavaFXApplication5 extends Application {
  19.    
  20.     @Override
  21.     public void start(Stage primaryStage) {
  22.      
  23.         PhongMaterial mat1 = new PhongMaterial();
  24.         //mat1.setDiffuseColor(Color.CYAN);
  25.         mat1.setDiffuseMap(new Image(getClass().getResource("dif.jpg").toExternalForm()));
  26.         mat1.setBumpMap(new Image(getClass().getResource("bumg.jpg").toExternalForm()));
  27.         mat1.setSpecularMap(new Image(getClass().getResource("specular.jpg").toExternalForm()));
  28.        
  29.         Sphere sphere = new Sphere((1080/2)-20);
  30.         sphere.setTranslateX(1920/2);
  31.         sphere.setTranslateY(1080/2);
  32.         sphere.setMaterial(mat1);
  33.        
  34.        /* Cylinder cylinder = new Cylinder(300,100);
  35.         cylinder.setTranslateX(600);
  36.         cylinder.setTranslateY(400);*/
  37.        
  38.         RotateTransition rotTrans = new RotateTransition();
  39.         rotTrans.setDuration(Duration.millis(25000));
  40.         rotTrans.setNode(sphere);
  41.         rotTrans.setByAngle(360);
  42.         rotTrans.setAxis(Rotate.Y_AXIS);
  43.         rotTrans.setCycleCount(-1);
  44.         rotTrans.setAutoReverse(false);
  45.        
  46.        
  47.        /* Rotate rx = new Rotate(0,0,0,0, Rotate.X_AXIS);
  48.         Rotate ry = new Rotate(0,0,0,0, Rotate.Y_AXIS);
  49.         Rotate rz = new Rotate(0,0,0,0, Rotate.Z_AXIS);
  50.         rx.setAngle(45);
  51.         ry.setAngle(30);
  52.         rz.setAngle(50);
  53.        
  54.         cylinder.getTransforms().addAll(rz,ry,rz);*/
  55.        
  56.         Group root = new Group(sphere);
  57.        //root.setTranslateZ(500);
  58.         Scene scene = new Scene(root, 1920, 1080, true, SceneAntialiasing.BALANCED);
  59.         scene.setFill(Color.BLACK);
  60.         scene.setCamera(new PerspectiveCamera());
  61.        
  62.         primaryStage.setTitle("TRZYFEEDEFIX");
  63.         primaryStage.setScene(scene);
  64.         primaryStage.show();
  65.        
  66.         rotTrans.play();
  67.     }
  68.  
  69.     public static void main(String[] args) {
  70.         launch(args);
  71.     }
  72.    
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement