在“曲线图编辑器”(Graph Editor)中,调整滑块可更改动画曲线的颜色。
更改单个动画曲线的颜色
此时将出现“更改曲线颜色选项”(Change Curve Color Options)窗口。(请参见编辑菜单(Edit menu)中的“更改曲线颜色”(Change Curve Color) > 。)
选定曲线的颜色将更改为您在“更改曲线颜色选项”(Change Curve Color Options)窗口中指定的颜色。
将属性名称与曲线颜色相关联
将出现“曲线颜色”(Curve Colors)窗口,且左侧面板中将列出您选择的属性。
还可以随时在“曲线图编辑器”(Graph Editor)的大纲视图中选择属性,并单击“曲线颜色”(Curve Colors)窗口中的“添加”(Add)以加载它们。
现在,控制该属性的动画曲线已设定为指定的颜色。
重置曲线颜色
动画曲线将重置为其默认颜色。
使用“使用曲线颜色”和“曲线颜色”属性,可以设定各个曲线的颜色或使用多个全局操作(例如,根据那些可驱动曲线的颜色组的角色一次性对曲线着色)。这类全局操作可通过 MEL 脚本完成。有关 MEL 示例脚本,请参见自定义多个动画曲线颜色的 MEL 示例程序。
“曲线图编辑器”(Graph Editor)的大纲视图和曲线视图中将出现动画曲线的所有用户定义的颜色设置。“使用曲线颜色”(Use Curve Color)复选框和“曲线颜色”(Curve Color)样例位于每个动画曲线节点(例如 animCurveN)的“动画曲线属性”(Anim Curve Attributes)区域。
可一次性显示的自定义颜色曲线最大数为 20。如果超过该数,将使用其默认颜色显示曲线。
在自定义颜色和默认曲线颜色之间切换
“使用曲线颜色”(Use Curve Color)位于每个动画曲线节点(例如,animCurveN)的“动画曲线属性”(Anim Curve Attributes)区域。请查看下列程序。
设定自定义动画曲线颜色
打开“属性编辑器”(Attribute Editor)。
选定的颜色将出现在“曲线颜色”(Curve Color)样例”中。现在,在“曲线图编辑器”(Graph Editor)的“曲线视图”(Curve View)中,动画曲线将采用“曲线颜色”(Curve Color)样例的颜色。
//+ //************************************************************************ // // Synopsis: // global proc int colourSelectedCurves( int $how, float $r, // float $g, float $b ) // // Description: // This MEL procedure assigns a curve display color to all // selected curves and curves connected to selected nodes. The curve display // color is used for drawing curves in the Graph Editor and for labelling // curves in the Dope Sheet. // The following example creates a cube, torus, and sphere, animates them by // creating translation curves for each, then selects the cube and sphere and // sets their curve colors as magenta. // If you then select all three objects and open the Graph Editor, the curves // associated with the cube and sphere appear magenta and the curves // associated with the torus appear their default colours.
// Parameters: // int $how : (in) Specifies how the "useCurveColour" // attribute is set for each curve. // If 1, curves will display with the // newly assigned colour; if 0, curves // will display in default colour. // float $r : (in) Red component of colour to assign. // float $g : (in) Green component of colour to assign. // float $b : (in) Blue component of colour to assign. // // Returns: // int numCurves : Returns the number of curves a colour // was assigned to. // //************************************************************************ //- global proc int colourSelectedCurves( int $how, float $r, float $g, float $b ) { int $count; int $i; int $j; // Get the list of selected nodes. // string $selectionList[] = `ls -sl`; // Assign colours based on the selected set of nodes. // $count = 0; for ( $i = 0; $i < size( $selectionList ); $i++ ) { string $s = $selectionList[$i]; string $isCurve[] = `ls -type "animCurve" $s`; if ( size( $isCurve ) != 0 ) { // A curve is selected: assign it the specified colour. // setAttr ($s + ".useCurveColor") $how; setAttr ($s + ".curveColorR") $r; setAttr ($s + ".curveColorG") $g; setAttr ($s + ".curveColorB") $b; $count++; } else { // A non-curve node is selected: assign all curves which // are directly connected to it the specified colour. // string $connectedNodes[] = `listConnections $s`; for ( $j = 0; $j < size( $connectedNodes ); $j++ ) { string $c = $connectedNodes[$j]; string $isCurve[] = `ls -type "animCurve" $c`; if ( size( $isCurve ) != 0 ) { // We are connected to a curve; assign it the // specified curve colour. // setAttr ($c + ".useCurveColor") $how; setAttr ($c + ".curveColorR") $r; setAttr ($c + ".curveColorG") $g; setAttr ($c + ".curveColorB") $b; $count++; // Return the number of curves we set the colour on. // return( $count ); Here is an example of how to test the above procedure: // Create three animated objects // string $c[] = `polyCube`; move 10 2 3; setKeyframe ($c[0]+".t"); currentTime 16; move 10 -2 3; setKeyframe ($c[0]+".t"); string $t[] = `torus`; currentTime 1; move -10 -2 -3; setKeyframe ($t[0]+".t"); currentTime 16; move 10 -2 -3; setKeyframe ($t[0]+".t"); string $s[] = `sphere`; currentTime 1; move -10 -2 3; setKeyframe ($s[0]+".t"); currentTime 16; move 10 -2 -3; setKeyframe ($s[0]+".t"); // Set the colour of the cube and sphere to magenta, // select $c[0] $s[0]; colourSelectedCurves( 1, 1.0, 0.0, 1.0 );