83 *
84 * @see javafx.scene.AmbientLight
85 * @see javafx.scene.PerspectiveCamera
86 * @see javafx.scene.PointLight
87 * @see javafx.scene.SceneAntialiasing
88 * @see javafx.scene.paint.PhongMaterial
89 * @see javafx.scene.shape.Sphere
90 * @see javafx.scene.transform.Rotate
91 * @conditionalFeatures SCENE3D
92 *
93 * @related /Graphics 3d/Xylophone
94 * @related /Graphics 3d/3D Box
95 * @related /Graphics 3d/3D Cubes
96 * @related /Graphics 3d/3D Sphere System
97 */
98 public class Simple3DSphereApp extends Application {
99
100 private Sphere earth;
101 private PhongMaterial material;
102 private PointLight sun;
103 private final DoubleProperty sunDistance = new SimpleDoubleProperty(100);
104 private final BooleanProperty sunLight = new SimpleBooleanProperty(true);
105 private final BooleanProperty diffuseMap = new SimpleBooleanProperty(true);
106 private final BooleanProperty specularMap = new SimpleBooleanProperty(true);
107 private final BooleanProperty bumpMap = new SimpleBooleanProperty(true);
108 private final BooleanProperty selfIlluminationMap = new SimpleBooleanProperty(true);
109
110 public Parent createContent() throws Exception {
111
112 String base = "/ensemble/samples/graphics3d/sphere/earth-";
113 Image dImage = new Image(getClass().getResource(base + "d.jpg").toString());
114 Image nImage = new Image(getClass().getResource(base + "n.jpg").toString());
115 Image sImage = new Image(getClass().getResource(base + "s.jpg").toString());
116 Image siImage = new Image(getClass().getResource(base + "l.jpg").toString());
117
118 material = new PhongMaterial();
119 material.setDiffuseColor(Color.WHITE);
120 material.diffuseMapProperty().bind(
121 Bindings.when(diffuseMap).then(dImage).otherwise((Image) null));
122 material.setSpecularColor(Color.TRANSPARENT);
123 material.specularMapProperty().bind(
124 Bindings.when(specularMap).then(sImage).otherwise((Image) null));
125 material.bumpMapProperty().bind(
126 Bindings.when(bumpMap).then(nImage).otherwise((Image) null));
127 material.selfIlluminationMapProperty().bind(
128 Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null));
|
83 *
84 * @see javafx.scene.AmbientLight
85 * @see javafx.scene.PerspectiveCamera
86 * @see javafx.scene.PointLight
87 * @see javafx.scene.SceneAntialiasing
88 * @see javafx.scene.paint.PhongMaterial
89 * @see javafx.scene.shape.Sphere
90 * @see javafx.scene.transform.Rotate
91 * @conditionalFeatures SCENE3D
92 *
93 * @related /Graphics 3d/Xylophone
94 * @related /Graphics 3d/3D Box
95 * @related /Graphics 3d/3D Cubes
96 * @related /Graphics 3d/3D Sphere System
97 */
98 public class Simple3DSphereApp extends Application {
99
100 private Sphere earth;
101 private PhongMaterial material;
102 private PointLight sun;
103
104 private final DoubleProperty sunDistance = new SimpleDoubleProperty(100);
105 public final DoubleProperty sunDistanceProperty() {
106 return sunDistance;
107 }
108
109 private final BooleanProperty sunLight = new SimpleBooleanProperty(true);
110 public final BooleanProperty sunLightProperty() {
111 return sunLight;
112 }
113
114 private final BooleanProperty diffuseMap = new SimpleBooleanProperty(true);
115 public final BooleanProperty diffuseMapProperty() {
116 return diffuseMap;
117 }
118
119 private final BooleanProperty specularMap = new SimpleBooleanProperty(true);
120 public final BooleanProperty specularMapProperty() {
121 return specularMap;
122 }
123
124 private final BooleanProperty bumpMap = new SimpleBooleanProperty(true);
125 public final BooleanProperty bumpMapProperty() {
126 return bumpMap;
127 }
128
129 private final BooleanProperty selfIlluminationMap = new SimpleBooleanProperty(true);
130 public final BooleanProperty selfIlluminationMapProperty() {
131 return selfIlluminationMap;
132 }
133
134 public Parent createContent() throws Exception {
135
136 String base = "/ensemble/samples/graphics3d/sphere/earth-";
137 Image dImage = new Image(getClass().getResource(base + "d.jpg").toString());
138 Image nImage = new Image(getClass().getResource(base + "n.jpg").toString());
139 Image sImage = new Image(getClass().getResource(base + "s.jpg").toString());
140 Image siImage = new Image(getClass().getResource(base + "l.jpg").toString());
141
142 material = new PhongMaterial();
143 material.setDiffuseColor(Color.WHITE);
144 material.diffuseMapProperty().bind(
145 Bindings.when(diffuseMap).then(dImage).otherwise((Image) null));
146 material.setSpecularColor(Color.TRANSPARENT);
147 material.specularMapProperty().bind(
148 Bindings.when(specularMap).then(sImage).otherwise((Image) null));
149 material.bumpMapProperty().bind(
150 Bindings.when(bumpMap).then(nImage).otherwise((Image) null));
151 material.selfIlluminationMapProperty().bind(
152 Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null));
|