# Houdini 表达式 Expression functions # 表达式全局变量
部分全局变量等价于以 `@` 开头的变量来适配 [VEX Snippets ](http://www.sidefx.com/docs/houdini/vex/snippets.html)中的变量。
Snippet (片段)是编程用语,用来表示那些可以重复利用的代码片段。 Playback 回放`$` | `@` | Description |
---|---|---|
`$FPS` | 每秒回放的帧数 (也可以通过播放栏上的设置修改). | |
`$FSTART` | 动画起始帧的帧数字 (也可以通过播放栏上的设置修改). **$NFRAMES** (动画帧数) = $FEND - $FSTART + 1. | |
`$FEND` | 动画末帧的帧数字(也可以通过播放栏上的设置修改). | |
`$F` | 当前帧数字, 这是个非常有用的变量,尤其是给渲染的序列帧文件编号 | |
`$FF` | `@Frame` | 浮点帧数字 |
`$NFRAMES` | 动画的总帧数 `$NFRAMES = $FEND - $FSTART + 1`. | |
`$RFSTART` | 播放栏中显示的第一帧的帧数字。 播放栏可以显示长动画中的特定部分,使你可以专注于编辑这部分动画。 $RFSTART 和 $RFEND 控制播放栏显示特定部分的长度 | |
`$RFEND` | 播放栏中显示的最后一帧的帧数字 | |
`$T` | `@Time` | 以秒为单位的当前时间, 等同于 ($F-1)/$FPS |
`$TLENGTH` | 秒为单位的动画总时长 | |
`$TSTART` | 秒为单位的动画开始时间 | |
`$TEND` | 秒为单位的动画结束时间 |
`$ACTIVETAKE` | 包含了当前TAKE(拍摄)的名称 | |
`$E` | 数学常数 e (2.71828…). | |
`$HFS` | Houdini的安装目录 | |
`$HH` | `$HFS/houdini`. | |
`$HIP` | 包含当前场景文件的文件目录 | |
`$HIPFILE` | 包含扩展名的,当前场景文件的完整路径 | |
`$HIPNAME` | 不包含扩展名的当前场景文件完整路径。你可以用此变量基于当前场景名称创建不同扩展名的文件。 | |
`$HOME` | 你的 Home 目录 | |
`$JOB` | 你的 [project directory](http://www.sidefx.com/docs/houdini/basics/project.html "The File > New Project and File > Set Project menu items let you set up project directories and associate scene files with projects.").(工程目录) | |
`$PI` | 数学常数 pi (3.1415926…). |
`$OS` | Operator String. Contains the current OP’s name. |
`$CH` | Current channel name. |
`$IV` | In value (value at start of segment). |
`$OV` | Out value. |
`$IM` | In slope |
`$OM` | Out slope |
`$IA` | In acceleration |
`$OA` | Out acceleration |
`$LT` | Local time - not including stretch or offset |
`$IT` | Start time of segment |
`$OT` | End time of segment |
`$LIT` | Local start time of segment |
`$LOT` | Local end time of segment |
`$PREV_IT` | Previous segment start time |
`$NEXT_OT` | Next segment end time |
`$CSTART` | Start frame of the current COP. |
`$CEND` | End frame of the current COP. |
`$CFRAMES` | Number of frames for the current COP. |
`$CFRAMES_IN` | Number of frames available from the first input COP. |
`$CINC` | Gets the global frame increment value. |
`$W` | Current image width. |
`$H` | Current image height |
`$N` | Current frame being rendered. |
`$NRENDER` | Number of frames being rendered. |
HScript 表达式 | 使用 [expression functions](http://www.sidefx.com/docs/houdini/expressions/index.html "Expression functions let you compute the value of parameters.")(表达式函数)编写表达式的传统方法 |
Python | 更强大 但是也更繁琐的方式。使用 [Houdini Object Model](http://www.sidefx.com/docs/houdini/hom/index.html "How to script Houdini using Python and the Houdini Object Model.") API 和任何 Python 本身的函数。 |
VEX | 一种快速编译的语言,只用在特定节点的特定参数上 |
你可以创建自己的参数并引用它。详见 [spare parameters](http://www.sidefx.com/docs/houdini/network/spare.html "How to add extra parameters to an individual node.").(备用参数)
要... | 这样做 |
---|---|
自动创建参数引用 | 1. 源参数上右键选择 **Copy parameter**.(复制参数) 2. 目标参数上右键选择 **Paste relative reference**.(粘贴对应参数) Houdini 会输入正确的 `ch("")` 语法让后一个参数引用前一个参数的值。 |
手动创建通道引用 | 用 HScrpt 表达式时,使用 [ch](http://www.sidefx.com/docs/houdini/expressions/ch.html "Returns the value of a parameter.") 获得另外一个参数的值。
`ch` 会从当前节点的(可能的相对)路径到参数。 比如,要得到当前节点的 Z 变换属性:
```
ch("tz")
```
获得 `lamp` 物体的 X 变换属性:
```
ch("/obj/lamp/tx")
```
获得处于相同网络的 `grid1` 节点的 Y 旋转属性:
```
ch("../grid1/ry")
```
(要获得字符串的值,使用 [chs](http://www.sidefx.com/docs/houdini/expressions/chs.html "Evaluates the string value of a parameter at the current time.").)
|
查询参数的内部名称 | 要手动引用参数,你必须知道参数的内部名称,你可以将鼠标悬停在参数框上方 或 通过参数编辑器中的 **设置** **▸ 编辑参数** 界面 **,**点击参数然后查看 **Name** 区域。 |
Position Y | ```
@P.y + rand(@Frame * @ptnum)
```
|
---|