Skip to main content

a question about Render class

1 reply [Last post]
chowchow616
Offline
Joined: 2007-01-09

Hello everybody. I want to use Render class. But I don'k know how to use it. I write a test program which is imitated to ReadRaster in j3d example. But the result is not correct.

The code is this:
private void genImage(){
gc=canvas.getGraphicsContext3D();
bImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB);
imageComponent = new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage, true, true);
raster=new Raster(new Point3f(0.0f,0.0f,0.0f),Raster.RASTER_COLOR,0,0,256,256,imageComponent,null);
gc.readRaster(raster);
bImage = raster.getImage().getImage();
}
public void init(){
Container cp=getContentPane();
cp.setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
canvas=new Canvas3D(config);
cp.add("Center",canvas);
BranchGroup scene=createSceneGraph();
SimpleUniverse simpleU=new SimpleUniverse(canvas);
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
genImage();
JFrame depthImageFrame=new JFrame("Render Image");
JLabel label=new JLabel();
label.setIcon(new ImageIcon(bImage));
depthImageFrame.add(label);
depthImageFrame.setVisible(true);
depthImageFrame.setSize(256,256);
}

And the createSceneGraph() method in this code is to create only a simple color cube. If the result was right, it should show an image of color cube in sub-frame, which is just the same as which is shown in main-frame. But sub-frame shows nothing in my result.

This problem has bothered me for two days. Could someone help me? Thanks.

Message was edited by: chowchow616

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chowchow616
Offline
Joined: 2007-01-09

Could somebody help me? Thanks :)