Home

SetInterpolation V 1.0 for DS 2,3,4


SetInterpolation v 1.0

For Daz Studio 2, 3, 4

by mCasual/Jacques

 


 

NEWS ! There is now a version of setinterpolation named

SetInterpV2forDS3.dsa and SetInterpV2forDS2.ds

included in the ZIP

which sets the interpolation type for the Morphs !

( instead of just the non-morphs properties )




This is a script that can only be used with Daz Studio

Daz Studio is a free 3D animation program which you can get at www.daz3d.com



Click Here to Download SetInterpolationv1.zip

the zip file contains the script for Daz Studio version 2 and 3, and the associated icons




Purpose

 

By default it seems that Daz Studio creates keyframes with splined interpolation. 

For character animation it helps create life-like movements: ease-in, ease-out, anticipation, follow-through. 

But in other cases it's not desirable since the type of spline used tends to overshoot or undershoot between keyframes

Example:

keyframe at frame 0, car door closed ( YRotation = 0° )
keyframe at frame 150, car door closed
keyframe at frame 180, car door opened ( YRotation = 90° )

with splined interpolation we get the result shown below: the car's door swings inside the car just before it opens


---

there's a variable attached to each key of each animatable property ( only properties of type DzFloatProperty ) of a given node that decides the type of interpolation used. So i wrote a script that goes through each selected node, each property, and each keyframe within a range you specify, and sets the interpolation to the type of interpolation you chose

Here's our car door animation curve after we forced the interpolation type to be "Linear"

 


 




 

Downloading and installing the Script

You can download the script and its associated icon, unzip it somewhere in your daz content folder, 

usually in the "script" sub-folder

example: C:\Program Files\DAZ\Studio\content\Scripts





Usage

Select the nodes (bones, objects) for which you want to set Interpolation types

launch the script  SetInterpolationv1,ds whih should be where you unzipped it

and have an icon that looks like this


A dialog box should popup and look like this


the range section is self-explanatory

the type of Interpolations are

  • Linear : a straight line between the keyframes

  • Constant : staircase from keyframe to keyframe

  • TCB: spline curve between keyframes ( avoid !  since it requires settings not handled herein )

  • Hermite: spline curve between keyframes ( the default interpolation type given by daz studio each time a keyframe is created




 

Appendix:

the script source

// DAZ Studio version 3.0 filetype DAZ Script

var wDlg = new DzDialog;

wDlg.caption = "Set Interpolation For Selected Nodes";

var wDlgLyt = new DzVBoxLayout( wDlg );

wDlgLyt.autoAdd = true;

wDlgLyt.margin = 5;

wDlgLyt.spacing = 5;

var timestep = Scene.getTimeStep();

var wBtnGrp1 = new DzVButtonGroup( wDlg );

wBtnGrp1.title = "Range of keys to be processed";

wBtnGrp1.columns = 1;

wBtn = new DzRadioButton( wBtnGrp1 );

wBtn.text = "Animation Range : " + Scene.getAnimRange().start / timestep + " to " + Scene.getAnimRange().end / timestep;

wBtn = new DzRadioButton( wBtnGrp1 );

wBtn.text = "Play Range : " + Scene.getPlayRange().start / timestep + " to " + Scene.getPlayRange().end / timestep;

wBtn = new DzRadioButton( wBtnGrp1 );

wBtn.text = "Current Frame Only : " + Scene.getFrame();

wBtnGrp1.selected = 0;

var wBtnGrp2 = new DzVButtonGroup( wDlg );

wBtnGrp2.title = "Type of Interpolation to set";

wBtnGrp2.columns = 1;

wBtn = new DzRadioButton( wBtnGrp2 );

wBtn.text = "LINEAR_INTERP \tLinear interpolation between key values";

wBtn = new DzRadioButton( wBtnGrp2 );

wBtn.text = "CONSTANT_INTERP \tConstant interpolation between key values";

wBtn = new DzRadioButton( wBtnGrp2 );

wBtn.text = "TCB_INTERP \tTCB (Kochanek-Bartels) Spline interpolation between key values";

wBtn = new DzRadioButton( wBtnGrp2 );

wBtn.text = "HERMITE_INTERP \tHermite Spline interpolation between key values ";

wBtnGrp2.selected = 0;

var wLbl = new DzLabel( wDlg );

wLbl.text = "You are about to change the interpolation type, possibly for a large number of keys and nodes.\nLater on, if you create new keyframes they will use the default interpolation which is \'Hermite\'";

var wDlgBtnsGB = new DzGroupBox( wDlg );

wDlgBtnsGB.flat = true;

var wDlgBtnsLyt = new DzGridLayout( wDlgBtnsGB );

wDlgBtnsLyt.margin = 5;

wDlgBtnsLyt.spacing = 5;

wDlgBtnsLyt.setColStretch( 1, 1 );

var wAcceptBtn = new DzPushButton( wDlgBtnsGB );

wAcceptBtn.text = "&Accept";

wAcceptBtn.minWidth = 80;

wAcceptBtn.maxHeight = 20;

wDlg.setAcceptButton( wAcceptBtn );

wDlgBtnsLyt.addWidget( wAcceptBtn, 0, 2 );

var wCancelBtn = new DzPushButton( wDlgBtnsGB );

wCancelBtn.text = "&Cancel";

wCancelBtn.minWidth = 80;

wCancelBtn.maxHeight = 20;

wDlg.setRejectButton( wCancelBtn );

wDlgBtnsLyt.addWidget( wCancelBtn, 0, 3 );

wDlg.width = wDlg.minWidth > 400 ? wDlg.minWidth : 400;

wDlg.height = wDlg.minHeight;

if( wDlg.exec() )

{

process();

}

//========================================================================

//

//========================================================================

function process()

{

var range;

switch( wBtnGrp1.selected )

{

case 0:

range = Scene.getAnimRange();

break;

case 1:

range = Scene.getPlayRange();

break;

case 2:

range = new DzTimeRange( Scene.getTime(), Scene.getTime() );

break;

}

var itype;

switch( wBtnGrp2.selected )

{

case 0:

itype = DzFloatProperty.LINEAR_INTERP;

break;

case 1:

itype = DzFloatProperty.CONSTANT_INTERP;

break;

case 2:

itype = DzFloatProperty.TCB_INTERP;

break;

case 3:

itype = DzFloatProperty.HERMITE_INTERP;

break;

}

var numNodes = Scene.getNumSelectedNodes();

for( var n = 0; n < numNodes; n++ )

{

node = Scene.getSelectedNode( n );

setMods( node, itype, range );

setProps( node, itype, range );

}

}

//========================================================================

//

//========================================================================

function setMods( node, itype, range )

{

var obj = node.getObject();

if( !obj )

return;

var numModifiers = obj.getNumModifiers();

for( var i = 0; i < numModifiers; i++ )

{

var modifier = obj.getModifier( i );

if( modifier.inherits( "DzMorph" ) )

{

var prop = modifier.getValueChannel();

if( prop.canAnimate() )

{

if( prop.hasKeys() )

{

if( prop.isNumeric () ) //if( prop.isA( "DzFloatProperty" ) )

{

var numKeys = prop.getNumKeys();

for( var j = 0; j < numKeys; j++ )

{

var kt = prop.getKeyTime( j );

if( ( kt >= range.start ) && ( kt <= range.end ) )

{

if( prop.setKeyInterpolation )

prop.setKeyInterpolation( j, itype );

}

}

}

}

}

}

}

}

//========================================================================

//

//========================================================================

function setProps( node, itype, range )

{

var numProps = node.getNumProperties();

for( var i = 0; i < numProps; i++ )

{

var prop = node.getProperty( i );

if( prop.canAnimate() )

{

if( prop.hasKeys() )

{

if( prop.isNumeric () ) //if( prop.isA( "DzFloatProperty" ) )

{

var numKeys = prop.getNumKeys();

for( var j = 0; j < numKeys; j++ )

{

var kt = prop.getKeyTime( j );

if( ( kt >= range.start ) && ( kt <= range.end ) )

{

if( prop.setKeyInterpolation )

prop.setKeyInterpolation( j, itype );

}

}

}

}

}

}

}


 

 

 

Č
ċ
ď
mCasual Jacques,
Nov 7, 2009, 4:01 AM
Comments