Hi!
This is a newbie question, I haven't yet gone through
the entire users guide, sorry.
I'm writing an applet that needs to show x3d-files in a
javax.swing.JButton (Swing). So I need to render an x3d-file
into an java.awt.Image object, after that I will call
JButton(new ImageIcon(image));
What I would like to have:
public java.awt.Image drawSpatialIntoImage(Spatial sp) { // }
Right now I'm extending SimpleJMEApplet to show the
x3d-file (class MyApplet extends SimpleJMEApplet).
Some pseudo-code:
public class MyApplet extends SimpleJMEApplet {
public void simpleAppletSetup() {
initLights();
byte[] modelBytes = getModelBytes("monkey.x3d");
showModel(modelBytes);
}
public void showModel(byte[] x3dBytes) {
ByteArrayInputStream modelIn = new ByteArrayInputStream(x3dBytes);
Map<String, InputStream> texIns = new HashMap<String, InputStream>();
X3DLoader x3DLoader;
try {
x3DLoader = new X3DLoader();
Spatial model = x3DLoader.loadScene(modelIn, texIns, lightState);
model.updateRenderState();
model.setModelBound(new BoundingBox());
model.updateModelBound();
Node node = new Node();
node.attachChild(model);
getRootNode().attachChild(node);
}
public void simpleAppletUpdate() { /changing angle/ }
}
Thanks for any suggestions or links.
Regards,
Brad