Question: in this code why the figures don't show on the screen just the gray screen show ( import javafx.application.Application; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene;
in this code why the figures don't show on the screen just the gray screen show import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.AmbientLight;
import javafx.scene.shape.Cylinder;
import javafx.scene.shape.Sphere;
import javafx.stage.Stage;
import javafx.scene.transform.Rotate;
public class ThreeDSceneExample extends Application
@Override
public void startStage stage
Root group for all D shapes
Group root new Group;
Create the main central sphere
Sphere centralSphere new Sphere;
PhongMaterial redMaterial new PhongMaterialColorRED;
centralSphere.setMaterialredMaterial;
Create smaller spheres and cylinders for connections
createAndAddConnectionroot centralSphere, Color.BLUE; right
createAndAddConnectionroot centralSphere, Color.GREEN; left
createAndAddConnectionroot centralSphere, Color.BLUE; top
createAndAddConnectionroot centralSphere, Color.GREEN; bottom
createAndAddConnectionroot centralSphere, Color.BLUE; front
createAndAddConnectionroot centralSphere, Color.GREEN; back
Add ambient light
AmbientLight light new AmbientLightColorWHITE;
root.getChildrenaddlight;
Set up the camera
PerspectiveCamera camera new PerspectiveCameratrue;
camera.setTranslateZ;
Scene scene new Sceneroot true;
scene.setFillColorLIGHTGRAY;
scene.setCameracamera;
Adding rotation transformation
root.getTransformsaddAll
new Rotate Rotate.XAXIS
new Rotate Rotate.YAXIS
;
Set up the stage
stage.setTitleD Scene Example";
stage.setScenescene;
stage.show;
private void createAndAddConnectionGroup root, Sphere centralSphere, double x double y double z Color color
Create a small sphere at the end of each arm
Sphere sphere new Sphere;
PhongMaterial material new PhongMaterialcolor;
sphere.setMaterialmaterial;
sphere.setTranslateXx;
sphere.setTranslateYy;
sphere.setTranslateZz;
Create a cylinder to connect the central sphere to the outer sphere
Cylinder connection new Cylinder;
connection.setMaterialnew PhongMaterialColorDARKGRAY;
connection.setTranslateXx centralSphere.getTranslateX;
connection.setTranslateYy centralSphere.getTranslateY;
connection.setTranslateZz centralSphere.getTranslateZ;
if x
connection.setRotationAxisRotateYAXIS;
connection.setRotate;
else if y
connection.setRotationAxisRotateXAXIS;
connection.setRotate;
root.getChildrenaddAllsphere connection;
public static void mainString args
launchargs;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
