Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D Shapes 3개 핵심 Properties가 존재 1.Material 표면의 재질을 설정합니다.

Similar presentations


Presentation on theme: "3D Shapes 3개 핵심 Properties가 존재 1.Material 표면의 재질을 설정합니다."— Presentation transcript:

1 3D Shapes 3개 핵심 Properties가 존재 1.Material 표면의 재질을 설정합니다.
Type은 추상 class Material. 구현된 파생 class PhongMaterial. 2.DrawMode 개체의 그리는 방법을 설정한다. Type은 enum DrawMode. Member Line : polygon을 Wireframe으로 그린다. Member Fill : polygon을 면으로 그린다. 3.CullFace 3D Shape의 Face의 전면 후면중,제외시킬 대상을 설정한다. Type은 enum CullFace. Member None : Culling을 하지 않는다. Member Back : 후면을 제외한다. Member Front : 전면을 제외한다.

2 3D Shapes public void start(Stage primaryStage) { //Shape3D 파생 클래스를 선언
Box box = new Box(100, 100, 100); //표면의 재질을 설정한다. box.setMaterial(new PhongMaterial(Color.AQUAMARINE)); //개체의 그리는 방법을 설정한다. box.setDrawMode(DrawMode.LINE); //다면체의 면을 추려내는 방법 설정 box.setCullFace(CullFace.BACK); //생성된 개체를 화면에 추가. Group shapGroup = new Group(box); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

3 3D Shapes 테스트를 위한 추가적인 속성 RotationAxis 대상 Shape의 회전축(x,y,z)을 지정할 수 있다. 각 대상 축을 양수로 지정할 경우는 각 축에서 중심을 바라보는 기준으로 시계방향으로 회전한다. 각 대상 축을 음수로 지정할 경우는 각 축에서 중심을 바라보는 기준으로 반 시계방향으로 회전한다. Rotate RotationAxis를 기준으로 Shape를 설정한 각도만큼 회전시킨다. TranslateX 대상의 X축 위치를 변형한다. TranslateY 대상의 Y축 위치를 변형한다. TranslateZ 대상의 Z축 위치를 변형한다.

4 3D Shapes public void start(Stage primaryStage) {
Box box = new Box(100, 100, 100); //표면의 재질을 설정한다. box.setMaterial(new PhongMaterial(Color.AQUAMARINE)); //개체의 그리는 방법을 설정한다. //box.setDrawMode(DrawMode.LINE); //다면체의 면을 추려내는 방법 설정 box.setCullFace(CullFace.BACK); //회전의 기준을 X축으로 지정한다, 양수 일 경우는 시계방향,음수 일 경우는 반시계방향으로 회전한다. box.setRotationAxis(new Point3D(1, 0, 0)); //개체를 특정 angle만큼 회전시킨다. box.setRotate(20); //생성된 개체를 화면에 추가. Group shapGroup = new Group(box); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

5 3D Shapes 파생 클래스 별 특성 1.정의된 클래스
Sphere Sphere() – 기본값으로 Sphere를 생성한다. (Default Radius 1, Default Division 64 ) Sphere(double radius) – Sphere의 반경을 지정하여 생성한다. Sphere(double radius, int divisions) – Sphere의 반경을 지정, Sphere를 구성하는 면의 분열 개수를 설정. ( 최소값은 1이며, 1보다 작은값이 설정되더라도 1이하로는 변경되지 않는다.) Cylinder Cylinder() – 기본값으로 Cylinder를 생성한다. (Default Radius 1, Default Height 2, Default Division 64 ) Cylinder (double radius, double height) – Cylinder의 반경,높이를 지정하여 생성한다. Cylinder (double radius, double height, int divisions) - Cylinder의 반경,높이를 지정 , Cylinder를 구성하는 면의 분열 개수를 설정. ( 최소값은 3이며, 3보다 작은값이 설정되더라도 3이하로는 변경되지 않는다.) Box Box() – 기본값으로 Box를 생성한다. (Default Width 2, Default Height 2, Default Depth 2 ) Box(double width, double height, double depth) – Box크기를 지정하여 생성한다,(Width X, Height Y, Depth Z)

6 3D Shapes Box example public void start(Stage primaryStage) {
//Box의 width(x축 길이), height(y축 길이), depth(z축 길이)를 지정한다. Box box = new Box(100,20,300); //표면의 재질을 설정한다. box.setMaterial(new PhongMaterial(Color.AQUAMARINE)); //개체의 그리는 방법을 설정한다. box.setDrawMode(DrawMode.LINE); //다면체의 면을 추려내는 방법 설정 box.setCullFace(CullFace.BACK); //회전의 기준을 X축으로 지정한다, 양수 일 경우는 시계방향,음수 일 경우는 반시계방향으로 회전한다. box.setRotationAxis(new Point3D(1, 1, 0)); //개체를 특정 angle만큼 회전시킨다. box.setRotate(20); Group shapGroup = new Group(box); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

7 3D Shapes Cylinder example public void start(Stage primaryStage) {
//구의 반경과, 구 의 면 분열 개수를 지정. Cylinder cylinder = new Cylinder(100,100,2); //표면의 재질을 설정한다. cylinder.setMaterial(new PhongMaterial(Color.AQUAMARINE)); //개체의 그리는 방법을 설정한다. cylinder.setDrawMode(DrawMode.LINE); //다면체의 면을 추려내는 방법 설정 cylinder.setCullFace(CullFace.BACK); //회전의 기준을 X,Y축으로 지정한다, 양수 일 경우는 시계방향,음수 일 경우는 반시계방향으로 회전한다. cylinder.setRotationAxis(new Point3D(1, 1, 0)); //개체를 특정 angle만큼 회전시킨다. cylinder.setRotate(20); Group shapGroup = new Group(cylinder); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

8 3D Shapes Sphere example public void start(Stage primaryStage) {
//구의 반경과, 구 의 면 분열 개수를 지정. Sphere sphere = new Sphere(100,1); //표면의 재질을 설정한다. sphere.setMaterial(new PhongMaterial(Color.AQUAMARINE)); //개체의 그리는 방법을 설정한다. sphere.setDrawMode(DrawMode.LINE); //다면체의 면을 추려내는 방법 설정 sphere.setCullFace(CullFace.BACK); //회전의 기준을 X,Y축으로 지정한다, 양수 일 경우는 시계방향,음수 일 경우는 반시계방향으로 회전한다. sphere.setRotationAxis(new Point3D(1, 1, 0)); //개체를 특정 angle만큼 회전시킨다. sphere.setRotate(20); Group shapGroup = new Group(sphere); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

9 3D Shapes 파생 클래스 별 특성 2.사용자 정의 클래스
MeshView Points - 3차원 형상의 모든 꼭지점의 좌표 정보. TexCoords – 3D Shape에 Face별로 질감을 입할 좌표 정보를 입력한다. Faces – 면을 구성하는 Points,TextCoords의 정보. FaceSmoothingGroups – 면을 연결할 그룹의 정보.

10 3D Shapes MeshView example 1.1 public void start(Stage primaryStage) {
MeshView meshView = new MeshView(createPyramid()); //개체의 그리는 방법을 설정한다. meshView.setDrawMode(DrawMode.FILL); //표면의 재질을 설정한다. PhongMaterial mat = new PhongMaterial(); mat.setDiffuseMap(new Image(getClass().getResourceAsStream("brush.png"))); meshView.setMaterial(mat); //다면체의 면을 추려내는 방법 설정. meshView.setCullFace(CullFace.BACK); //회전의 기준을 X축으로 지정한다, 양수 일 경우는 시계방향,음수 일 경우는 반시계방향으로 회전한다. meshView.setRotationAxis(new Point3D(1, 1, 0)); //개체를 특정 angle만큼 회전시킨다. meshView.setRotate(20); Group shapGroup = new Group(meshView); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

11 3D Shapes MeshView example 1.2 private TriangleMesh createPyramid() {
float h = 150; // Height float w = 300; // Side TriangleMesh mesh = new TriangleMesh(); mesh.getPoints().addAll( 0, 0, 0, // Point 0 - Top 0, h, -w / 2, // Point 1 - Front -w / 2, h, 0, // Point 2 - Left w / 2, h, 0, // Point 3 - Right 0, h, w / 2 // Point 4 - Back ); mesh.getTexCoords().addAll( 0.1f, 0.5f, // 0 red 0.3f, 0.5f, // 1 green 0.5f, 0.5f, // 2 blue 0.7f, 0.5f, // 3 yellow 0.9f, 0.5f // 4 orange mesh.getFaces().addAll( 0, 0, 2, 0, 1, 0, // Front left face 0, 1, 1, 1, 3, 4, // Front right face 0, 0, 3, 0, 4, 0, // Back right face 0, 0, 4, 0, 2, 0, // Back left face 4, 0, 1, 0, 2, 0, // Bottom rear face 4, 0, 3, 0, 1, 0 // Bottom front face mesh.getFaceSmoothingGroups().addAll(0,0,0,0); return mesh; }

12 3D Shapes MeshView.FaceSmoothingGroups example 1.1
public void start(Stage primaryStage) { MeshView meshView = new MeshView(createPyramid()); //개체의 그리는 방법을 설정한다. meshView.setDrawMode(DrawMode.FILL); //표면의 재질을 설정한다. PhongMaterial mat = new PhongMaterial(Color.HOTPINK); meshView.setMaterial(mat); //다면체의 면을 추려내는 방법 설정. meshView.setCullFace(CullFace.NONE); //회전의 기준을 X축으로 지정한다, 양수 일 경우는 시계방향,음수 일 경우는 반시계방향으로 회전한다. meshView.setRotationAxis(new Point3D(1, 1, 0)); //개체를 특정 angle만큼 회전시킨다. meshView.setRotate(20); Group shapGroup = new Group(meshView); BorderPane root = new BorderPane(shapGroup, null, null, null, null); Scene scene = new Scene(root, 640, 480); primaryStage.setScene(null); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }

13 3D Shapes MeshView.FaceSmoothingGroups example 1.2
private TriangleMesh createPyramid() { float h = 300; // Height float w = 300; // Side TriangleMesh mesh = new TriangleMesh(); mesh.getPoints().addAll( 0, 0, 0, // Point 0 - LeftTop w, 0,100, // Point 1 - RightTop 0, h, 100, // Point 2 - LeftBottom w, h, // Point 3 - RightBottom ); //TextureCoordinates위치 정보를 설정한다. mesh.getTexCoords().addAll( 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f mesh.getFaces().addAll( 0, 0, 2, 2, 3, 3, // Front LeftBottom face 0, 0, 3, 3, 1, 1 // Front RightTop face //Face와 Face가 만나는 부분을 SmootingGroup로 설정한다. //mesh.getFaceSmoothingGroups().addAll(0,0); mesh.getFaceSmoothingGroups().addAll(1,1); return mesh; }


Download ppt "3D Shapes 3개 핵심 Properties가 존재 1.Material 표면의 재질을 설정합니다."

Similar presentations


Ads by Google