Hello Java3d Fans,
I am a Java3d beginner and want to programm an servlet, which
create an JPEG of a JAVA3d-Scene.
I wrote a test class using Canvas 3d in offscreen mode, but all I get
is an empty Image. What did I wrong? I hope you can help me to fix
this ...
Thank you
Here is the program:
[...]
public class Test {
private SimpleUniverse u;
public Test(){}
public BranchGroup createSceneGraph(){
[...]
return objRoot;
}
public static void main(String[] args) {
Test test = new Test();
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config,true);
Screen3D sOff = c.getScreen3D();
c.getScreen3D().setSize(100,100);
c.getScreen3D().setPhysicalScreenWidth( (0.0254/90.0)* 100);
c.getScreen3D().setPhysicalScreenHeight((0.0254/90.0)* 100);
BranchGroup scene = test.createSceneGraph();
test.u = new SimpleUniverse();
test.u.getViewingPlatform().setNominalViewingTransform();
test.u.addBranchGraph(scene);
View v = test.u.getViewer().getView();
v.addCanvas3D(c);
BufferedImage bImage = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
ImageComponent2D buffer = new
ImageComponent2D(ImageComponent.FORMAT_RGB,
bImage);
buffer.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
c.setOffScreenBuffer(buffer);
c.renderOffScreenBuffer();
c.waitForOffScreenRendering();
try {
DataOutputStream output = new DataOutputStream(new
FileOutputStream("C:\\borstels-offscreen-test.jpg"));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
encoder.encode(bImage);
output.flush();
output.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Thank you for helping
Bj�rn
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l�cheln! Fotogalerie online mit GMX ohne eigene Homepage!
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".