> I think that everyone can easy to write a Java3D program to slie show some
> picture. But I don't know how to render it into AVI file or another movie
> format. Who can help me to solve this problem ASAP. Thanks.
Hi,
I had that problem once ago too. The only solution I found was to take a
screenshot of the canvas in postSwap() (inherited from Canvas3D). When I
switched recording on (iMode = VIDEO) everytime postSwap was called an JPEG
is saved to disk. After turning recording off the images were processed to
a video (that is something you can find in every JMF tutorial). The problem
is that postSwap() is only called whenever somethin happens to the
universe. So e.g. if you have an animation with a shere moving to the
right, staing there for 2 seconds and the moving back. The video won't show
the two seconds of rest for the sphere. Here is a part of the code in
postSwap() (hardly undocumended but I don't have much time now).
public void postSwap()
{
if(iMode != NORMAL) {
//System.out.println("get image..");
GraphicsContext3D ctx = getGraphicsContext3D();
// The raster components need all be set!
Raster ras = new Raster(
new Point3f(-1.0f,-1.0f,-1.0f),
Raster.RASTER_COLOR,
0,0,
this.getWidth(),getHeight(),
new ImageComponent2D(
ImageComponent.FORMAT_RGB,
new BufferedImage(getWidth(), getHeight(),
BufferedImage.TYPE_INT_RGB)),
null);
ctx.readRaster(ras);
// Now strip out the image info
BufferedImage img = ras.getImage().getImage();
// write that to disk....
try {
FileOutputStream out;
if (iMode == VIDEO)
{
out = new FileOutputStream(theSavePath.getParent() +
"Capture" + postSwapCount_+".jpg");
//store which files belong to this videosequence in a
buffer
imageBuffer.add(theSavePath.getParent() + "Capture" +
postSwapCount_+".jpg");
}
//take just one screenshot so we don't need a special name
else
{
out = new FileOutputStream(theSavePath);
}
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
param.setQuality(0.75f,false); // 75% quality for the JPEG
encoder.setJPEGEncodeParam(param);
encoder.encode(img);
out.close();
//OK we've got our screenshot --> do nothing next time this function is
called
if (iMode == SCREENSHOT) iMode = NORMAL;
} catch ( IOException e ) {
System.out.println("I/O exception!");
}
//for the next image...
if (iMode == VIDEO) postSwapCount_++;
}
}
Hope it helps
Cheers
Christian