annotate src/com/aurellem/capture/Capture.java @ 20:bc6fbfbbadd9 spazz

retarded spazz dancing achieved
author Robert McIntyre <rlm@mit.edu>
date Sat, 29 Oct 2011 16:22:57 -0700
parents d10f4d4ff15a
children 5f616cc420dd
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@12 5 import java.util.concurrent.Callable;
rlm@3 6
rlm@12 7 import com.aurellem.capture.audio.MultiListener;
rlm@12 8 import com.aurellem.capture.audio.WaveFileWriter;
rlm@9 9 import com.aurellem.capture.video.AVIVideoRecorder;
rlm@10 10 import com.aurellem.capture.video.AbstractVideoRecorder;
rlm@10 11 import com.aurellem.capture.video.XuggleVideoRecorder;
rlm@3 12 import com.jme3.app.Application;
rlm@12 13 import com.jme3.audio.AudioRenderer;
rlm@12 14 import com.jme3.renderer.ViewPort;
rlm@12 15 import com.jme3.scene.Spatial;
rlm@12 16 import com.jme3.system.AppSettings;
rlm@3 17
rlm@3 18 public class Capture {
rlm@3 19
rlm@12 20 public static void captureVideo(final Application app, final File file) throws IOException{
rlm@12 21
rlm@12 22 final AbstractVideoRecorder videoRecorder;
rlm@10 23 // The XuggleVideoRecorder is better than the AVIVideoRecorder in every way
rlm@10 24 // except for ease of installation. The excellent work by Werner Randelshofer
rlm@10 25 // is used as a fallback option. Please visit http://www.xuggle.com/ to learn
rlm@10 26 // how to set up the XuggleVideoRecorder.
rlm@12 27
rlm@12 28 if (file.getCanonicalPath().endsWith(".avi")){
rlm@12 29 videoRecorder = new AVIVideoRecorder(file);}
rlm@12 30 else { videoRecorder = new XuggleVideoRecorder(file);}
rlm@12 31
rlm@12 32 Callable<Object> thunk = new Callable<Object>(){
rlm@12 33 public Object call(){
rlm@12 34
rlm@12 35 ViewPort viewPort =
rlm@12 36 app.getRenderManager()
rlm@12 37 .createPostView("aurellem record", app.getCamera());
rlm@12 38
rlm@12 39 viewPort.setClearFlags(false, false, false);
rlm@12 40
rlm@12 41 // get GUI node stuff
rlm@12 42 for (Spatial s : app.getGuiViewPort().getScenes()){
rlm@12 43 viewPort.attachScene(s);
rlm@12 44 }
rlm@12 45
rlm@12 46 app.getStateManager().attach(videoRecorder);
rlm@12 47 viewPort.addProcessor(videoRecorder);
rlm@12 48 return null;
rlm@12 49 }
rlm@12 50 };
rlm@12 51 app.enqueue(thunk);
rlm@12 52 }
rlm@12 53
rlm@12 54
rlm@12 55 public static void captureAudio(final Application app, final File file) throws IOException{
rlm@12 56 AppSettings settings = new AppSettings(true);
rlm@12 57 settings.setAudioRenderer("Send");
rlm@12 58 app.setSettings(settings);
rlm@12 59
rlm@12 60 Callable<Object> thunk = new Callable<Object>(){
rlm@12 61 public Object call(){
rlm@12 62 AudioRenderer ar = app.getAudioRenderer();
rlm@12 63 if (ar instanceof MultiListener){
rlm@12 64 MultiListener ml = (MultiListener)ar;
rlm@12 65 ml.registerSoundProcessor(new WaveFileWriter(file));
rlm@12 66 }
rlm@12 67 return null;
rlm@12 68 }
rlm@12 69 };
rlm@10 70
rlm@12 71 app.enqueue(thunk);
rlm@12 72 }
rlm@12 73
rlm@3 74 }