I am trying to learn how to use textures.
I added the following code to my appearance:
TextureLoader loader = new TextureLoader("tex01.jpg", this);
ImageComponent2D image = loader.getImage();
Texture2D tex = new Texture2D();
tex.setImage(0, image);
tex.setEnable(true);
tex.setBoundaryModeS(Texture.WRAP);
tex.setBoundaryModeT(Texture.WRAP);
A.setTexture(tex);
----------------------
When I try to run my applet with appletviewer, I get the error:
appletviewer pattern.html
java.lang.IllegalArgumentException: cannot set image in default texture
at javax.media.j3d.TextureRetained.setImage(TextureRetained.java:210)
at javax.media.j3d.Texture.setImage(Texture.java:362)
at Pattern.createAppearanceKnot(Pattern.java:1753)
at Pattern.createSceneGraph(Pattern.java, Compiled Code)
at Pattern.init(Pattern.java:452)
at sun.applet.AppletPanel.run(AppletPanel.java:333)
at java.lang.Thread.run(Thread.java:479)
--------------------------
When I try to run it by just clicking on the html file, I get the error:
JAR cache enabled.
Error: in loading image
java.lang.NullPointerException
at javax.media.j3d.ImageComponent2D.<init>(ImageComponent2D.java:59)
at com.sun.j3d.utils.image.TextureLoader.getImage(TextureLoader.java:294)
at Pattern.createAppearanceKnot(Pattern.java:1750)
at Pattern.createSceneGraph(Pattern.java, Compiled Code)
at Pattern.init(Pattern.java:452)
at sun.applet.AppletPanel.run(AppletPanel.java:333)
at java.lang.Thread.run(Thread.java:479)
-----------------------
The "tex01.jpg" file is in the same directory as all the class files and the html file.
Anyone know what's wrong?
Bob Gray