更改动画曲线颜色

您可以在“首选项”(Preferences)菜单的颜色设置(Color Settings)窗口中设置默认曲线颜色。此外,您还可以为“曲线图编辑器”(Graph Editor)中显示的动画曲线指定自定义颜色。 有关不同颜色所代表内容的解释,请参见曲线图编辑器颜色

“曲线图编辑器”(Graph Editor)更改单个动画曲线颜色

更改单个动画曲线的颜色

  1. “曲线图编辑器”(Graph Editor)中,选择要更改颜色的曲线。
  2. 选择“编辑 > 更改曲线颜色”(Edit > Change Curve Color) >

    此时将出现“更改曲线颜色选项”(Change Curve Color Options)窗口。(请参见编辑菜单(Edit menu)中的“更改曲线颜色”(Change Curve Color) > 。)

  3. 为选定的动画曲线设定新颜色,并执行下列操作之一:
    • 单击“颜色”(Color)以应用当前颜色,并关闭“更改曲线颜色选项”(Change Curve Color Options)窗口。
    • 单击“应用”(Apply)以将当前颜色应用到曲线,并使“更改曲线颜色选项”(Change Curve Color Options)窗口保持打开状态,以便进行进一步编辑。

    选定曲线的颜色将更改为您在“更改曲线颜色选项”(Change Curve Color Options)窗口中指定的颜色。

将曲线颜色与属性名称相关联

将属性名称与曲线颜色相关联

  1. 为要指定曲线颜色的属性指定一个具有动画曲线的对象。
  2. “曲线图编辑器”(Graph Editor)“窗口 > 动画编辑器 > 曲线图编辑器”(Window > Animation Editor > Graph Editor))中,选择要关联颜色的属性。
  3. “曲线图编辑器”(Graph Editor)菜单栏中,选择“编辑 > 设置曲线颜色”(Edit > Set Curve Colors)

    将出现“曲线颜色”(Curve Colors)窗口,且左侧面板中将列出您选择的属性。

    提示:

    还可以随时在“曲线图编辑器”(Graph Editor)的大纲视图中选择属性,并单击“曲线颜色”(Curve Colors)窗口中的“添加”(Add)以加载它们。

  4. 对于要指定其自身颜色的每个属性,请执行以下操作:
    • “曲线颜色”(Curve Colors)窗口中选择该属性。
    • 单击颜色样例以打开“颜色历史”(Color History)设定。
    • “曲线颜色”(Curve Colors)窗口选择所需的颜色。

    现在,控制该属性的动画曲线已设定为指定的颜色。

重置曲线颜色

  1. “曲线图编辑器”(Graph Editor)的大纲视图中选择该属性,然后选择“编辑 > 设置曲线颜色”(Edit > Set Curve Colors)
  2. 在出现的“曲线颜色”(Curve Colors)窗口中选择该属性名称。
  3. 单击“移除”(Remove)

    动画曲线将重置为其默认颜色。

通过“属性编辑器”(Attribute Editor)或使用 MEL 来更改动画曲线颜色

使用“使用曲线颜色”和“曲线颜色”属性,可以设定各个曲线的颜色或使用多个全局操作(例如,根据那些可驱动曲线的颜色组的角色一次性对曲线着色)。这类全局操作可通过 MEL 脚本完成。有关 MEL 示例脚本,请参见自定义多个动画曲线颜色的 MEL 示例程序

“曲线图编辑器”(Graph Editor)的大纲视图和曲线视图中将出现动画曲线的所有用户定义的颜色设置。“使用曲线颜色”(Use Curve Color)复选框和“曲线颜色”(Curve Color)样例位于每个动画曲线节点(例如 animCurveN)的“动画曲线属性”(Anim Curve Attributes)区域。

注:

可一次性显示的自定义颜色曲线最大数为 20。如果超过该数,将使用其默认颜色显示曲线。

在自定义颜色和默认曲线颜色之间切换

  1. 启用或禁用“使用曲线颜色”(Use Curve Color)属性。

    “使用曲线颜色”(Use Curve Color)位于每个动画曲线节点(例如,animCurveN)的“动画曲线属性”(Anim Curve Attributes)区域。请查看下列程序。

设定自定义动画曲线颜色

  1. 选择已设置动画的对象。
  2. 打开“曲线图编辑器”(Graph Editor)
  3. 在图表视图中,选择动画曲线。
  4. 选择“曲线 > 属性总表”(Curves > Spreadsheet)

    打开“属性编辑器”(Attribute Editor)

  5. 在 animCurveN 选项卡的“动画曲线属性”(Anim Curve Attributes)区域中,启用“使用曲线颜色”(Use Curve Color)
  6. 单击颜色样例以启动“颜色历史”(Color History)设置。
  7. “颜色历史”(Color History)设置中,选择曲线的自定义颜色。

选定的颜色将出现在“曲线颜色”(Curve Color)样例”中。现在,在“曲线图编辑器”(Graph Editor)“曲线视图”(Curve View)中,动画曲线将采用“曲线颜色”(Curve Color)样例的颜色。

自定义多个动画曲线颜色的 MEL 示例程序

//+
//************************************************************************
//
// 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 );