Well although this is probably a silly question that I should have been able to find the answers to, I’ve spent enough time searching that I think I’m ready to call out for help. I’m using a Raster in my scene:
image = ImageIO.read(getURL());
ImageComponent2D image2D = new ImageComponent2D(ImageComponent2D.FORMAT_RGBA, image);
Raster raster = new Raster();
raster.setType(Raster.RASTER_COLOR);
raster.setImage(image2D);
raster.setSize(image.getWidth(), image.getHeight());
then I create a new Shape3D(raster) and use it in my scene.
I’m having two problems with this. My first problem is that the position of the Raster is at the top left of the image. I want it to be at the center. In Java2D I would just translate by (-image.getWidth()/2, -image.getHeight()/2) but I’ve found no such equivalent here. I tried setting the Raster position to that and it flies off the screen, obviously using a different scale. Then I tried (-.5, -.5) which was closer but that moved it too far. I read that it uses “object coordinates” so I assume that it’s referring to the scale of my scene as thats what it appears to be doing. But why in the world would it have its own personal embedded method to do that when I can just attach the Shape3D to a TransformGroup and move it in my scene like every other Geometry object?
My second problem is with the alpha. I tried loading in a .gif with single color transparency and a .png with an alpha channel. I made sure that in Java2D they are loaded in properly with the alpha working. I put them in my code here in Java3D and I just get the white background to the image. I tried mucking with the Appearance stuff but I can’t find the answer there either. I assume if the answer is anywhere that’s where it is. Could someone help me with that also?