JPG/MPEG

Hoi!
As I’m getting deeper into Java3D I asked myself wether there is a possibility to have a real-time screenshot made by Java3D? Perhaps triggered by a behavior? Can Java3D go into non-real-time mode and just render frame after frame and write them out? That would ne nice for high quality scenes my CPU/GPU is too slow for :stuck_out_tongue:
Or is there a direct way for creating mpegs?
I digged in the API at Canvas3D/Screen3D etc., but there doesn’t seem to be a method for this.
Greets,
cweila2s

You might consider an external grabber like FRAPS (http://www.fraps.com). I’ve used it with great success.

Kev

for screenshots:


void takeScreenshot(Canvas3D canvas3D, String filepath)
{
      // Creates a raster to hold the image data
      GraphicsContext3D  ctx = canvas3D.getGraphicsContext3D();
      Raster ras = new Raster();
      ras.setType(Raster.RASTER_COLOR);
      ras.setCapability(Raster.ALLOW_IMAGE_READ);
      Dimension d = canvas3D.getSize();
      ras.setSize(d);
      ras.setImage(new ImageComponent2D(ImageComponent2D.FORMAT_RGB, d.width, d.height));

      // Now strip out the image data
      ctx.readRaster(ras);
      ImageComponent2D img_src = ras.getImage();
      RenderedImage image = img_src.getImage();

      // Save it
      try {
            javax.imageio.ImageIO.write(image, "XXX", new File(filepath));
            System.out.println("Sreenshot saved as: " + filepath);
      } catch (java.io.IOException ioe) {
            ioe.printStackTrace();
      }
}

Hmmm, FRAPS really looks nice, but only available for Windows… (and I’m on Solaris).
The takeScreenshot method works fine, I have it in a frame triggered behavior and it writes output :smiley:
Thanks to both of you!!

Go for:

http://rsb.info.nih.gov/ij/

There’s ImageJ, that can easily convert the JPGs into an avi. There are several other programm that can do this better (or directly to an mpeg2), but ImageJ is Java and stand-alone, thus no root rights or things like that (which may be interesting for some people, it was for me).
Plus, you can write your own converters or filters easily :smiley: