changeset 49:121b6d7e4d3f

more friendly AppSettings handling
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Dec 2011 13:22:27 -0600
parents 6ecfef90e9eb
children 8a091a5f48fa
files src/com/aurellem/capture/AurellemSystemDelegate.java src/com/aurellem/capture/Capture.java src/com/aurellem/capture/examples/Advanced.java
diffstat 3 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/src/com/aurellem/capture/AurellemSystemDelegate.java	Sat Dec 03 12:53:31 2011 -0600
     1.2 +++ b/src/com/aurellem/capture/AurellemSystemDelegate.java	Sat Dec 03 13:22:27 2011 -0600
     1.3 @@ -7,8 +7,15 @@
     1.4  
     1.5  public class AurellemSystemDelegate extends JmeDesktopSystem {
     1.6  	
     1.7 +	public static final String SEND = "Send";
     1.8 +	
     1.9  	public AudioRenderer newAudioRenderer(AppSettings settings) {
    1.10          initialize(settings);
    1.11 -        return new AudioSendRenderer();
    1.12 +        if (settings.getAudioRenderer() == SEND){
    1.13 +        	return new AudioSendRenderer();
    1.14 +        }
    1.15 +        else {
    1.16 +        	return super.newAudioRenderer(settings);        	
    1.17 +        }        
    1.18      }	
    1.19  }
    1.20 \ No newline at end of file
     2.1 --- a/src/com/aurellem/capture/Capture.java	Sat Dec 03 12:53:31 2011 -0600
     2.2 +++ b/src/com/aurellem/capture/Capture.java	Sat Dec 03 13:22:27 2011 -0600
     2.3 @@ -14,6 +14,7 @@
     2.4  import com.jme3.audio.AudioRenderer;
     2.5  import com.jme3.renderer.ViewPort;
     2.6  import com.jme3.scene.Spatial;
     2.7 +import com.jme3.system.AppSettings;
     2.8  import com.jme3.system.JmeSystem;
     2.9  
    2.10  public class Capture {
    2.11 @@ -37,7 +38,7 @@
    2.12  
    2.13  				ViewPort viewPort = 
    2.14  						app.getRenderManager()
    2.15 -						.createPostView("aurellem record", app.getCamera());
    2.16 +						.createPostView("aurellem video record", app.getCamera());
    2.17  
    2.18  				viewPort.setClearFlags(false, false, false);
    2.19  
    2.20 @@ -56,9 +57,15 @@
    2.21  
    2.22  	
    2.23  	public static void captureAudio(final Application app, final File file) throws IOException{
    2.24 -		
    2.25 +		AppSettings settings = null;
    2.26 +		if (app.getContext() != null){settings = app.getContext().getSettings();}
    2.27 +		if (settings == null){settings = new AppSettings(true);}
    2.28 +		settings.setAudioRenderer("Send");
    2.29 +		app.setSettings(settings);
    2.30 +
    2.31  		JmeSystem.setSystemDelegate(new AurellemSystemDelegate());
    2.32  				
    2.33 +		
    2.34  		final WaveFileWriter writer = new WaveFileWriter(file);
    2.35  
    2.36  		Callable<Object> thunk = new Callable<Object>(){
    2.37 @@ -73,6 +80,5 @@
    2.38  		};
    2.39  		
    2.40  		app.enqueue(thunk);
    2.41 -	}
    2.42 -	
    2.43 +	}		
    2.44  }
     3.1 --- a/src/com/aurellem/capture/examples/Advanced.java	Sat Dec 03 12:53:31 2011 -0600
     3.2 +++ b/src/com/aurellem/capture/examples/Advanced.java	Sat Dec 03 13:22:27 2011 -0600
     3.3 @@ -69,7 +69,7 @@
     3.4  		//Logger.getLogger("com.jme3").setLevel(Level.OFF); 
     3.5  		Advanced app = new Advanced();
     3.6  		AppSettings settings = new AppSettings(true);
     3.7 -		settings.setAudioRenderer("Send");
     3.8 +		settings.setAudioRenderer(AurellemSystemDelegate.SEND);
     3.9  		JmeSystem.setSystemDelegate(new AurellemSystemDelegate());
    3.10  		app.setSettings(settings);
    3.11  		app.setShowSettings(false);
    3.12 @@ -164,7 +164,7 @@
    3.13  		motionControl = new MotionTrack(bell,track);
    3.14  		
    3.15  		// for now, use reflection to change the timer... 
    3.16 -		//motionControl.setTimer(new IsoTimer(60));
    3.17 +		// motionControl.setTimer(new IsoTimer(60));
    3.18  		try {
    3.19  			Field timerField;
    3.20  			timerField = AbstractCinematicEvent.class.getDeclaredField("timer");