mcjShiftAnim



Introduction


This daz script is similar to mcjCycle filter, 

it lets you synthesize animation curves or modify existing ones. 

The name of the script comes from the fact that i needed to shift an animated figure up to ground-level,

but did not want to do it using null nodes. 

Unlike mcjCycleFilter, there's no graphical plot of the animation curves

for long animations ( example 1800 frames ) displaying animation curves is very slow and not that useful.




History


December 14th 2013 8 PM -  fixrf issue with the extremities of looping-time-shifted. implemented the ''curPos'' constant and the ''pos'' variable

December 13th 2013 released


Installation



The zip package is found at the bottom of this page

unzip it in your daz content folder, typically 


C:\Program Files\DAZ\Studio\content\ 
or

C:\Program Files (x86)\DAZ\Studio\content\


once installed, it will appear in your content library, under Studio / Scripts / mcasual 


or

C:\Users\Public\Documents\My DAZ 3D Library\


once installed, it will appear in your content library, under My DAZ 3D Library / Scripts / mcasual
 




USE




Select the node to be processed


Launch the script



Select the property or morph channel to be modified


in the example above i selected the Scale property


select the "Processing" to be performed


in the example above i selected the "set" process


which means that the "Scale" for the selected node will be replaced by the value i supply in the Parameter field




here i supplied the parameter 2


i could also type in a short script ... more about this later


specify the range of frames to be processed in the Time-Range section


here i selected the whole playrange


click the "do it" button


for each frame of the playrange , Scale will be set to 2



The Add function

the value you type in the Parameter field will be added to the current value of the selected channel across the specified time-range




The Smooth function


for each frame, an average will be computed

it's the sum of the current value and its 2 neighbors, divided by 3


the extremities of the selected range are not modified 




The Maintain Current function


the value for the current timeline frame will be applied for the whole specified range



The Time shift function


the animation curve will be shifted by the specified number of frames


negative numbers can be used


note that the mcjReTime script is better suited for cases where you want to time shift a whole pose-animation

https://sites.google.com/site/mcasualsdazscripts2/mcjretimeanimation



The Looped Time shift  function


the animation curve will be shifted by the specified number of frames


the keyframes that "fall off" the end of the selected time-range are shifted at the start of the time-range


so if your animation was a looping animation, it will still loop after this


negative numbers can be used




The Reversed Time function


the animation curve will be mirrored in time

so an object that was moving from position 0 to 10 will now move from position 10 to 0



Expert mode for nerds

if you know a programming language like C or javascript or Daz Script, 

then in the parameter field you can type script statements instead of a number

for example, if you select the "Add" process

you could type 

 20 * sin( ang + pi / 2 );

as it processes the animation curve frame by frame, the script updates a few variables, and "ang" is one of those variables


variables

fr : current frame processed, according to the specified time range ( so the first one is not necessarily zero ). ( modifying fr may lock D|S )

iFr : the current frame , zero based, the first frame processed is zero, the last one is numFrames-1 ( iFr = fr - startFrame )

x : progression along the range of frames, Zero for the first frame, 1 for the last frame ( x = iFr / ( numFrames - 1 ) )

ang is 0 radians for the first frame and 2π for the last frame processed ( ang = x * 2 * pi )


t : the Time, in internal Daz Studio units ( t = fr * tick ) 


val : the value of the selected prop for the currently processed frame

pos the World position of the selected node  for the currently processed frame. A DzVec3.  ( curPos.x, curPos.y, curPos.z );



constants

numFrames: the number of frames in the timeRange;

startFrame the first frame of the range;

endFrame the last frame of the range;

curVal  the value of the selected property at the current timeline frame;

node the selected node. a DzNode.

prop the selected property, always a DzFloatProperty


curPos the World position of the selected node for the current timeline frame. A DzVec3.  ( curPos.x, curPos.y, curPos.z );


 

shortHand notation


by default you must access the Math functions using for example Math.sin( ang )

but for your convenience i defined shorthand version for the most common like sin

so you can type sin( ang );

  • pi = Math.PI;
  • sin = Math.sin;
  • cos = Math.cos;
  • tan = Math.tan;
  • abs = Math.abs;
  • random = Math.random;

Typical script statements


30 * sin( ang * 3 + pi / 4 )  //3 Hertz sine-wave with a 45 phase

x * 100; // Ramp going from 0 to 100 over the time range

val / 2 // half the current value

30 * abs( sin( ang * 2 ) )  // rectified 2Hz sine-wave, looks like a bouncing ball 


Save f(x) and Load f(x) buttons


The content of the "Parameter" field can be saved as a text file and later re-used


A few such files are in the attachments below 




ċ
mcjShiftAnim.zip
(27k)
mCasual Jacques,
Dec 14, 2013, 5:02 PM
Ċ
mCasual Jacques,
Dec 14, 2013, 7:20 PM
Comments