Java Reference
In-Depth Information
The code that maps the image of the world map onto the sphere is pretty straightforward:
Image diffuseMap = new Image(EarthSphere.class
.getResource("earth-mercator.jpg")
.toExternalForm());
PhongMaterial earthMaterial = new PhongMaterial();
earthMaterial.setDiffuseMap(diffuseMap);
final Sphere earth = new Sphere(400);
earth.setMaterial(earthMaterial);
Note that the image is a world map in Mercator projection, which is required by the internal TriangleMesh of
Sphere . When the program in Listing 10-8 is run, the EarthSphere window in Figure 10-9 is displayed.
Figure 10-9. The EarthSphere program
Search WWH ::




Custom Search