2024-04-01

This commit is contained in:
2024-04-01 20:11:09 +09:00
parent a2349837be
commit c4291c2746
26 changed files with 464 additions and 34 deletions

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) 2024. Elex. All Rights Reesrved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples.three_d;
import javafx.scene.Camera;
import javafx.scene.PerspectiveCamera;
public class Cameras {
public static Camera camera(){
final Camera camera = new PerspectiveCamera();
return camera;
}
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024. Elex. All Rights Reesrved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples.three_d;
import javafx.scene.AmbientLight;
import javafx.scene.PointLight;
import javafx.scene.paint.Color;
public class Lights {
public static PointLight pointLight() {
final PointLight light = new PointLight();
light.setColor(Color.YELLOW);
return light;
}
public static AmbientLight ambientLight() {
final AmbientLight light = new AmbientLight();
light.setColor(Color.GOLD);
return light;
}
}

View File

@@ -0,0 +1,9 @@
/*
* Copyright (c) 2024. Elex. All Rights Reesrved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples.three_d;
public class Materials {
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2024. Elex. All Rights Reesrved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples.three_d;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.shape.DrawMode;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;
public class MyApplication extends Application {
private Parent content(){
Box box = new Box(5,5,5);
box.setMaterial(new PhongMaterial(Color.RED));
box.setDrawMode(DrawMode.LINE);
Camera camera = new PerspectiveCamera(true);
camera.getTransforms().addAll(
new Rotate(-20, Rotate.Y_AXIS),
new Rotate(-20,Rotate.X_AXIS),
new Translate(0,0,-15)
);
Group root = new Group();
root.getChildren().add(box);
root.getChildren().add(camera);
SubScene subScene = new SubScene(root, 300, 300);
subScene.setFill(Color.ALICEBLUE);
subScene.setCamera(camera);
Group group = new Group();
group.getChildren().add(subScene);
return group;
}
public static void main(String... args){
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("3D Example");
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(content()));
primaryStage.show();
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024. Elex. All Rights Reesrved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples.three_d;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.shape.Cylinder;
import javafx.scene.shape.Sphere;
import javafx.scene.shape.TriangleMesh;
public class Shapes {
public static Box box(){
final Box shape = new Box(100, 100, 30);
final PhongMaterial material = new PhongMaterial();
material.setSpecularColor(Color.ORANGE);
material.setDiffuseColor(Color.RED);
shape.setMaterial(material);
return shape;
}
public static Cylinder cylinder(){
final Cylinder shape = new Cylinder(100, 100);
final PhongMaterial material = new PhongMaterial();
material.setSpecularColor(Color.BLUE);
material.setDiffuseColor(Color.LIGHTBLUE);
shape.setMaterial(material);
return shape;
}
public static Sphere sphere(){
final Sphere shape = new Sphere(100);
final PhongMaterial material = new PhongMaterial();
material.setSpecularColor(Color.BLUE);
material.setDiffuseColor(Color.LIGHTBLUE);
shape.setMaterial(material);
return shape;
}
public static TriangleMesh triangleMesh(){
final TriangleMesh shape = new TriangleMesh();
final float[] points = {};
shape.getPoints().addAll(points);
final float[] texCoords = {};
shape.getTexCoords().addAll(texCoords);
final int[] faces = {};
shape.getFaces().addAll(faces);
final int[] smoothingGroups = {};
shape.getFaceSmoothingGroups().addAll(smoothingGroups);
return shape;
}
}

View File

@@ -0,0 +1,6 @@
/*
* Copyright (c) 2024. Elex. All Rights Reesrved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples.three_d;

View File

@@ -0,0 +1,7 @@
module javafx.examples.fxml.main {
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
exports kr.pe.elex.examples.three_d;
}