A ClipEffect represents the set of effects associated with a
Clip. Each ClipEffect object contains one item corresponding to
a
MappedItem.
These ClipEffectItems contain expressions that control the clip
without affecting the
Source on which the clip was instantiated. For example, you can
create a walk cycle with a progressive offset by using an
expression similar to this:
ClipEffects are available from the
Clip object using Clip::GetEffect.
- See also:
-
Clip, MappedItem::GetClipEffectItem,
ClipEffectItem, Clip::GetEffect,
GetMappingRule,
SetMappingRule
- Since:
- 4.0
- Example:
- Demonstrates how to use MappedItems to look for a specific
animation channel. Once this channel is found a clip effect is
added onto it.
using namespace XSI;
Application app;
Model root = app.GetActiveSceneRoot();
X3DObject myCube;
root.AddGeometry( L"Cube", L"MeshSurface", L"", myCube );
CValueArray args(9);
CValue outArg;
args[0] = root;
args[1] = L"cube.kine.local.posx,cube.kine.local.posy,cube.kine.local.posz";
args[2] = 1l;
args[3] = L"StoredStaticPose";
args[4] = true;
args[5] = 1l;
args[6] = 5l;
args[7] = false;
args[8] = false;
app.ExecuteCommand( L"StoreAction", args, outArg );
Source mySource(outArg);
CValueArray addClipArgs(6);
addClipArgs[0] = root;
addClipArgs[1] = mySource.GetFullName();
addClipArgs[5] = L"MyClip1";
app.ExecuteCommand( L"AddClip", addClipArgs, outArg );
Clip myClip(outArg);
CRefArray mappedItems = myClip.GetMappedItems();
LONG i;
MappedItem currItem;
for(i = 0; i < mappedItems.GetCount(); ++i)
{
currItem = mappedItems[i];
Parameter param = currItem.GetDestination();
if(param.GetFullName().IsEqualNoCase(L"cube.kine.local.posy"))
{
CValueArray mappingRuleArgs(4);
mappingRuleArgs[0] = myClip.GetFullName() + L".ActionClip";
mappingRuleArgs[1] = param;
mappingRuleArgs[2] = L"frame";
mappingRuleArgs[3] = (LONG)(i + 1);
app.ExecuteCommand(L"SetMappingRule", mappingRuleArgs, outArg);
break;
}
}
ClipEffectItem effectItem(currItem.GetClipEffectItem());
app.LogMessage(L"The expression associated with the posy item is >> " +
effectItem.GetExpression());
- Example:
- Illustrates how to get at the
ClipEffect objects by creating some sources and clips with clip
effects and then finding them again through the mapped items on the
clips in the mixer.
using namespace XSI;
CString GetRelativeNameForTarget( Parameter& in_param );
void CreateStaticSource();
Application app;
CValueArray cargs; CValue oarg;
cargs.Add( L"" ); cargs.Add( false );
app.ExecuteCommand( L"NewScene", cargs, oarg );
cargs.Clear(); oarg.Clear();
Model root = app.GetActiveSceneRoot();
CreateStaticSource();
Mixer mix = root.GetMixer();
CRefArray cliplist = mix.GetClips();
for ( LONG i=0; i<cliplist.GetCount(); ++i ) {
Clip clp( cliplist[i] );
if ( clp.GetType() != siClipAudioType ) {
CRefArray mappings = clp.GetMappedItems();
if ( mappings.IsValid() ) {
app.LogMessage( L"Found " + CString(mappings.GetCount()) + L" mapped items(s)" );
for ( LONG j=0; j<mappings.GetCount(); j++ ) {
MappedItem mapitem( mappings[j] );
ClipEffectItem clpfxitem = mapitem.GetClipEffectItem();
if ( clpfxitem.GetExpression() != L"" ) {
app.LogMessage( L"...this clip has a clip effect item matching this expression:" );
app.LogMessage( L" " + clpfxitem.GetExpression() );
}
Parameter dest( mapitem.GetDestination() );
app.LogMessage( L"...destination parameter: " + dest.GetFullName() );
}
}
}
}
CString GetRelativeNameForTarget( Parameter& in_param )
{
Model mdl = in_param.GetModel();
CString mdlname = mdl.GetFullName();
if ( mdlname.IsEqualNoCase(L"Scene_Root") ) {
return in_param.GetFullName();
} else {
CString tmp = in_param.GetFullName();
CString lookfor = mdlname + L".";
CString foundsofar = L"";
CString relpath = L"";
for ( ULONG i=0; i<tmp.Length(); ++i ) {
if ( foundsofar.IsEqualNoCase(lookfor) ) {
relpath += tmp[i];
} else {
foundsofar += tmp[i];
}
}
return relpath;
}
}
void CreateStaticSource()
{
Application app;
Model root = app.GetActiveSceneRoot();
Null n; root.AddNull( L"MyNull", n );
Parameter posx = n.GetParameter( L"posx" ); CString rposx = GetRelativeNameForTarget( posx );
Parameter posy = n.GetParameter( L"posy" ); CString rposy = GetRelativeNameForTarget( posy );
Parameter posz = n.GetParameter( L"posz" ); CString rposz = GetRelativeNameForTarget( posz );
ActionSource src = root.AddActionSource( L"StoredStaticPose" );
src.AddSourceItem( rposx, 5.5743, true );
src.AddSourceItem( rposy, 0.1953, true );
src.AddSourceItem( rposy, -0.0195, true );
CValueArray clpArgs(9); CValue clpOut;
clpArgs[0] = root.GetFullName();
clpArgs[1] = src.GetFullName();
clpArgs[4] = CValue(4.0);
app.ExecuteCommand( L"AddClip", clpArgs, clpOut );
}