Skip to main content

A rendering error

6 replies [Last post]
dams
Offline
Joined: 2006-05-05

Hi all,
I've an error while updating a texture with j3d 1.4.0-beta1 & j3d1.3.2
and my application is freezing:

Hit uncaught exception java.lang.ArrayIndexOutOfBoundsException
Exception in thread "J3D-RenderStructureUpdateThread-1" java.lang.ArrayIndexOutOfBoundsException: 1
at javax.media.j3d.RenderBin.processTextureChanged(Unknown Source)
at javax.media.j3d.RenderBin.processMessages(Unknown Source)
at javax.media.j3d.StructureUpdateThread.doWork(Unknown Source)
at javax.media.j3d.J3dThread.run(Unknown Source)

It's difficult for me to reproduce this bug because I'm working on an API based on j3d.

Dams

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dams
Offline
Joined: 2006-05-05

Ok, I found the reason why...
Here this is the code that crashes:

ImageComponent2D i2d[] = {
(ImageComponent2D)getTexture().getImage(0)
};
AffineTransform at = AffineTransform.getScaleInstance((float)i2d[0].getWidth() / (float)getWidth(), (float)i2d[0].getHeight() / (float)getHeight());
AffineTransformOp atop = new AffineTransformOp(at, 2);
BufferedImage _image = atop.filter(getBufferedImage(), null);
i2d[0].set(_image);
getTexture().setImages(i2d);

and to fix the problem, I changed the last line by:

getTexture().setImage(0, i2d[0]);

So, you see the problem?!?

Dams

kcr
Offline
Joined: 2004-03-17

You need to pass an array of images for all mipmap levels to Texture.setImages(ImageComponent[]) method. If you only want to pass a single image, use Texture.setImage(0, ImageComponent) instead.

Btw, I think there still may be a Java 3D bug here, in that setImages checks the size of the array before passing it to the Rendering Structure, so the exception shouldn't be happening in the RenderStructureUpdateThread. Instead, an IllegalArgumentException or NPE should be thrown in the calling thread by setImages.

-- Kevin

dams
Offline
Joined: 2006-05-05

Yes, Kevin, I think that there is a bug or just a missing throws Exception when passing ImageComponent: Rendering Exception and j3d freezing are not normal comportements...
Maybe an issue can be filed for that? And maybe this can be documented for the methods?
For me, the problem has been resolved by the fix setImage(0, ImageComponent), but my question is for all other mipmap levels, what was done by only setting the first ImageComponent???

Thank you

dams

kcr
Offline
Joined: 2004-03-17

> Maybe an issue can be filed for that?

If you have a test program, please feel free to file an issue.

> And maybe this can be documented for the methods?

It's alreay documented that an IllegalArgumentException will be thrown if the length of the array is not equal to the total number of mipmap levels.

> For me, the problem has been resolved by the fix setImage(0, ImageComponent), but my question is for
> all other mipmap levels, what was done by only setting the first ImageComponent???

They are left unchanged.

dams
Offline
Joined: 2006-05-05

Hi Chien,
thank you for your answer first,
and how can I make a "trace from a debug build"?
It means that I need a special build to log j3d trace?
I'm trying to make a test case, but it seems difficult without API source...

dams

jada
Offline
Joined: 2004-03-17

Without a test program or a trace from a debug build, we can't really help.

- Chien.