AEJoy —— AE 插件开发中的 命令选择器(一)

363 阅读2分钟

「这是我参与11月更文挑战的第 21 天,活动详情查看:2021最后一次更文挑战」。

参加该活动的第 38 篇文章

正文

命令选择器

简单地说,命令就是 After Effects 想要你的 effect 去做的事。

对某些选择器的响应是必需的;大多数是可选的,但回想一下,我们添加它们还是有原因的 ……

发送每个命令选择器后,effect 从 After Effects 接收 PF_InData 形式的信息,还有 PF_ParamDef[] 形式的输入和参数值(包括输入层的参数描述数组),并访问回调和函数组。

然后,它们将信息以 PF_OutData 的形式发送回 After Effects,并(在适当的时候)将输出渲染到 PF_LayerDef,也称为 PF_EffectWorld

在事件期间,它们以 PF_EventExtra 形式接收特定于事件的信息。

Command Selectors

Commands are, simply, what After Effects wants your effect to do.

Responses to some selectors are required; most are optional, though recall that we did add them for a reason

With each command selector sent, effects receive information from After Effects in PF_InData, input and parameter values in PF_ParamDef[] (an array of parameter descriptions including the input layer), and access to callbacks and function suites.

They send information back to After Effects in PF_OutData, and (when appropriate) render output to a PF_LayerDef, also called a PF_EffectWorld.

During events, they receive event-specific information in PF_EventExtra.

调用序列

只有前几个命令选择器是可预测的;调用序列的其余部分由用户操作决定

第一次应用时,插件接收 PF_Cmd_GLOBAL_SETUP ,然后是PF_Cmd_PARAM_SETUP。每次用户添加 effect 到一个层都会发送 PF_Cmd_SEQUENCE_SETUP

对于由基础的非 SmartFX effect 渲染的每一帧,After Effects 会发送 PF_Cmd_FRAME_SETUP,然后 PF_Cmd_RENDER ,然后 PF_Cmd_FRAME_SETDOWN

所有效果插件必须响应 PF_Cmd_RENDER

对于 SmartFX , 在单个 PF_Cmd_SMART_RENDER 被发送之前, PF_Cmd_SMART_PRE_RENDER 可以被发送任意次数。

当用户删除一个 effect 或关闭项目时,会在退出的时候发送 PF_Cmd_SEQUENCE_SETDOWNPF_Cmd_SEQUENCE_RESETUP 是在项目被加载或它所应用的层发生变化时发送的。PF_Cmd_SEQUENCE_FLATTEN 是在 After Effects 项目写入磁盘时发送的。

当用户从效果控制窗口(ECW)中选择 About… 时,发送PF_Cmd_ABOUT

PF_Cmd_GLOBAL_SETDOWN 在 After Effects 关闭或删除最后一个 effect 实例时被发送。不要依赖此消息来确定插件何时从内存中删除; 使用操作系统特定的入口点。

Calling Sequence

Only the first few command selectors are predictable; the rest of the calling sequence is dictated by user action.

When first applied, a plug-in receives PF_Cmd_GLOBAL_SETUP, then PF_Cmd_PARAM_SETUP. Each time the user adds the effect to a layer, PF_Cmd_SEQUENCE_SETUP is sent.

For each frame rendered by a basic non-SmartFX effect, After Effects sends PF_Cmd_FRAME_SETUP, then PF_Cmd_RENDER, then PF_Cmd_FRAME_SETDOWN.

All effect plug-ins must respond to PF_Cmd_RENDER

For SmartFX, PF_Cmd_SMART_PRE_RENDER may be sent any number of times, before a single PF_Cmd_SMART_RENDER is sent.

PF_Cmd_SEQUENCE_SETDOWN is sent on exit, when the user removes an effect or closes the project. PF_Cmd_SEQUENCE_RESETUP is sent when a project is loaded or when the layer to which it’s applied changes. PF_Cmd_SEQUENCE_FLATTEN is sent when the After Effects project is written out to disk.

PF_Cmd_ABOUT is sent when the user chooses About… from the Effect Controls Window (ECW).

PF_Cmd_GLOBAL_SETDOWN is sent when After Effects closes, or when the last instance of the effect is removed. Do not rely on this message to determine when your plug-in is being removed from memory; use OS-specific entry points.