SDK: Set keyframes of effect parameters
Hey
I'm working on a c++ effect for After Effects. When the effect is added to the layer, one of the parameters should already have two keyframes. What would be the best way to do that? My idea was to put the code in the GlobalSetup function. I do realise that if that works I will probably need an if statement checking if it is already keyframed.
My problem is simply how to write a keyframe to the effects parameter. I feel close but I'm not sure how to actually set the desired value. I have this:
static PF_Err
GlobalSetup (
PF_InData *in_data,
PF_OutData *out_data,
PF_ParamDef *params[],
PF_LayerDef *output )
{
PF_Err err = PF_Err_NONE;
PF_Handle globH = NULL;
my_global_dataP globP = NULL;
AEGP_PluginID pluginID;
AEGP_StreamRefH streamH = NULL;
AEGP_AddKeyframesInfoH akH = NULL;
AEGP_EffectRefH effectPH = NULL;
A_long indexPL = NULL;
AEGP_StreamValue2 valueP;
AEGP_SuiteHandler suites(in_data->pica_basicP);
out_data->my_version = PF_VERSION( MAJOR_VERSION,
MINOR_VERSION,
BUG_VERSION,
STAGE_VERSION,
BUILD_VERSION);
out_data->out_flags = PF_OutFlag_PIX_INDEPENDENT |
PF_OutFlag_SEND_UPDATE_PARAMS_UI |
PF_OutFlag_USE_OUTPUT_EXTENT |
PF_OutFlag_DEEP_COLOR_AWARE |
PF_OutFlag_WIDE_TIME_INPUT;
out_data->out_flags2 = PF_OutFlag2_PARAM_GROUP_START_COLLAPSED_FLAG |
PF_OutFlag2_DOESNT_NEED_EMPTY_PIXELS |
PF_OutFlag2_AUTOMATIC_WIDE_TIME_INPUT |
PF_OutFlag2_SUPPORTS_THREADED_RENDERING;
globH = suites.HandleSuite1()->host_new_handle(sizeof(my_global_data));
if (globH) {
globP = reinterpret_cast<my_global_dataP>(suites.HandleSuite1()->host_lock_handle(globH));
if (globP) {
globP->initializedB = TRUE;
if (in_data->appl_id != 'PrMr') {
ERR(suites.UtilitySuite3()->AEGP_RegisterWithAEGP(NULL, STR(StrID_Name), &globP->my_id));
}
if (!err){
out_data->global_data = globH;
}
}
suites.HandleSuite1()->host_unlock_handle(globH);
} else {
err = PF_Err_INTERNAL_STRUCT_DAMAGED;
}
const A_char* pluginName = STR(StrID_Name);
ERR(suites.UtilitySuite5()->AEGP_RegisterWithAEGP(NULL, pluginName, &pluginID));
ERR(suites.PFInterfaceSuite1()->AEGP_GetNewEffectForEffect(pluginID, in_data->effect_ref, &effectPH));
ERR(suites.StreamSuite5()->AEGP_GetNewEffectStreamByIndex(pluginID, effectPH, 25, &streamH));
ERR(suites.KeyframeSuite4()->AEGP_StartAddKeyframes(streamH, &akH));
ERR(suites.KeyframeSuite4()->AEGP_AddKeyframes(akH, AEGP_LTimeMode_CompTime, 0, &indexPL));
valueP.one_d = 20; // How do I set the value?
ERR(suites.KeyframeSuite4()->AEGP_SetAddKeyframe(akH, indexPL, &valueP));
ERR(suites.StreamSuite3()->AEGP_DisposeStreamValue(&valueP));
AEFX_CLR_STRUCT(valueP);
ERR(suites.KeyframeSuite4()->AEGP_EndAddKeyframes(true, akH));
ERR(suites.StreamSuite2()->AEGP_DisposeStream(streamH));
ERR(suites.EffectSuite2()->AEGP_DisposeEffect(effectPH));
return err;
}I get this error: class "AEGP_StreamValue2" has no member "one_d.
Any help will be greatly appreciated.
Thanks,
Jakob
