Skip to main content

Raster Bugged by TexCoordGeneration

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2012-04-08

Hello :)

I have a problem and I think it is a bug as one setting on one node affects another completely unrelated node. I will explain what happens, include code which shows it happening and a possible very long winded work-around.

The code creates the minimum requirements for java3d.
loads an image.
creates imageComponent2D,raster,platformGeometry
attaches the raster to the platformgeometry and renders image as expected.

when the user presses space a sphere with white direction light is added.

the spheres appearance has
black and white material
an array of 1 TextureUnitState
of which holds a texture,
textureAttributes that modulate the objects colour and the texture
and a default TexCoordGeneration

once the sphere is successfully grafted onto the scene for some reason the raster scales its image to match the canvas size and only displays the portion visible within the rasters area. how frustrating!!!! in my mind the raster should not have been affected at all.

i havent been able to test this on any other machine but my whole purpose for pursuing this development choice is for maximum compatibility so i would hopefully think this bug effect will occur on any machine.

the work-around which has come to mind is to perform calculation everytime the canvas or raster is resized. that is to take the canvas size and raster image size properties and calculate scaling factors which can be added to the texcoordgeneration planeS and planeT which i have had some success at altering the images scale but havent fully tested the idea. seems a little long winded to get the result i had before using TextureUnitStates of which my machine supports 4.

There maybe something really obvious I am missing and hence why this post. im hoping for something really simple to solve it :) I would really appreciate you insight, thanks.

raster_bug.jar8.76 KB

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-04-08

I have found a feasible solution.

Whether it is a hack to correct a bug or its the "correct" way, im not sure, seems a bit strange that one has to include the following code.

anyway, to ensure the raster displays its image at screen scale I created a buffered image the same size as the canvas, created ImageComponent2D and Textrue2D and added it to the appearance of the raster. This seems to ensure the raster scale remains at the same original screen scale.

add the following lines to the raster bug program and the problem no longer occurs.

BufferedImage bi1=new BufferedImage(500,400,BufferedImage.TYPE_INT_ARGB);
Texture2D t1=new Texture2D(Texture.BASE_LEVEL,Texture.RGBA,500,400);
t1.setImage(0,new ImageComponent2D(ImageComponent2D.FORMAT_RGBA,bi1));

I hope this post helps someone. took me 3 days to get to the bottom of this one!