
上QQ阅读APP看书,第一时间看更新
1.2.2 使用表达式设置叶片的形态
在“添加动态属性”卷展栏中,单击“常规”按钮,如图1-17所示。

图1-17
在系统自动弹出的“添加属性”对话框中,设置“长名称”为xingzhuang,勾选“覆盖易读名称”选项,设置“易读名称”为“形状”,“数据类型”的选项为“浮点型”,“属性类型”的选项为“每粒子(数组)”,如图1-18所示。
设置完成后,单击左下方的“确定”按钮,关闭该对话框。这时,可以看到“每粒子(数组)属性”卷展栏中会多出来一个“形状”属性,这就是刚刚添加的属性,如图1-19所示。
将光标移动至“形状”属性上,右击并执行“创建表达式”命令,如图1-20所示。

图1-18

图1-19

图1-20
在系统自动弹出的“表达式编辑器”面板中,输入:
nParticleShape1.xingzhuang=rand(0,3);
单击该面板中的“创建”按钮,如图1-21所示。

图1-21
在“实例化器(几何体替换)”卷展栏中的“常规选项”卷展栏中,设置“对象索引”的选项为xingzhuang,如图1-22所示。

图1-22
设置完成后,可以看到现在场景中的叶片颜色会随机发生变化,如图1-23所示。

图1-23
单击“FX缓存”工具架上的“将选定的nCloth模拟保存到nCache文件”图标,如图1-24所示。为粒子动画创建缓存文件。

图1-24
创建完成缓存文件后,再次播放场景动画,会发现粒子动画的播放变得非常流畅,如图1-25所示。

图1-25

图1-25(续)
技巧与提示
粒子的缓存文件创建完成后,仍然可以通过在场景中调整树叶模型的旋转角度来控制对应粒子的方向。