# HG changeset patch # User Robert McIntyre # Date 1319809966 25200 # Node ID be5ac56826bee30d7b5d5dc5106c979e2bef09b5 # Parent e299cd89074d40df5cf05672b9352169ce6c3afc created part of the advanced documentation diff -r e299cd89074d -r be5ac56826be src/com/aurellem/capture/examples/AdvancedAudio.java --- a/src/com/aurellem/capture/examples/AdvancedAudio.java Thu Oct 27 21:55:51 2011 -0700 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Fri Oct 28 06:52:46 2011 -0700 @@ -8,14 +8,23 @@ import com.jme3.app.SimpleApplication; import com.jme3.audio.AudioNode; import com.jme3.audio.Listener; +import com.jme3.cinematic.MotionPath; +import com.jme3.cinematic.events.MotionTrack; +import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; +import com.jme3.input.controls.KeyTrigger; import com.jme3.input.controls.MouseButtonTrigger; +import com.jme3.light.DirectionalLight; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; +import com.jme3.math.FastMath; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; import com.jme3.scene.shape.Box; +import com.jme3.scene.shape.Sphere; import com.jme3.system.AppSettings; @@ -39,18 +48,142 @@ */ public class AdvancedAudio extends SimpleApplication { - - public static void main(String[] args) { - - AdvancedAudio app = new AdvancedAudio(); - AppSettings settings = new AppSettings(true); + + public static void main(String[] args) { + + AdvancedAudio app = new AdvancedAudio(); + AppSettings settings = new AppSettings(true); + //settings.setAudioRenderer("Send"); + app.setSettings(settings); + app.setShowSettings(false); + app.setPauseOnLostFocus(false); + org.lwjgl.input.Mouse.setGrabbed(false); + app.start(); + } + - settings.setAudioRenderer("Send"); - app.setSettings(settings); - app.setShowSettings(false); - app.start(); - app.setPauseOnLostFocus(false); - } + private Spatial teapot; + private boolean active = true; + private boolean playing = false; + private MotionPath path; + private MotionTrack motionControl; + + + private void makeEar(Node root, Vector3f position){ + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + Geometry ear = new Geometry("ear", new Box(1.0f, 1.0f, 1.0f)); + ear.setLocalTranslation(position); + mat.setColor("Color", ColorRGBA.Green); + ear.setMaterial(mat); + root.attachChild(ear); + } + + + private void createScene() { + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + Geometry bell = new Geometry( "sound-emitter" , new Sphere(15,15,1)); + mat.setColor("Color", ColorRGBA.Blue); + bell.setMaterial(mat); + rootNode.attachChild(bell); + + + + + DirectionalLight light = new DirectionalLight(); + light.setDirection(new Vector3f(0, -1, 0).normalizeLocal()); + light.setColor(ColorRGBA.White.mult(1.5f)); + rootNode.addLight(light); + + makeEar(rootNode, new Vector3f(0, 0 ,20)); + makeEar(rootNode, new Vector3f(0, 0 ,-20)); + makeEar(rootNode, new Vector3f(20, 0 ,0)); + makeEar(rootNode, new Vector3f(-20, 0 ,0)); + + MotionPath path = new MotionPath(); + + // loop 1 + path.addWayPoint(new Vector3f(0, 0, 0)); + path.addWayPoint(new Vector3f(0, 0, -10)); + path.addWayPoint(new Vector3f(-2, 0, -14)); + path.addWayPoint(new Vector3f(-6, 0, -20)); + path.addWayPoint(new Vector3f(0, 0, -26)); + path.addWayPoint(new Vector3f(6, 0, -20)); + path.addWayPoint(new Vector3f(0, 0, -14)); + path.addWayPoint(new Vector3f(-6, 0, -20)); + path.addWayPoint(new Vector3f(0, 0, -26)); + path.addWayPoint(new Vector3f(6, 0, -20)); + + + // loop 2 + path.addWayPoint(new Vector3f(5, 0, -5)); + path.addWayPoint(new Vector3f(7, 0, 1.5f)); + path.addWayPoint(new Vector3f(14, 0, 2)); + path.addWayPoint(new Vector3f(20, 0, 6)); + path.addWayPoint(new Vector3f(26, 0, 0)); + path.addWayPoint(new Vector3f(20, 0, -6)); + path.addWayPoint(new Vector3f(14, 0, 0)); + path.addWayPoint(new Vector3f(20, 0, 6)); + path.addWayPoint(new Vector3f(26, 0, 0)); + path.addWayPoint(new Vector3f(20, 0, -6)); + path.addWayPoint(new Vector3f(14, 0, 0)); + + + + // loop 3 + path.addWayPoint(new Vector3f(8, 0, 7.5f)); + path.addWayPoint(new Vector3f(7, 0, 10.5f)); + path.addWayPoint(new Vector3f(6, 0, 20)); + path.addWayPoint(new Vector3f(0, 0, 26)); + path.addWayPoint(new Vector3f(-6, 0, 20)); + path.addWayPoint(new Vector3f(0, 0, 14)); + path.addWayPoint(new Vector3f(6, 0, 20)); + path.addWayPoint(new Vector3f(0, 0, 26)); + path.addWayPoint(new Vector3f(-6, 0, 20)); + path.addWayPoint(new Vector3f(0, 0, 14)); + + + // begin elipse + + path.addWayPoint(new Vector3f(16, 5, 20)); + path.addWayPoint(new Vector3f(0, 0, 26)); + path.addWayPoint(new Vector3f(-16, -10, 20)); + path.addWayPoint(new Vector3f(0, 0, 14)); + path.addWayPoint(new Vector3f(16, 20, 20)); + path.addWayPoint(new Vector3f(0, 0, 26)); + path.addWayPoint(new Vector3f(-10, -25, 10)); + path.addWayPoint(new Vector3f(-10, 0, 0)); + + // come at me bro! + path.addWayPoint(new Vector3f(-28.00242f, 48.005623f, -34.648228f)); + path.setCurveTension(0.80f); + + + motionControl = new MotionTrack(bell,path); + motionControl.setDirectionType(MotionTrack.Direction.PathAndRotation); + motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y)); + motionControl.setInitialDuration(10f); + motionControl.setSpeed(0.1f); + + + //path.enableDebugShape(assetManager, rootNode); + + + positionCamera(); + + + } + + + private void positionCamera(){ + this.cam.setLocation(new Vector3f(-28.00242f, 48.005623f, -34.648228f)); + this.cam.setRotation(new Quaternion(0.3359635f, 0.34280345f, -0.13281013f, 0.8671653f)); + + + } + + + + private AudioNode audio_gun; private AudioNode audio_nature; @@ -60,15 +193,10 @@ public File data2 = new File("/home/r/tmp/data2.wav"); public File data3 = new File("/home/r/tmp/data3.wav"); - private File makeTarget(int n){ - return new File("/home/r/tmp/assload-" + n + ".wav"); - } - @Override public void simpleInitApp() { - this.setTimer(new IsoTimer(60)); - + //this.setTimer(new IsoTimer(60)); if (this.audioRenderer instanceof MultiListener){ MultiListener rf = (MultiListener)this.audioRenderer; @@ -76,8 +204,6 @@ for (int n = 0; n < 0; n++){ Listener zzz = new Listener(); rf.addListener(zzz); - rf.registerSoundProcessor( - zzz, new WaveFileWriter(makeTarget(n))); } Listener listener3 = new Listener(); rf.addListener(auxListener); @@ -86,19 +212,17 @@ rf.registerSoundProcessor(auxListener, new WaveFileWriter(data2)); rf.registerSoundProcessor(listener3, new WaveFileWriter(data3)); } - flyCam.setMoveSpeed(40); - /** just a blue box floating in space */ - Box box1 = new Box(Vector3f.ZERO, 1, 1, 1); - player = new Geometry("Player", box1); - Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); - mat1.setColor("Color", ColorRGBA.Blue); - player.setMaterial(mat1); - rootNode.attachChild(player); - /** custom init methods, see below */ + + + initKeys(); initAudio(); + createScene(); + + + motionControl.play(); this.audioRenderer.playSource(audio_gun); @@ -152,10 +276,7 @@ listener.setRotation(rot); auxListener.setLocation(loc); auxListener.setRotation(rot); - if (audio_gun.getStatus() == AudioNode.Status.Stopped){ - System.out.println("I'm Stopped!"); - this.requestClose(false); - } + } diff -r e299cd89074d -r be5ac56826be src/com/aurellem/capture/examples/Basic.java --- a/src/com/aurellem/capture/examples/Basic.java Thu Oct 27 21:55:51 2011 -0700 +++ b/src/com/aurellem/capture/examples/Basic.java Fri Oct 28 06:52:46 2011 -0700 @@ -25,44 +25,12 @@ public class Basic { - public static void basicVideo() throws IOException{ - File video = File.createTempFile("HelloJME3", ".avi"); - System.out.println("Saving video to: " + video.getCanonicalPath()); - SimpleApplication app = new HelloJME3(); - app.setTimer(new IsoTimer(60)); - app.setShowSettings(false); + public static void main(String[] ignore) throws IOException{ + File video = File.createTempFile("JME-water-video", ".avi"); + File audio = File.createTempFile("JME-water-audio", ".wav"); - Capture.captureVideo(app, video); - app.start(); - } - - public static void basicVideoGUI() throws IOException { - File video = File.createTempFile("GUI", ".avi"); - System.out.println("Saving video to: " + video.getCanonicalPath()); - SimpleApplication app = new TestNiftyExamples(); - app.setTimer(new IsoTimer(60)); - app.setShowSettings(false); - - Capture.captureVideo(app, video); - app.start(); - } - - public static void basicAudio() throws IOException{ - File audio = File.createTempFile("BasicAudio", ".wav"); - System.out.println("Saving audio to: " + audio.getCanonicalPath()); - SimpleApplication app = new HelloAudio(); - app.setTimer(new IsoTimer(60)); - app.setShowSettings(false); - - // you will not hear the audio while it is being captured. - Capture.captureAudio(app, audio); - - app.start(); - } - - public static void basicAudioVideo() throws IOException{ - File video = new File("/home/r/tmp/basicVideo.avi"); - File audio = new File("/home/r/tmp/basicAudio.wav"); + System.out.println(video.getCanonicalPath()); + System.out.println(audio.getCanonicalPath()); SimpleApplication app = new TestPostWater(); app.setTimer(new IsoTimer(60)); @@ -73,12 +41,4 @@ app.start(); } - - - public static void main(String[] ignore) throws IOException{ - basicVideo(); - basicVideoGUI(); - basicAudio(); - basicAudioVideo(); - } } diff -r e299cd89074d -r be5ac56826be src/com/aurellem/capture/video/AVIVideoRecorder.java --- a/src/com/aurellem/capture/video/AVIVideoRecorder.java Thu Oct 27 21:55:51 2011 -0700 +++ b/src/com/aurellem/capture/video/AVIVideoRecorder.java Fri Oct 28 06:52:46 2011 -0700 @@ -38,7 +38,6 @@ } public void finish() { - System.out.println("I'm finished! <3"); try {out.close();} catch (IOException e) {e.printStackTrace();} }