翻译glTF2.0 说明文档Animations这段

守給你的承諾、 提交于 2020-02-27 21:59:18

英文原文

Animations 动画

glTF通过节点变换的关键帧动画支持铰接和蒙皮动画。关键帧数据存储在缓冲区中,并使用访问器在动画中引用。glTF 2.0也以类似的方式支持实例化变形目标的动画。

注意:glTF 2.0只支持动画节点转换和变形目标权值。规范的未来版本可能支持动画任意属性,如材质颜色和纹理变换矩阵。
注意:glTF 2.0只定义了动画存储,所以这个规范没有定义任何特定的运行时行为,比如:播放顺序、自动启动、循环、时间轴映射等……
实现注意:glTF 2.0没有明确定义导入动画时将如何使用动画,但作为最佳实践,建议将每个动画作为动作自包含。例如,“行走”和“运行”动画可能分别包含针对模型不同骨骼的多个通道。客户端实现可以选择何时播放任何可用的动画。

所有的动画都存储在资产的animations数组中。动画被定义为一组通道(channels属性)和一组采样器,它们用关键帧数据和插值方法指定访问器(samplers属性)。

下面的示例展示了预期的动画使用。

{
    "animations": \[
        {
            "name": "Animate all properties of one node with different samplers",
            "channels": \[
                {
                    "sampler": 0,
                    "target": {
                        "node": 1,
                        "path": "rotation"
                    }
                },
                {
                    "sampler": 1,
                    "target": {
                        "node": 1,
                        "path": "scale"
                    }
                },
                {
                    "sampler": 2,
                    "target": {
                        "node": 1,
                        "path": "translation"
                    }
                }
            \],
            "samplers": \[
                {
                    "input": 4,
                    "interpolation": "LINEAR",
                    "output": 5
                },
                {
                    "input": 4,
                    "interpolation": "LINEAR",
                    "output": 6
                },
                {
                    "input": 4,
                    "interpolation": "LINEAR",
                    "output": 7
                }
            \]
        },
        {
            "name": "Animate two nodes with different samplers",
            "channels": \[
                {
                    "sampler": 0,
                    "target": {
                        "node": 0,
                        "path": "rotation"
                    }
                },
                {
                    "sampler": 1,
                    "target": {
                        "node": 1,
                        "path": "rotation"
                    }
                }
            \],
            "samplers": \[
                {
                    "input": 0,
                    "interpolation": "LINEAR",
                    "output": 1
                },
                {
                    "input": 2,
                    "interpolation": "LINEAR",
                    "output": 3
                }
            \]
        },
        {
            "name": "Animate two nodes with the same sampler",
            "channels": \[
                {
                    "sampler": 0,
                    "target": {
                        "node": 0,
                        "path": "rotation"
                    }
                },
                {
                    "sampler": 0,
                    "target": {
                        "node": 1,
                        "path": "rotation"
                    }
                }
            \],
            "samplers": \[
                {
                    "input": 0,
                    "interpolation": "LINEAR",
                    "output": 1
                }
            \]
        },
        {
            "name": "Animate a node rotation channel and the weights of a Morph Target it instantiates",
            "channels": \[
                {
                    "sampler": 0,
                    "target": {
                        "node": 1,
                        "path": "rotation"
                    }
                },
                {
                    "sampler": 1,
                    "target": {
                        "node": 1,
                        "path": "weights"
                    }
                }
            \],
            "samplers": \[
                {
                    "input": 4,
                    "interpolation": "LINEAR",
                    "output": 5
                },
                {
                    "input": 4,
                    "interpolation": "LINEAR",
                    "output": 6
                }
            \]
        }
    \]
}

通道将关键帧动画的输出值连接到场景树中的特定节点。通道的sampler属性包含包含动画的采样器数组中的一个采样器的索引。target属性是一个对象,它标识使用其node属性动画哪个节点,以及使用path动画该节点的哪个属性。非动画属性必须在动画期间保持其值。
当没有定义node时,应该忽略channel。有效的路径名是“平移”、“旋转”、“缩放”和“权重”。
每个动画采样器定义输入/输出对:一组浮点标量值,表示以秒为单位的线性时间;和一组表示动画属性的向量或标量。所有的值都存储在一个缓冲区中,并通过访问器进行访问;有关输出访问器类型,请参阅下表。键之间的插补是使用interpolation属性中指定的插补方法来执行的。支持的interpolation值包括LINEARSTEPCUBICSPLINE。有关样条插值的更多信息,请参见附录C

channel.path Accessor Type Component Type(s) Description
"translation" "VEC3" 5126 (FLOAT) XYZ translation vector
"rotation" "VEC4" 5126 (FLOAT)
5120 (BYTE) normalized 5121 (UNSIGNED_BYTE) normalized 5122 (SHORT) normalized 5123 (UNSIGNED_SHORT) normalized XYZW rotation quaternion
"scale" "VEC3" 5126 (FLOAT) XYZ scale vector
"weights" "SCALAR" 5126 (FLOAT) 5120 (BYTE) normalized 5121 (UNSIGNED_BYTE) normalized 5122 (SHORT) normalized 5123 (UNSIGNED_SHORT) normalized Weights of morph targets

实现必须使用以下方程来从一个标准化整数“c”获得相应的浮点值“f”,反之亦然

accessor.componentType int-to-float float-to-int
5120 (BYTE) f = max(c / 127.0, -1.0) c = round(f * 127.0)
5121 (UNSIGNED_BYTE) f = c / 255.0 c = round(f * 255.0)
5122 (SHORT) f = max(c / 32767.0, -1.0) c = round(f * 32767.0)
5123 (UNSIGNED_SHORT) f = c / 65535.0 c = round(f * 65535.0)

动画采样器的输入访问器必须定义最小最大属性。

实现注意: 动画与非线性时间输入,如时间扭曲在Autodesk 3ds Max或玛雅,不能直接代表与glTF动画。glTF是一种运行时格式,在运行时计算非线性时间输入非常昂贵。导出器实现应该将非线性时间动画采样为线性输入和输出,以获得准确的表示。

变形目标动画帧是由一系列长度为目标数目的标量定义的。这些标量序列必须作为输出访问器中的单个流端到端,其最终大小将等于变形目标的数量乘以动画帧的数量。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!