Question: How do I make this autobot the same as the image above in this code? import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene. * ; import

How do I make this autobot the same as the image above in this code?
import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene.*; import javafx.scene.image.Image; import static javafx.scene.input.KeyCode.DOWN; import static javafx.scene.input.KeyCode.LEFT; import static javafx.scene.input.KeyCode.RIGHT; import static javafx.scene.input.KeyCode.UP; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Box; import javafx.scene.shape.Cylinder; import javafx.stage.Stage; import javafx.scene.input.KeyEvent; import javafx.scene.input.ScrollEvent; import javafx.scene.transform.Rotate; public class Hello3D extends Application { private double mouseX, mouseY; private double angleX =0; private double angleY =0; @Override public void start(Stage primaryStage){// Create the soda can with texture PhongMaterial sodaMaterial = new PhongMaterial(); sodaMaterial.setDiffuseMap(new Image(getClass().getResourceAsStream("/img/cok1.png"))); Cylinder sodaCan = new Cylinder(15,70); // Adjust radius and height as needed sodaCan.setMaterial(sodaMaterial); sodaCan.setTranslateX(0); sodaCan.setTranslateY(35); // Position it above the floor // Create the floor with a texture PhongMaterial floorMaterial = new PhongMaterial(); floorMaterial.setDiffuseMap(new Image(getClass().getResourceAsStream("/img/bgg.png"))); Box floor = new Box(200,1,200); // Large, flat box to act as a floor floor.setMaterial(floorMaterial); floor.setTranslateY(70); // Position it below the can // Add lighting to the scene AmbientLight ambientLight = new AmbientLight(Color.WHITE); // Root node and scene setup Group root = new Group(); root.getChildren().addAll(sodaCan, floor, ambientLight); // Set up the camera Camera camera = new PerspectiveCamera(true); camera.setTranslateZ(-500); // Position camera camera.setNearClip(1); camera.setFarClip(1000); // Create the scene Scene scene = new Scene(root,800,600, true, SceneAntialiasing.BALANCED); scene.setFill(Color.WHITE); // Set background color scene.setCamera(camera); // Add controls for interactivity addArrowKeyControls(scene, camera); addScrollZoom(scene, camera); addMouseRotation(scene, root); // Set up stage primaryStage.setTitle("3D Texture Mapping Scene"); primaryStage.setScene(scene); primaryStage.show(); }// Method to add arrow key controls (move camera along x and y axes) private void addArrowKeyControls(Scene scene, Camera camera){ scene.setOnKeyPressed((KeyEvent event)->{ switch (event.getCode()){ case UP: // Move camera up camera.setTranslateY(camera.getTranslateY()-10); break; case DOWN: // Move camera down camera.setTranslateY(camera.getTranslateY()+10); break; case LEFT: // Move camera left camera.setTranslateX(camera.getTranslateX()-10); break; case RIGHT: // Move camera right camera.setTranslateX(camera.getTranslateX()+10); break; default: break; }}); }// Method to add scroll zoom control (move camera along z axis) private void addScrollZoom(Scene scene, Camera camera){// Add scroll event handler to the scene scene.setOnScroll((ScrollEvent event)->{// Get scroll amount (up or down) double delta = event.getDeltaY(); // Calculate a new Z-position (scale scroll by 0.3 for smoother zoom) double newZ = camera.getTranslateZ()+ delta *0.3; // Set cameras Z translation to newZ camera.setTranslateZ(newZ); }); }// Method to add mouse rotation controls (rotate scene along x and y axes) private void addMouseRotation(Scene scene, Node node){// Add Mouse event handlers to the scene scene.setOnMousePressed(event ->{// On mouse press, get mouse coordinates mouseX = event.getSceneX(); mouseY = event.getSceneY(); }); scene.setOnMouseDragged(event ->{// On mouse drag, update the rotation angles based on mouse movement angleX +=(event.getSceneY()- mouseY); // Rotate along X-axis (up/down movement) angleY +=(event.getSceneX()- mouseX); // Rotate along Y-axis (left/right movement)// Set/apply the rotation transforms node.getTransforms().setAll( new Rotate(angleX, Rotate.X_AXIS), new Rotate(an
 How do I make this autobot the same as the image

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!