rlm@3: package com.aurellem.capture; rlm@3: rlm@3: import java.io.File; rlm@3: import java.io.IOException; rlm@3: rlm@9: import com.aurellem.capture.video.AVIVideoRecorder; rlm@10: import com.aurellem.capture.video.AbstractVideoRecorder; rlm@10: import com.aurellem.capture.video.XuggleVideoRecorder; rlm@3: import com.jme3.app.Application; rlm@3: import com.jme3.math.ColorRGBA; rlm@3: rlm@3: public class Capture { rlm@3: rlm@3: public static void SimpleCaptureVideo(Application app, File file) throws IOException{ rlm@3: app.getViewPort().setClearFlags(true, true, true); rlm@11: // this prevents pixels from staying in the render buffer between frames rlm@11: // and messing the video up. It's not a problem since Black is the default, and this rlm@11: // can be overridden by user code. rlm@3: app.getViewPort().setBackgroundColor(ColorRGBA.Black); rlm@10: rlm@10: // The XuggleVideoRecorder is better than the AVIVideoRecorder in every way rlm@10: // except for ease of installation. The excellent work by Werner Randelshofer rlm@10: // is used as a fallback option. Please visit http://www.xuggle.com/ to learn rlm@10: // how to set up the XuggleVideoRecorder. rlm@10: rlm@10: AbstractVideoRecorder videoRecorder; rlm@10: rlm@10: if (file.getCanonicalPath().endsWith(".avi")){ rlm@10: videoRecorder = new AVIVideoRecorder(file);} rlm@11: else { videoRecorder = new XuggleVideoRecorder(file);} rlm@10: rlm@3: app.getStateManager().attach(videoRecorder); rlm@3: app.getViewPort().addFinalProcessor(videoRecorder); rlm@11: } rlm@3: }