diff src/com/aurellem/capture/examples/AdvancedVideo.java @ 14:e299cd89074d

creating Advanced Audio documentation.
author Robert McIntyre <rlm@mit.edu>
date Thu, 27 Oct 2011 21:55:51 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/com/aurellem/capture/examples/AdvancedVideo.java	Thu Oct 27 21:55:51 2011 -0700
     1.3 @@ -0,0 +1,75 @@
     1.4 +package com.aurellem.capture.examples;
     1.5 +
     1.6 +import java.io.File;
     1.7 +import java.io.IOException;
     1.8 +
     1.9 +import com.aurellem.capture.Capture;
    1.10 +import com.aurellem.capture.IsoTimer;
    1.11 +import com.aurellem.capture.video.AbstractVideoRecorder;
    1.12 +import com.jme3.app.SimpleApplication;
    1.13 +import com.jme3.material.Material;
    1.14 +import com.jme3.math.ColorRGBA;
    1.15 +import com.jme3.math.Vector3f;
    1.16 +import com.jme3.scene.Geometry;
    1.17 +import com.jme3.scene.shape.Box;
    1.18 +
    1.19 +/** Recording Video from an application suitable for upload to youtube.*/
    1.20 +public class AdvancedVideo extends SimpleApplication {
    1.21 +
    1.22 +	/*File staticVideo = 
    1.23 +		new File("/home/r/bullshit.avi");
    1.24 +		*/
    1.25 +	File movingVideo = 
    1.26 +		new File("/home/r/tmp/bullshit2.flv");
    1.27 +
    1.28 +	AbstractVideoRecorder movingRecorder ;
    1.29 +	
    1.30 +    public static void main(String[] args){
    1.31 +        AdvancedVideo app = new AdvancedVideo();
    1.32 +        app.start();
    1.33 +    }
    1.34 +
    1.35 +    public void initVideo(){ 
    1.36 +    	this.setTimer(new IsoTimer(60));
    1.37 +    	/*try{
    1.38 +    		// set the timer to 30fps lock-step
    1.39 +    		this.setTimer(new IsoTimer(30)); 
    1.40 +    		
    1.41 +    		//ViewPort compositeViewPort = renderManager.createFinalView("composite", cam);
    1.42 +    		//compositeViewPort.attachScene(this.rootNode);
    1.43 +    		//compositeViewPort.attachScene(this.guiNode);
    1.44 +    		this.viewPort.setClearFlags(true, true, true);
    1.45 +    		this.viewPort.setBackgroundColor(ColorRGBA.Black);
    1.46 +    		movingRecorder = new AVIVideoRecorder(movingVideo); 
    1.47 +    		this.stateManager.attach(movingRecorder);
    1.48 +    		this.viewPort.addFinalProcessor(movingRecorder);
    1.49 +    		this.viewPort.attachScene(this.guiNode);
    1.50 +    		
    1.51 +    	}catch (IOException e) {
    1.52 +    		e.printStackTrace();}
    1.53 +    		*/
    1.54 +    	try {Capture.captureVideo(this, movingVideo);} 
    1.55 +    	catch (IOException e) {e.printStackTrace();}
    1.56 +		
    1.57 +    }
    1.58 +    protected Geometry player;
    1.59 +    
    1.60 +    public void simpleInitApp() {
    1.61 +    	initVideo(); // begin recording!
    1.62 +    	/** this blue box is our player character */
    1.63 +    	Box b = new Box(Vector3f.ZERO, 1, 1, 1);
    1.64 +    	player = new Geometry("blue cube", b);
    1.65 +    	Material mat = new Material(assetManager,
    1.66 +    		"Common/MatDefs/Misc/Unshaded.j3md");
    1.67 +    	mat.setColor("Color", ColorRGBA.Blue);
    1.68 +    	player.setMaterial(mat);
    1.69 +    	rootNode.attachChild(player);
    1.70 +    }
    1.71 +
    1.72 +    /* Use the main event loop to trigger repeating actions. */
    1.73 +    public void simpleUpdate(float tpf) {
    1.74 +        // make the player rotate:
    1.75 +        player.rotate(0, 2*tpf, 0); 
    1.76 +    }
    1.77 +    
    1.78 +} 
    1.79 \ No newline at end of file