We have been having problems with obtaining BufferedImages from a
DisplayImplJ3D. Namely if there are any components, dialogs, terminals, etc,
over the VisAD display these are captured in the image.
After reading through some source code and api's (for both VisAD and Java3D)
it has become apparent that I should be able to do something along the lines
of offscreen rendering. I have had a look through the main() in
VisADCanvasJ3D and it does its offscreen rendering by creating a new display
and adding some data references to it, this is possible but not ideal as our
memory usage is already really high.
So after snooping around in the java3d examples I came across an example for
offscreen rendering and adapted it for VisAD.
So my question is this. Is there any way to create a DisplayImplJ3D that
contains the same view as an existing display but uses a different api
I thought the code might look something like...
DisplayImplJ3D offscreen = new DisplayImplJ3D("offscreen", renderer, 640,
BufferedImage image = offscreen.getImage(true);
where "display" is the display added to our jFrame.
but I get a "visad.DisplayException: DisplayRenderer.setDisplay: display
already set" which is fair enough after looking at the source.
Other options I have looked at are creating a RemoteSlaveDisplay, or copying
the java3d offscreen rendering demo (outlined below...)?
Another issue found was that when running the main() of VisADCanvasJ3D under
linux we have only had the box and never got a field displayed. Whereas this
has worked on windows. We get the same results for all linux and all windows
This is a nice juicy problem, which will hopefully get you all excited,
either that, or it is nice and simple and I can go off back into the woods
and hack code. I am keen to do some work on getting this to work nicely.
Cheers in advance,
BTW: I hacked together some code adapted from the java3d offscreen rendering
example, which also didn't work but was interesting all the same. Not only
does this code not work, (null pointer from c.renderOffscreenBuffer()) it is
really ugly, as I was hoping not to have to call any java3d methods
Canvas3D d = renderer.getCanvas();
Canvas3D c = new VisADCanvasJ3D(renderer, 640, 480);
Screen3D sOn = d.getScreen3D();
Screen3D sOff = c.getScreen3D();
//attach the same view to the offscreen canvas
View v = renderer.getView();
((VisADCanvasJ3D)c).captureFlag = true;
BufferedImage image = ((VisADCanvasJ3D)c).captureImage;