annotate src/com/aurellem/capture/Capture.java @ 11:8a6b1684f536

refactored.
author Robert McIntyre <rlm@mit.edu>
date Thu, 27 Oct 2011 02:27:02 -0700
parents 4c5fc53778c1
children d10f4d4ff15a
rev   line source
rlm@3 1 package com.aurellem.capture;
rlm@3 2
rlm@3 3 import java.io.File;
rlm@3 4 import java.io.IOException;
rlm@3 5
rlm@9 6 import com.aurellem.capture.video.AVIVideoRecorder;
rlm@10 7 import com.aurellem.capture.video.AbstractVideoRecorder;
rlm@10 8 import com.aurellem.capture.video.XuggleVideoRecorder;
rlm@3 9 import com.jme3.app.Application;
rlm@3 10 import com.jme3.math.ColorRGBA;
rlm@3 11
rlm@3 12 public class Capture {
rlm@3 13
rlm@3 14 public static void SimpleCaptureVideo(Application app, File file) throws IOException{
rlm@3 15 app.getViewPort().setClearFlags(true, true, true);
rlm@11 16 // this prevents pixels from staying in the render buffer between frames
rlm@11 17 // and messing the video up. It's not a problem since Black is the default, and this
rlm@11 18 // can be overridden by user code.
rlm@3 19 app.getViewPort().setBackgroundColor(ColorRGBA.Black);
rlm@10 20
rlm@10 21 // The XuggleVideoRecorder is better than the AVIVideoRecorder in every way
rlm@10 22 // except for ease of installation. The excellent work by Werner Randelshofer
rlm@10 23 // is used as a fallback option. Please visit http://www.xuggle.com/ to learn
rlm@10 24 // how to set up the XuggleVideoRecorder.
rlm@10 25
rlm@10 26 AbstractVideoRecorder videoRecorder;
rlm@10 27
rlm@10 28 if (file.getCanonicalPath().endsWith(".avi")){
rlm@10 29 videoRecorder = new AVIVideoRecorder(file);}
rlm@11 30 else { videoRecorder = new XuggleVideoRecorder(file);}
rlm@10 31
rlm@3 32 app.getStateManager().attach(videoRecorder);
rlm@3 33 app.getViewPort().addFinalProcessor(videoRecorder);
rlm@11 34 }
rlm@3 35 }