comparison src/com/aurellem/capture/Capture.java @ 49:121b6d7e4d3f

more friendly AppSettings handling
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Dec 2011 13:22:27 -0600
parents 388f9d062012
children 3dc1f15e1e13
comparison
equal deleted inserted replaced
48:6ecfef90e9eb 49:121b6d7e4d3f
12 import com.aurellem.capture.video.XuggleVideoRecorder; 12 import com.aurellem.capture.video.XuggleVideoRecorder;
13 import com.jme3.app.Application; 13 import com.jme3.app.Application;
14 import com.jme3.audio.AudioRenderer; 14 import com.jme3.audio.AudioRenderer;
15 import com.jme3.renderer.ViewPort; 15 import com.jme3.renderer.ViewPort;
16 import com.jme3.scene.Spatial; 16 import com.jme3.scene.Spatial;
17 import com.jme3.system.AppSettings;
17 import com.jme3.system.JmeSystem; 18 import com.jme3.system.JmeSystem;
18 19
19 public class Capture { 20 public class Capture {
20 21
21 public static void captureVideo(final Application app, final File file) throws IOException{ 22 public static void captureVideo(final Application app, final File file) throws IOException{
35 Callable<Object> thunk = new Callable<Object>(){ 36 Callable<Object> thunk = new Callable<Object>(){
36 public Object call(){ 37 public Object call(){
37 38
38 ViewPort viewPort = 39 ViewPort viewPort =
39 app.getRenderManager() 40 app.getRenderManager()
40 .createPostView("aurellem record", app.getCamera()); 41 .createPostView("aurellem video record", app.getCamera());
41 42
42 viewPort.setClearFlags(false, false, false); 43 viewPort.setClearFlags(false, false, false);
43 44
44 // get GUI node stuff 45 // get GUI node stuff
45 for (Spatial s : app.getGuiViewPort().getScenes()){ 46 for (Spatial s : app.getGuiViewPort().getScenes()){
54 app.enqueue(thunk); 55 app.enqueue(thunk);
55 } 56 }
56 57
57 58
58 public static void captureAudio(final Application app, final File file) throws IOException{ 59 public static void captureAudio(final Application app, final File file) throws IOException{
59 60 AppSettings settings = null;
61 if (app.getContext() != null){settings = app.getContext().getSettings();}
62 if (settings == null){settings = new AppSettings(true);}
63 settings.setAudioRenderer("Send");
64 app.setSettings(settings);
65
60 JmeSystem.setSystemDelegate(new AurellemSystemDelegate()); 66 JmeSystem.setSystemDelegate(new AurellemSystemDelegate());
61 67
68
62 final WaveFileWriter writer = new WaveFileWriter(file); 69 final WaveFileWriter writer = new WaveFileWriter(file);
63 70
64 Callable<Object> thunk = new Callable<Object>(){ 71 Callable<Object> thunk = new Callable<Object>(){
65 public Object call(){ 72 public Object call(){
66 AudioRenderer ar = app.getAudioRenderer(); 73 AudioRenderer ar = app.getAudioRenderer();
71 return null; 78 return null;
72 } 79 }
73 }; 80 };
74 81
75 app.enqueue(thunk); 82 app.enqueue(thunk);
76 } 83 }
77
78 } 84 }