Java Reference
In-Depth Information
Figure 9. Code segment and result for TexCoordGenApp.java
1.
Appearance createAppearance(){
2.
3.
Appearance Appear = new Appearance();
4.
5.
PolygonAttributes polyAttrib = new PolygonAttributes();
6.
polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
7.
Appear.setPolygonAttributes(polyAttrib);
8.
9.
TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,
10.
TexCoordGeneration.TEXTURE_COORDINATE_2);
11.
Appear.setTexCoordGeneration(tcg);
12.
13.
String filename = "deck3.jpg";
14.
System.out.println("attempt to load texture from file: "+filename);
15.
TextureLoader loader = new TextureLoader(filename, this);
16.
ImageComponent2D image = loader.getImage();
17.
if(image == null) System.out.println("load failed for texture: "+filename);
18.
19.
Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
20.
image.getWidth(), image.getHeight());
21.
texture.setImage(0, image);
22.
texture.setEnable(true);
23.
24.
Appear.setTexture(texture);
25.
26.
return Appear; }
OBJECT_LINEAR
EYE_LINEAR
Figure 10. Code segment and result for SphereMap.java
1.
Appearance createAppearance()
2.
{
3.
TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP,
4.
TexCoordGeneration.TEXTURE_COORDINATE_3);
5.
Appear.setTexCoordGeneration(tcg);
6.
7.
String filename = "fisheye.jpg";
8.
System.out.println("attempt to load texture from file: "+filename);
9.
TextureLoader loader = new TextureLoader(filename, this);
10. }
Search WWH ::




Custom Search