rlm@14: package com.aurellem.capture.examples; rlm@14: rlm@14: import java.io.File; rlm@14: import java.io.IOException; rlm@14: rlm@14: import com.aurellem.capture.Capture; rlm@14: import com.aurellem.capture.IsoTimer; rlm@14: import com.aurellem.capture.video.AbstractVideoRecorder; rlm@14: import com.jme3.app.SimpleApplication; rlm@14: import com.jme3.material.Material; rlm@14: import com.jme3.math.ColorRGBA; rlm@14: import com.jme3.math.Vector3f; rlm@14: import com.jme3.scene.Geometry; rlm@14: import com.jme3.scene.shape.Box; rlm@14: rlm@14: /** Recording Video from an application suitable for upload to youtube.*/ rlm@14: public class AdvancedVideo extends SimpleApplication { rlm@14: rlm@14: /*File staticVideo = rlm@14: new File("/home/r/bullshit.avi"); rlm@14: */ rlm@14: File movingVideo = rlm@14: new File("/home/r/tmp/bullshit2.flv"); rlm@14: rlm@14: AbstractVideoRecorder movingRecorder ; rlm@14: rlm@14: public static void main(String[] args){ rlm@14: AdvancedVideo app = new AdvancedVideo(); rlm@14: app.start(); rlm@14: } rlm@14: rlm@14: public void initVideo(){ rlm@14: this.setTimer(new IsoTimer(60)); rlm@14: /*try{ rlm@14: // set the timer to 30fps lock-step rlm@14: this.setTimer(new IsoTimer(30)); rlm@14: rlm@14: //ViewPort compositeViewPort = renderManager.createFinalView("composite", cam); rlm@14: //compositeViewPort.attachScene(this.rootNode); rlm@14: //compositeViewPort.attachScene(this.guiNode); rlm@14: this.viewPort.setClearFlags(true, true, true); rlm@14: this.viewPort.setBackgroundColor(ColorRGBA.Black); rlm@14: movingRecorder = new AVIVideoRecorder(movingVideo); rlm@14: this.stateManager.attach(movingRecorder); rlm@14: this.viewPort.addFinalProcessor(movingRecorder); rlm@14: this.viewPort.attachScene(this.guiNode); rlm@14: rlm@14: }catch (IOException e) { rlm@14: e.printStackTrace();} rlm@14: */ rlm@14: try {Capture.captureVideo(this, movingVideo);} rlm@14: catch (IOException e) {e.printStackTrace();} rlm@14: rlm@14: } rlm@14: protected Geometry player; rlm@14: rlm@14: public void simpleInitApp() { rlm@14: initVideo(); // begin recording! rlm@14: /** this blue box is our player character */ rlm@14: Box b = new Box(Vector3f.ZERO, 1, 1, 1); rlm@14: player = new Geometry("blue cube", b); rlm@14: Material mat = new Material(assetManager, rlm@14: "Common/MatDefs/Misc/Unshaded.j3md"); rlm@14: mat.setColor("Color", ColorRGBA.Blue); rlm@14: player.setMaterial(mat); rlm@14: rootNode.attachChild(player); rlm@14: } rlm@14: rlm@14: /* Use the main event loop to trigger repeating actions. */ rlm@14: public void simpleUpdate(float tpf) { rlm@14: // make the player rotate: rlm@14: player.rotate(0, 2*tpf, 0); rlm@14: } rlm@14: rlm@14: }