Java Reference
In-Depth Information
Figure 10-11.
The EarthBox program
If you pay attention to Figure
10-11
, you will notice that all six sides of the box are mapped to the same image.
This is a consequence of how the predefined
Box
class implements its
TriangleMesh
. We can easily create a
user-defined
MeshCube
with sides that are mapped to different parts of the
diffuseMap
image file.
In Listing 10-9, we create a
MeshCube
and then texturize it with an earth-in-a-box image file with an image that
looks like an actual spread-out box, resulting in a world map on a cube.
Listing 10-9.
MeshCube.java
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.PointLight;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.MeshView;
import javafx.scene.shape.TriangleMesh;
Search WWH ::
Custom Search