diff 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
line wrap: on
line diff
     1.1 --- a/src/com/aurellem/capture/examples/Advanced.java	Thu Nov 03 16:55:43 2011 -0700
     1.2 +++ b/src/com/aurellem/capture/examples/Advanced.java	Thu Nov 03 18:47:21 2011 -0700
     1.3 @@ -3,6 +3,7 @@
     1.4  import java.io.File;
     1.5  import java.io.FileNotFoundException;
     1.6  import java.io.IOException;
     1.7 +import java.lang.reflect.Field;
     1.8  import java.nio.ByteBuffer;
     1.9  import java.util.logging.Level;
    1.10  import java.util.logging.Logger;
    1.11 @@ -21,6 +22,7 @@
    1.12  import com.jme3.audio.AudioNode;
    1.13  import com.jme3.audio.Listener;
    1.14  import com.jme3.cinematic.MotionPath;
    1.15 +import com.jme3.cinematic.events.AbstractCinematicEvent;
    1.16  import com.jme3.cinematic.events.MotionTrack;
    1.17  import com.jme3.material.Material;
    1.18  import com.jme3.math.ColorRGBA;
    1.19 @@ -158,7 +160,20 @@
    1.20  		track.setCurveTension(0.80f);
    1.21  
    1.22  		motionControl = new MotionTrack(bell,track);
    1.23 -		motionControl.setTimer(new IsoTimer(60));
    1.24 +		
    1.25 +		// for now, use reflection to change the timer... 
    1.26 +		//motionControl.setTimer(new IsoTimer(60));
    1.27 +		try {
    1.28 +			Field timerField;
    1.29 +			timerField = AbstractCinematicEvent.class.getDeclaredField("timer");
    1.30 +			timerField.setAccessible(true);
    1.31 +			try {timerField.set(motionControl, new IsoTimer(60));} 
    1.32 +			catch (IllegalArgumentException e) {e.printStackTrace();} 
    1.33 +			catch (IllegalAccessException e) {e.printStackTrace();}
    1.34 +			} 
    1.35 +		catch (SecurityException e) {e.printStackTrace();} 
    1.36 +		catch (NoSuchFieldException e) {e.printStackTrace();}
    1.37 +		
    1.38  		motionControl.setDirectionType(MotionTrack.Direction.PathAndRotation);
    1.39  		motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
    1.40  		motionControl.setInitialDuration(20f);