comparison src/com/aurellem/capture/examples/Advanced.java @ 42:b1bc965a38d2

use reflection to set timer for MotionTrack for now
author Robert McIntyre <rlm@mit.edu>
date Thu, 03 Nov 2011 18:47:21 -0700
parents 58386a64d019
children 2f129118e2d6
comparison
equal deleted inserted replaced
41:58386a64d019 42:b1bc965a38d2
1 package com.aurellem.capture.examples; 1 package com.aurellem.capture.examples;
2 2
3 import java.io.File; 3 import java.io.File;
4 import java.io.FileNotFoundException; 4 import java.io.FileNotFoundException;
5 import java.io.IOException; 5 import java.io.IOException;
6 import java.lang.reflect.Field;
6 import java.nio.ByteBuffer; 7 import java.nio.ByteBuffer;
7 import java.util.logging.Level; 8 import java.util.logging.Level;
8 import java.util.logging.Logger; 9 import java.util.logging.Logger;
9 10
10 import javax.sound.sampled.AudioFormat; 11 import javax.sound.sampled.AudioFormat;
19 import com.aurellem.capture.audio.WaveFileWriter; 20 import com.aurellem.capture.audio.WaveFileWriter;
20 import com.jme3.app.SimpleApplication; 21 import com.jme3.app.SimpleApplication;
21 import com.jme3.audio.AudioNode; 22 import com.jme3.audio.AudioNode;
22 import com.jme3.audio.Listener; 23 import com.jme3.audio.Listener;
23 import com.jme3.cinematic.MotionPath; 24 import com.jme3.cinematic.MotionPath;
25 import com.jme3.cinematic.events.AbstractCinematicEvent;
24 import com.jme3.cinematic.events.MotionTrack; 26 import com.jme3.cinematic.events.MotionTrack;
25 import com.jme3.material.Material; 27 import com.jme3.material.Material;
26 import com.jme3.math.ColorRGBA; 28 import com.jme3.math.ColorRGBA;
27 import com.jme3.math.FastMath; 29 import com.jme3.math.FastMath;
28 import com.jme3.math.Quaternion; 30 import com.jme3.math.Quaternion;
156 track.addWayPoint(v); 158 track.addWayPoint(v);
157 } 159 }
158 track.setCurveTension(0.80f); 160 track.setCurveTension(0.80f);
159 161
160 motionControl = new MotionTrack(bell,track); 162 motionControl = new MotionTrack(bell,track);
161 motionControl.setTimer(new IsoTimer(60)); 163
164 // for now, use reflection to change the timer...
165 //motionControl.setTimer(new IsoTimer(60));
166 try {
167 Field timerField;
168 timerField = AbstractCinematicEvent.class.getDeclaredField("timer");
169 timerField.setAccessible(true);
170 try {timerField.set(motionControl, new IsoTimer(60));}
171 catch (IllegalArgumentException e) {e.printStackTrace();}
172 catch (IllegalAccessException e) {e.printStackTrace();}
173 }
174 catch (SecurityException e) {e.printStackTrace();}
175 catch (NoSuchFieldException e) {e.printStackTrace();}
176
162 motionControl.setDirectionType(MotionTrack.Direction.PathAndRotation); 177 motionControl.setDirectionType(MotionTrack.Direction.PathAndRotation);
163 motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y)); 178 motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
164 motionControl.setInitialDuration(20f); 179 motionControl.setInitialDuration(20f);
165 motionControl.setSpeed(1f); 180 motionControl.setSpeed(1f);
166 181