Notifications
Clear all

[Closed] Addnewkeys problem

Here is something that sort of works in real time:


 
theTimer = dotNetObject "System.Windows.Forms.Timer" 
posobject = #()
fn storepos = ( 
	   append posobject $.pos;
   slidertime = slidertime +1;
 
 ) 
dotnet.addEventHandler theTimer "tick"  storepos 
theTimer.interval = 30
 
	 t = 0; 
	slidertime = 0;
theTimer.start() ;
 when  transform $ changes id:#capturemove do ( 
	 theTimer.stop();
  storepos();
  theTimer.start();
  ) 
 
 
 

So that the timer ticks over recording position at regular intervals, until the object is moved, then the callback function stores the position. At rest, the timer kicks in again.
For playback we use:


 
slidertime = 0;
theTimer.stop();
 deleteAllChangeHandlers id:#capturemove;
 animate on;
 for t =  1 to posobject.count do (
  slidertime = slidertime + 1;
 
   $.pos = posobject[t];
 
 )
 animate off
 
 

However I noticed that the “when…do” callback construct repeats the last stationary position every second time it’s invoked. No idea why. Any clues denis?

Hi Denis, if you are still viewing this thread, I think I’ve solved the capture move problem using this :


theTimer = dotNetObject "System.Windows.Forms.Timer" 
 
posobject = #()
 
fn storepos = ( 
	append posobject $.pos;
	  slidertime = slidertime +1;
					) 
 
dotnet.addEventHandler theTimer "tick"  storepos 
theTimer.interval = 30
 
 slidertime = 0
  theTimer.start() ;
 
 
 when  transform $ changes id:#capturemove handleAt:#redrawViews do ( 
					  theTimer.stop();
					  storepos()
					  theTimer.start();
				   ) 
 
 
 

And for playback:


 
slidertime = 0;
deleteAllChangeHandlers id:#capturemove;
  theTimer.stop();
 animate on
 for t =  1 to posobject.count do (
 		  slidertime = slidertime + 1;
 
  		$.pos = posobject[t];
 
			   )
 animate off
 
 
 

I’ve tested it and it runs quite well. Can you think of some improvements, like some code for storing the baked animation in a custom file?

Page 2 / 2