diff src/com/aurellem/capture/hello/HelloVideo.java @ 0:9c4438349e88

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