Está en la página 1de 25

Unidad 3: Paso 4 - Solución práctica

Entregado por:

Tutor:

CELSO JAVIER RODRIGUEZ PIZZA

Universidad nacional abierta y a distancia

2021

2021161
DESARROLLO PASO 4

TIPO DE ACTIVIDAD: Individual

IMAGENES DE LA SOLUCION PROPUESTA

1. En el siguiente cuadro se debe presentar 5 imágenes (pantallazos) de la


solución propuesta.

2021161
2021161
2021161
2. Código de la solución propuesta comentando cada transformación (rotar en
el mismo eje, mover o desplazar, girar a la derecha, izquierda, arriba,
abajo, cambio de tamaño, etc.) de las imágenes.
Una imagen solo debe llevar una transformación. Las cinco imágenes deben
llevar transformaciones diferentes.

Codigo

package javafx;

import com.javafx.experiments.importers.Importer3D;

import javafx.animation.*;

import javafx.application.Application;

import javafx.geometry.Point3D;

import javafx.scene.*;

import javafx.scene.paint.Color;

import javafx.stage.Stage;

import javafx.util.Duration;

import java.io.IOException;

public class HelloWorld extends Application {

@Override

public void start(Stage primaryStage) throws Exception {

Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(10), ev -> {

try {

loadScene3D(primaryStage);

2021161
} catch (IOException e) {

e.printStackTrace();

}));

timeline.setCycleCount(1);

timeline.play();

Timeline timeline2 = new Timeline(new KeyFrame(Duration.seconds(10), ev -> {

try

timeline.stop();

loadScene3D2(primaryStage);

} catch(IOException e)

e.printStackTrace();

}));

timeline2.setCycleCount(1);

timeline2.setDelay(Duration.millis(10000));

timeline2.play();

Timeline timeline3 = new Timeline(new KeyFrame(Duration.seconds(10), ev -> {

try

timeline2.stop();

loadScene3D3(primaryStage);

2021161
} catch(IOException e)

e.printStackTrace();

}));

timeline3.setCycleCount(1);

timeline3.setDelay(Duration.millis(20000));

timeline3.play();

Timeline timeline4 = new Timeline(new KeyFrame(Duration.seconds(10), ev -> {

try

timeline3.stop();

loadScene3D4(primaryStage);

} catch(IOException e)

e.printStackTrace();

}));

timeline4.setCycleCount(1);

timeline4.setDelay(Duration.millis(30000));

timeline4.play();

Timeline timeline5 = new Timeline(new KeyFrame(Duration.seconds(10), ev -> {

try

2021161
timeline4.stop();

loadScene3D5(primaryStage);

} catch(IOException e)

e.printStackTrace();

}));

timeline5.setCycleCount(1);

timeline5.setDelay(Duration.millis(40000));

timeline5.play();

Timeline timeline6 = new Timeline(new KeyFrame(Duration.seconds(10), ev -> {

try

timeline5.stop();

loadScene3D6(primaryStage);

} catch(IOException e)

e.printStackTrace();

}));

timeline6.setCycleCount(1);

timeline6.setDelay(Duration.millis(50000));

timeline6.play();

//loadScene3D(primaryStage);

2021161
private void loadScene3D(Stage stage) throws IOException {

AmbientLight light1 = new AmbientLight();

Node model = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model.setScaleX(1600.0);

model.setScaleY(1600.0);

model.setScaleZ(1600.0);

Group root = new Group(model, light1);

Scene scene1 = new Scene(root, 1280, 650, true, SceneAntialiasing.BALANCED);

PerspectiveCamera camera = new PerspectiveCamera();

camera.setTranslateX(scene1.getWidth() / -2.0);

camera.setTranslateY(scene1.getHeight() / -2.0);

RotateTransition rt = new RotateTransition(Duration.seconds(10), model);

rt.setCycleCount(Animation.INDEFINITE);

rt.setFromAngle(0);

rt.setToAngle(360);

rt.setAxis(new Point3D(0, 1, 0));

rt.play();

TranslateTransition tr = new TranslateTransition(Duration.seconds(5), model);

2021161
tr.setFromY(650.0);

tr.setToY(0.0);

tr.setFromX(0.0);

tr.setToX(0.0);

tr.play();

scene1.setFill(Color.WHITE);

scene1.setCamera(camera);

stage.setTitle("JavaFX Graficos 3D");

stage.setScene(scene1);

stage.show();

private void loadScene3D2(Stage stage2) throws IOException {

AmbientLight light2 = new AmbientLight();

Node model1 = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model1.setScaleX(700.0);

model1.setScaleY(700.0);

model1.setScaleZ(700.0);

Node model2 = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model2.setScaleX(00.0);

model2.setScaleY(00.0);

model2.setScaleZ(00.0);

2021161
Node model3 = Importer3D.load(getClass().getResource("obj-
model/HomcenterTexto.obj").toExternalForm());

model3.setScaleX(130.0);

model3.setScaleY(130.0);

model3.setScaleZ(130.0);

Group root2 = new Group(model1, model2, model3, light2);

Scene scene2 = new Scene(root2, 1280, 650, true, SceneAntialiasing.BALANCED);

PerspectiveCamera camera2 = new PerspectiveCamera();

camera2.setTranslateX(scene2.getWidth() / -2.0);

camera2.setTranslateY(scene2.getHeight() / -2.0);

RotateTransition rt = new RotateTransition(Duration.seconds(10), model1);

rt.setCycleCount(Animation.INDEFINITE);

rt.setFromAngle(0);

rt.setToAngle(360);

rt.setAxis(new Point3D(0, 1, 0));

rt.play();

RotateTransition rta = new RotateTransition(Duration.seconds(10), model2);

rta.setCycleCount(Animation.INDEFINITE);

rta.setFromAngle(0);

rta.setToAngle(360);

rta.setAxis(new Point3D(0, 1, 0));

rta.play();

2021161
TranslateTransition tr = new TranslateTransition(Duration.seconds(5), model1);

tr.setFromY(-650.0);

tr.setToY(-250.0);

tr.setFromX(-1280.0);

tr.setToX(-550.0);

tr.play();

TranslateTransition tra = new TranslateTransition(Duration.seconds(5), model2);

tra.setFromY(650.0);

tra.setToY(0.0);

tra.setFromX(1280.0);

tra.setToX(300.0);

tra.play();

TranslateTransition tran = new TranslateTransition(Duration.seconds(5), model3);

tran.setFromY(650.0);

tran.setToY(0.0);

tran.setFromX(-1280.0);

tran.setToX(-300.0);

tran.play();

ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(1));

scaleTransition.setFromX(100.0);

scaleTransition.setToX(150.0);

scaleTransition.setFromY(100.0);

scaleTransition.setToY(150.0);

// Let the animation run forever

scaleTransition.setCycleCount(2);

2021161
// Reverse direction on alternating cycles

scaleTransition.setAutoReverse(true);

SequentialTransition Transition = new SequentialTransition();

Transition.getChildren().addAll(scaleTransition);

Transition.setNode(model2);

Transition.setCycleCount(PathTransition.INDEFINITE);

Transition.play();

scene2.setFill(Color.WHITE);

scene2.setCamera(camera2);

stage2.setTitle("JavaFX Graficos 3D");

stage2.setScene(scene2);

stage2.show();

private void loadScene3D3(Stage stage3) throws IOException {

AmbientLight light2 = new AmbientLight();

Node model1 = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model1.setScaleX(700.0);

model1.setScaleY(700.0);

model1.setScaleZ(700.0);

Node model2 = Importer3D.load(getClass().getResource("obj-


model/PC1.obj").toExternalForm());

model2.setScaleX(10.0);

2021161
model2.setScaleY(10.0);

model2.setScaleZ(10.0);

Node model3 = Importer3D.load(getClass().getResource("obj-


model/PCtexto1.obj").toExternalForm());

model3.setScaleX(100.0);

model3.setScaleY(100.0);

model3.setScaleZ(100.0);

Group root2 = new Group(model1, model2, model3, light2);

Scene scene2 = new Scene(root2, 1280, 650, true, SceneAntialiasing.BALANCED);

PerspectiveCamera camera2 = new PerspectiveCamera();

camera2.setTranslateX(scene2.getWidth() / -2.0);

camera2.setTranslateY(scene2.getHeight() / -2.0);

RotateTransition rt = new RotateTransition(Duration.seconds(10), model1);

rt.setCycleCount(Animation.INDEFINITE);

rt.setFromAngle(0);

rt.setToAngle(360);

rt.setAxis(new Point3D(0, 1, 0));

rt.play();

RotateTransition rta = new RotateTransition(Duration.seconds(10), model2);

rta.setCycleCount(Animation.INDEFINITE);

rta.setFromAngle(0);

rta.setToAngle(360);

rta.setAxis(new Point3D(1, 1, 1));

2021161
rta.play();

TranslateTransition tr = new TranslateTransition(Duration.seconds(5), model1);

tr.setFromY(-650.0);

tr.setToY(-250.0);

tr.setFromX(-1280.0);

tr.setToX(-550.0);

tr.play();

TranslateTransition tra = new TranslateTransition(Duration.seconds(5), model2);

tra.setFromY(-650.0);

tra.setToY(0.0);

tra.setFromX(300.0);

tra.setToX(300.0);

tra.play();

TranslateTransition tran = new TranslateTransition(Duration.seconds(5), model3);

tran.setFromY(0.0);

tran.setToY(0.0);

tran.setFromX(-1280.0);

tran.setToX(-300.0);

tran.play();

scene2.setFill(Color.WHITE);

scene2.setCamera(camera2);

stage3.setTitle("JavaFX Graficos 3D");

stage3.setScene(scene2);

stage3.show();

2021161
}

private void loadScene3D4(Stage stage4) throws IOException {

AmbientLight light2 = new AmbientLight();

Node model1 = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model1.setScaleX(700.0);

model1.setScaleY(700.0);

model1.setScaleZ(700.0);

Node model3 = Importer3D.load(getClass().getResource("obj-


model/PortatilTexto1.obj").toExternalForm());

model3.setScaleX(100.0);

model3.setScaleY(100.0);

model3.setScaleZ(100.0);

Node model4 = Importer3D.load(getClass().getResource("obj-


model/Portatil1.obj").toExternalForm());

model4.setScaleX(02.0);

model4.setScaleY(02.0);

model4.setScaleZ(02.0);

Group root2 = new Group(model1, model3, model4, light2);

Scene scene2 = new Scene(root2, 1280, 650, true, SceneAntialiasing.BALANCED);

PerspectiveCamera camera2 = new PerspectiveCamera();

camera2.setTranslateX(scene2.getWidth() / -2.0);

2021161
camera2.setTranslateY(scene2.getHeight() / -2.0);

RotateTransition rt = new RotateTransition(Duration.seconds(10), model1);

rt.setCycleCount(Animation.INDEFINITE);

rt.setFromAngle(0);

rt.setToAngle(360);

rt.setAxis(new Point3D(0, 1, 0));

rt.play();

RotateTransition rta = new RotateTransition(Duration.seconds(10) );

rta.setCycleCount(Animation.INDEFINITE);

rta.setFromAngle(0);

rta.setToAngle(360);

rta.setAxis(new Point3D(0, 1, 0));

rta.play();

TranslateTransition tr = new TranslateTransition(Duration.seconds(5), model1);

tr.setFromY(-650.0);

tr.setToY(-250.0);

tr.setFromX(-1280.0);

tr.setToX(-550.0);

tr.play();

TranslateTransition tra = new TranslateTransition(Duration.seconds(5) );

tra.setFromY(-650.0);

tra.setToY(0.0);

tra.setFromX(300.0);

tra.setToX(300.0);

2021161
tra.play();

TranslateTransition tran = new TranslateTransition(Duration.seconds(5), model3);

tran.setFromY(0.0);

tran.setToY(0.0);

tran.setFromX(-1280.0);

tran.setToX(-300.0);

tran.play();

TranslateTransition trans = new TranslateTransition(Duration.seconds(5), model4);

trans.setFromY(-650.0);

trans.setToY(200.0);

trans.setFromX(300.0);

trans.setToX(300.0);

trans.play();

scene2.setFill(Color.WHITE);

scene2.setCamera(camera2);

stage4.setTitle("JavaFX Graficos 3D");

stage4.setScene(scene2);

stage4.show();

private void loadScene3D5(Stage stage5) throws IOException {

AmbientLight light1 = new AmbientLight();

Node model1 = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model1.setScaleX(700.0);

2021161
model1.setScaleY(700.0);

model1.setScaleZ(700.0);

Node model2 = Importer3D.load(getClass().getResource("obj-


model/Escritorio1.obj").toExternalForm());

model2.setScaleX(01.0);

model2.setScaleY(01.0);

model2.setScaleZ(01.0);

Node model3 = Importer3D.load(getClass().getResource("obj-


model/EscritorioTexto1.obj").toExternalForm());

model3.setScaleX(100.0);

model3.setScaleY(100.0);

model3.setScaleZ(100.0);

Group root2 = new Group(model1, model2, model3, light1);

Scene scene2 = new Scene(root2, 1280, 650, true, SceneAntialiasing.BALANCED);

PerspectiveCamera camera2 = new PerspectiveCamera();

camera2.setTranslateX(scene2.getWidth() / -2.0);

camera2.setTranslateY(scene2.getHeight() / -2.0);

RotateTransition rt = new RotateTransition(Duration.seconds(10), model1);

rt.setCycleCount(Animation.INDEFINITE);

rt.setFromAngle(0);

rt.setToAngle(360);

rt.setAxis(new Point3D(0, 1, 0));

rt.play();

2021161
RotateTransition rta = new RotateTransition(Duration.seconds(10), model2);

rta.setCycleCount(Animation.INDEFINITE);

rta.setFromAngle(0);

rta.setToAngle(360);

rta.setAxis(new Point3D(0, 1, 0));

rta.play();

TranslateTransition tr = new TranslateTransition(Duration.seconds(5), model1);

tr.setFromY(-650.0);

tr.setToY(-250.0);

tr.setFromX(-1280.0);

tr.setToX(-550.0);

tr.play();

TranslateTransition tra = new TranslateTransition(Duration.seconds(5), model2);

tra.setFromY(-650.0);

tra.setToY(0.0);

tra.setFromX(300.0);

tra.setToX(300.0);

tra.play();

TranslateTransition tran = new TranslateTransition(Duration.seconds(5), model3);

tran.setFromY(0.0);

tran.setToY(0.0);

tran.setFromX(-1280.0);

tran.setToX(-300.0);

tran.play();

2021161
scene2.setFill(Color.WHITE);

scene2.setCamera(camera2);

stage5.setTitle("JavaFX Graficos 3D");

stage5.setScene(scene2);

stage5.show();

private void loadScene3D6(Stage stage6) throws IOException {

AmbientLight light1 = new AmbientLight();

Node model1 = Importer3D.load(getClass().getResource("obj-


model/Logo.obj").toExternalForm());

model1.setScaleX(700.0);

model1.setScaleY(700.0);

model1.setScaleZ(700.0);

Node model2 = Importer3D.load(getClass().getResource("obj-


model/Cama1.obj").toExternalForm());

model2.setScaleX(01.0);

model2.setScaleY(01.0);

model2.setScaleZ(01.0);

Node model3 = Importer3D.load(getClass().getResource("obj-


model/CamaTexto1.obj").toExternalForm());

model3.setScaleX(100.0);

model3.setScaleY(100.0);

model3.setScaleZ(100.0);

Group root2 = new Group(model1, model2, model3, light1);

2021161
Scene scene2 = new Scene(root2, 1280, 650, true, SceneAntialiasing.BALANCED);

PerspectiveCamera camera2 = new PerspectiveCamera();

camera2.setTranslateX(scene2.getWidth() / -2.0);

camera2.setTranslateY(scene2.getHeight() / -2.0);

RotateTransition rt = new RotateTransition(Duration.seconds(10), model1);

rt.setCycleCount(Animation.INDEFINITE);

rt.setFromAngle(0);

rt.setToAngle(360);

rt.setAxis(new Point3D(0, 1, 0));

rt.play();

RotateTransition rta = new RotateTransition(Duration.seconds(10), model2);

rta.setCycleCount(Animation.INDEFINITE);

rta.setFromAngle(0);

rta.setToAngle(-360);

rta.setAxis(new Point3D(0, 1, 0));

rta.play();

TranslateTransition tr = new TranslateTransition(Duration.seconds(5), model1);

tr.setFromY(-650.0);

tr.setToY(-250.0);

tr.setFromX(-1280.0);

tr.setToX(-550.0);

tr.play();

2021161
TranslateTransition tra = new TranslateTransition(Duration.seconds(5), model2);

tra.setFromY(-650.0);

tra.setToY(0.0);

tra.setFromX(300.0);

tra.setToX(300.0);

tra.play();

TranslateTransition tran = new TranslateTransition(Duration.seconds(5), model3);

tran.setFromY(0.0);

tran.setToY(0.0);

tran.setFromX(-1280.0);

tran.setToX(-300.0);

tran.play();

scene2.setFill(Color.WHITE);

scene2.setCamera(camera2);

stage6.setTitle("JavaFX Graficos 3D");

stage6.setScene(scene2);

stage6.show();

public static void main(String[] args) {

launch(args);

2021161
3. Hacer entrega de la carpeta con el proyecto desarrollado en JAVA.

Programa:
https://drive.google.com/file/d/1aVQg0iRSII1T2qpVAYID_UquFRcS4MVP/vi
ew?usp=sharing

4. Hacer entrega del video explicando el código realizado y haciendo ejecución


del mismo. Comparte el enlace del video subido a YouTube.

Link Video: https://youtu.be/z_pgvwRPBps

2021161
BIBLIOGRAFIA

Bibliografía
Francisco Cortes, Sedrick, (2019), How to change scene based on time with Javafx, retrieved from:
https://bit.ly/2QcE5d7

based-on-time-in-javafx Jewelsea, (2014). How to import 3d models in javaFx, retrieved from:


https://bit.ly/3x0bR61

Blender, (2019), Blender 2.8 tutorial, retrieved from: https://bit.ly/3n0na9F

TutorialsPoint (2019), JavaFx Tutorial, retrieved from: https://bit.ly/3drrNX0

2021161

También podría gustarte