Windows
动画 SDL 文件是一种常规的场景描述语言文件,此类文件包含一个附加部分,用于描述模型的层次。动画 SDL 文件有两个部分:DEFINITION 和 HIERARCHY。
HIERARCHY 部分可以省略。在这种情况下,动画 SDL 文件仅包含动画曲线(或动作)库。
在 DEFINITION 部分中,您可以像在常规 SDL 文件中那样指定曲线(或动作)描述。对于动画 SDL 和常规 SDL,动作的语法相同。
在 HIERARCHY 部分中,描述如何将 DEFINITION 部分中的动画曲线应用于模型的层次。
HIERARCHY { <----- Picked object Apply animation to picked object. { <----- A child of the picked object. Apply animation to child of picked object. { <----- A child of a child of the picked object. Apply animation to child of a child of picked object. } } { <----- Another child of the picked object. Apply animation to other child picked object. } }
如果某对象没有动画,但其子对象具有动画,仍然必须指定大括号作为该对象的占位符,但要省略对其应用动画的语句。这对同级项而言也是必要的。如果最左边的同级项未设置动画,但其右侧相邻的同级项设置了动画,请指定一个空的大括号对作为最左侧子对象的占位符。
HIERARCHY 部分中有两条语句,用于将动画应用于对象。第一条语句是类型语句,用于指定要接收动画的对象的类型。
类型语句的一般格式如下:
type “animatable item type name” ( <additional information> );
“animatable item type name”的示例有 Dag Node、Camera、Light、Shader、Surface CV 和 Curve CV。
如果曲线是某个面的一部分,则应指定两个值(使用逗号分隔)。第一个值指定面的曲线,第二个值指定曲线上的 CV。例如,如果某个面由三条曲线构成,若要引用该面的第 2 条曲线上的第 4 个 CV,则类型语句应为:
type “Curve CV” (2, 4);
类型语句后面的语句表示如何将动画应用于项的各个动画参数。这些语句称为通道语句,用于指定动画参数如何使用 DEFINITION 部分中定义的动作。
通道语句的一般格式如下:
channel “channel name” (action_name [extract axis] (action_name...));
每个可设置动画的项类型均有自己的一组动画参数名称,可以在参数控制窗口中看到这些参数名称(详细信息请参见“Animation”>“Editors”>“Param Control”)。例如,Dag 节点具有“X Translate”、“Y Translate”、“Z Scale”和“Visibility”参数。这些名称显示在参数控制窗口中,可用作通道名称。
请不要将通道指定给不使用该参数设置动画的项。同样,也不要指定不属于当前动画项类型的通道。例如,动画 SDL 不区分灯光类型,因此尽管您可以尝试将聚光灯扩散通道读取到点光源上,但这将导致错误。
在通道语句的圆括号中,您可以指定组成通道的动作列表。如果动作是运动路径,则必须指定要使用三维 NURBS 曲线的哪一个坐标轴。位于附加圆括号内的附加动作可用作原始曲线上的时间扭曲。
以下是已设置动画的圆柱体的动画 SDL 文件示例。
DEFINITION /* the 3-D NURBS curve used by the motion path action */ curve curve#2 ( degree = 3, knots = (0.0, 0.0, 0.0, 1.0, 1.0 , 1.0 ), cvs = ( cv( (0.0, 0.0, 0.0),1.0), cv( (3.0, 3.0, 3.0),1.0), cv( (-4.0, 2.0, -6.0),1.0), cv( (-3.0, 2.0, 3.0),1.0) ) ); /* a motion path action */ motion_curve motion_path ( curve#2, in = PRE_CONSTANT, out = POST_CONSTANT ); /* several parameter curve actions */ parameter_curve param_curve.Timing ( in = PRE_LINEAR, out = POST_LINEAR, cvs = ( parameter_vertex(1.0,0.0 , TAN_SMOOTH, ( -0.27852, -0.96043 ), TAN_SMOOTH, (0.27852,0.96043) ), parameter_vertex(30.0,30.0, TAN_SMOOTH, (-0.27852,-0.96043 ), TAN_SMOOTH, (0.27852,0.96043) ) ) ); parameter_curve param_curve.X_Scale ( in = PRE_CONSTANT, out = POST_CONSTANT, cvs = ( parameter_vertex(1.0 , 1.0 , TAN_SMOOTH, (1.0 ,0.0), TAN_SMOOTH, (1.0 , 0.0) ), parameter_vertex( 30.0 , 4.0 , TAN_SMOOTH, (1.0 ,0.0), TAN_SMOOTH, (1.0 , 0.0) ) ) ); parameter_curve param_curve.Z_Rotate ( in = PRE_CONSTANT, out = POST_CONSTANT, cvs = ( parameter_vertex(1.0 , 0.0, TAN_SMOOTH, (-1.0 , 0.0), TAN_SMOOTH, (1.0 , 0.0) ), parameter_vertex(30.0 ,360.0 , TAN_SMOOTH, (-1.0 , 0.0 ), TAN_SMOOTH, (1.0, 0.0) ) ) ); parameter_curve timewarp ( in = PRE_IDENTITY, out = POST_IDENTITY, cvs = ( parameter_vertex(1.0 , 1.0, TAN_SMOOTH, (-0.70711,-0.70711 ), TAN_SMOOTH, (0.70711,0.70711) ), parameter_vertex(30.0 ,30.0 ,TAN_SMOOTH, (-0.70711,-0.70711 ),TAN_SMOOTH, (0.70711,0.70711) ) ) ); parameter_curve param_curve.X_Position ( in = PRE_CONSTANT, out = POST_CONSTANT, cvs = ( parameter_vertex(1.0 , -0.2612 , TAN_SMOOTH, (-1.0 ,0.0), TAN_SMOOTH, (-1.0 ,0.0) ), parameter_vertex( 30.0 , -0.18593, TAN_SMOOTH, (-1.0 ,0.0), TAN_SMOOTH, (-1.0 ,0.0) ) ) ); parameter_curve param_curve.Y_Position ( in = PRE_CONSTANT, out = POST_CONSTANT, cvs = ( parameter_vertex(1.0 ,0.2612 , TAN_SMOOTH, (-1.0 ,0.0 ), TAN_SMOOTH, (-1.0 ,0.0) ), parameter_vertex( 30.0 , 0.58722, TAN_SMOOTH, ( -1.0 , 0.0 ), TAN_SMOOTH, (-1.0 ,0.0)) ) ); parameter_curve param_curve.Z_Position ( in = PRE_CONSTANT, out = POST_CONSTANT, cvs = ( parameter_vertex( 1.0 , 0.5 , TAN_SMOOTH, ( -1.0 , 0.0 ), TAN_SMOOTH, ( 1.0 , 0.0 ) ), parameter_vertex( 30.0, 0.90137, TAN_SMOOTH, ( -1.0 , 0.0 ), TAN_SMOOTH, (-1.0 ,0.0)) ) ); HIERARCHY { type "Dag Node" ( cylinder ); /* The cylinder is moved along a motion path. */ /* Each channel is extracted from a motion path */ /* with one timing curve modifying all three. */ channel "X Translate" ( motion_path [X] ( param_curve.Timing )); channel "Y Translate" ( motion_path [Y] ( param_curve.Timing )); channel "Z Translate" ( motion_path [Z] ( param_curve.Timing )); /* The width of the cylinder is also animated. */ channel "X Scale" ( param_curve.X_Scale ); { /* This is the first child of the top level */ /* of the cylinder. It spins around the Z */ /* axis. A timewarp has been applied. */ type "Dag Node" ( cyl_body ); channel "Z Rotate" ( param_curve.Z_Rotate ( timewarp )); } { /* Cap A of the cylinder is not animated, */ /* nor are any of its CVs, but these braces */ /* are necessary to maintain to maintain the*/ /* hierarchy structure. */ /* If these braces were omitted Cap B's */ /* animation would be read onto Cap A. */ } { /* Cap B is not animated but one of its cvs */ /* is. */ { type "Surface CV" ( 2, 4 ); /* Surface CV u = 2, v = 4 is animated. */ channel "X Position" ( param_curve.X_Position ); channel "Y Position" ( param_curve.Y_Position ); channel "Z Position" ( param_curve.Z_Position ); } }