Hi all,
I want to make a very simple box with a texture on it.
I read in the book Ready-to-run Java 3D how to do it but I still get the
error message:
Error: in loading image
Error: in loading image
java.lang.NullPointerException
at
com.sun.j3d.utils.image.TextureLoader.getTexture(TextureLoader.java:342)
at BoundingBox.createAppearances(BoundingBox.java:246)
at BoundingBox.createSceneGraph(BoundingBox.java:78)
at BoundingBox.init(BoundingBox.java:288)
at sun.applet.AppletPanel.run(AppletPanel.java:357)
at java.lang.Thread.run(Thread.java:479)
My code to create the appearance for the box looks like this:
public void createAppearances()
{
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
Color3f deepRed = new Color3f(0.9f, 0.2f, 0.1f);
Color3f royalBlue = new Color3f(0.1f, 0.3f, 0.9f);
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
mat = new Material[2];
app = new Appearance[2];
ta = new TextureAttributes[2];
mat[0] = new Material(royalBlue,royalBlue,royalBlue,white,
1.0f);
mat[1] = new Material(deepRed,deepRed,deepRed,white, 1.0f);
for (int i = 0; i < 2; i++) {
app[i] = new Appearance();
ta[i] = new TextureAttributes();
}
app[0].setMaterial(mat[0]);
app[1].setMaterial(mat[1]);
app[0].setTextureAttributes(ta[0]);
app[1].setTextureAttributes(ta[1]);
TextureLoader texLod0 = new TextureLoader(new
String("sign1.gif"), new String("RGB"), this);
TextureLoader texLod1 = new TextureLoader(new
String("sign1.gif"), new String("RGB"), this);
--> error on getTexture! Texture tex0 = texLod0.getTexture();
System.err.println("tex0= "+tex0);
Texture tex1 = texLod1.getTexture();
System.err.println("tex1= "+tex1);
if (tex0!=null) app[0].setTexture(tex0);
if (tex1!=null) app[1].setTexture(tex1);
}
What can cause the problem that the image can't be loaded? The image is
placed in the same dir as the applet.
Kevin Rushforth from the Java 3D Team of Sun Microsystems wrote to this
mailing list on 20-01-99 :
"Currently, Java 3D only takes advantage of 3D texture mapping on
Solaris systems. On win32, the OpenGL version of the Java 3D dll is
compiled with the Microsoft OpenGL header files, which do not define
the 3D texture mapping extension. "
My question is, does it still only works on solaris or is there allready
a way to get it worked on a Win NT machine with Open GL?
----------------------------------------------------
ing. Patrick Janssen
[EMAIL PROTECTED]
3i communication
intelligent interactive internet communication
http://www.3icommunication.com/
tel: 040-2960040, fax: 040-2960041
----------------------------------------------------
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".