Sceneform 动画
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Sceneform,您可以导入包含动画的模型。您可以使用 Sceneform API 播放和控制动画,并将节点附加到模型框架上。
例如,Sceneform 动画示例包含用于构建 Andy Android 模型和棒球帽的文件。Andy 模型包含动画数据,而棒球帽是非动画模型。运行此示例时,Andy 跳舞并挥舞双臂,帽子仍站着,用一个节点固定在头上。
区分 Sceneform 中的模型动画与 Android 中的属性动画非常重要。
模型动画由艺术家使用建模和动画软件提前制作。它们包含框架动画数据。这些动画必须导出为 *.fbx
文件,然后导入到 *.sfb
文件中,以便在 Sceneform 中使用。
属性动画是一个基本的 Android 概念,并不局限于 Sceneform。这种动画可以更改具有 getter 和 setter 的 Java 对象中的任何可变值。动画值可以动态设置,但无法打包到 *.sfb
文件中。
属性动画和模型动画都支持 Android 的 Animator API。它们都支持监听器、播放控件(启动/停止/结束/暂停/取消)、时长和启动延迟。
模型动画仅提供对 TimeInterpolators
播放的有限支持。模型动画不支持反向播放。
如需了解 Sceneform 动画建模的实际运用,请查看动画示例。
如需了解 Sceneform 的实际属性动画效果,请查看太阳系示例。
模型动画概念
在开始使用动画模型之前,建议您先了解与框架动画相关的具体概念,以及适用于 Sceneform 的相关限制和功能。
骨头。动画模型包含连在一起的骨头,形成层次结构中的父子关系。动画在播放过程中改变了骨架的位置和方向。
就像在 Sceneform 中移动父 Node
会导致所有子 Node
也移动一样,在 Sceneform 中移动父骨子也会移动子项。骨架可以通过动画移动,也可以通过 SkeletonNode
类作为节点访问。当骨头以 Node
的形式进行访问时,如果正在播放骨头,系统会用动画覆盖每帧的新位置。
骨架。框架由所有这些架构组成,形成一个父子关系的层次结构。
例如,人体模型可能包含“左肩”、“左上臂”、“左肘”和“左前臂”等骨头。从“左肩”作为此层次结构的父级,系统会将“左上臂”分配为子级。“左上臂”的子项可能是“左手肘”和下肢骨头的子项。当肩骨旋转时,上臂、前臂、肘部和下面的任何骨骼都会随之移动。
Sceneform 没有用于更改框架中框架之间父子关系的 API。必须提前在外部建模和动画软件包中完成此操作。
即使是描述无机物体的模型也可以利用骨架来描绘现实世界。例如,沙发的模型可以有骨架,也有骨架。
皮肤。皮肤是应用于模型的绘制的表面网格的权重。皮肤网格的位置和形状根据附近的骨头计算得出。这种皮肤连接骨架对应着模型变形的情况,从而提供更逼真的移动效果。
皮肤必须提前使用建模和动画软件包进行准备。Sceneform 可以更改皮肤网格的材料以改变模型的外观。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2022-09-26。
[null,null,["最后更新时间 (UTC):2022-09-26。"],[[["\u003cp\u003eSceneform allows importing and controlling 3D models with pre-made animations, including attaching objects to model skeletons for dynamic interactions.\u003c/p\u003e\n"],["\u003cp\u003eSceneform supports both model animation (baked into the model file) and property animation (dynamically controlled in Android), each with its own features and limitations.\u003c/p\u003e\n"],["\u003cp\u003eModel animation in Sceneform relies on concepts like bones, skeletons, and skinning to define the structure and movement of animated objects.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize Sceneform APIs to control playback, attach nodes, and interact with animated models within AR experiences.\u003c/p\u003e\n"]]],["Sceneform allows importing and controlling animated models via its APIs, including attaching nodes to a model's skeleton. Model animations, created externally and imported as `*.sfb` files, differ from Android property animations, which modify Java object values dynamically. Sceneform model animations use skeletal animation, where bones, connected in a hierarchical skeleton, drive the movement of the model's skin. Bones can be manipulated via the `SkeletonNode` class. The skin mesh appearance can be customized in sceneform.\n"],null,["# Sceneform animation\n\nSceneform lets you import models with animation. You can use Sceneform APIs to\nplay back and control the animation, and attach nodes to a model's skeleton.\n\nFor instance, the Sceneform [**Animation**](//github.com/google-ar/sceneform-android-sdk/tree/v1.15.0/samples/animation)\nsample includes files used to build models of Andy the android and a baseball\nhat. The Andy model contains animation data, while the baseball hat is a\nnon-animated model. When you run the sample, Andy breakdances and waves his arms\nwhile the hat remains fixed to his head using a node.\n\nSceneform model animation vs Android property animation\n-------------------------------------------------------\n\nIt's important to differentiate between *model animation* in Sceneform versus\n*property animation* in Android.\n\n- Model animations are created ahead of time by artists using modeling and\n animation software. They contain [skeletal animation data](#model-concepts).\n These animations must be exported as\n `*.fbx` files, then imported into a `*.sfb` file to be used in Sceneform.\n\n- [Property animation](//developer.android.com/guide/topics/graphics/prop-animation)\n is a fundamental Android concept and is not specific to Sceneform. This kind\n of animation can change any mutable value on a Java object that has a getter\n and a setter. The animated values can be set dynamically, but cannot be\n packaged into an `*.sfb` file.\n\n Both property and model animation support\n [Android's Animator API](//developer.android.com/reference/android/animation/Animator)\n . They both support\n [listeners](//developer.android.com/guide/topics/graphics/prop-animation#listeners),\n playback control (start/stop/end/pause/cancel), duration, and start delay.\n\n Only limited support for\n [`TimeInterpolators`](//developer.android.com/reference/android/animation/TimeInterpolator)\n playback is provided in the model animations. Reverse playback is not\n supported in model animations.\n- To see Sceneform animation modeling in action, review the\n [**Animation**](//github.com/google-ar/sceneform-android-sdk/tree/v1.15.0/samples/animation)\n sample.\n\n- To see property animation using Sceneform in action, review the\n [**Solar System**](//github.com/google-ar/sceneform-android-sdk/tree/v1.15.0/samples/solarsystem)\n sample.\n\nModel animation concepts\n------------------------\n\nBefore you start working with animated models, it's a good idea to understand specific\nconcepts relating to [*skeletal animation*](//en.wikipedia.org/wiki/Skeletal_animation),\nas well as related restrictions and features that apply to Sceneform.\n\n- **Bones.** An animated model contains *bones* that are connected together,\n forming parent-child relationships in a hierarchy. Animation alters the\n position and orientation of bones during playback.\n\n In the same way that moving a parent `Node` in Sceneform causes all child\n `Node`s to also move, moving a parent bone in Sceneform moves the children.\n Bones are movable by animation or accessed as a node via the [`SkeletonNode`](/sceneform/reference/com/google/ar/sceneform/SkeletonNode)\n class. When bones are accessed as a `Node`, the new positions are\n overwritten every frame by animation if one is playing.\n- **Skeleton.** The *skeleton* comprises all of the bones together, forming a\n hierarchy of parent-child relationships.\n\n For example, a model of a human arm might contain bones such as\n \"left shoulder\", \"left upper arm\", \"left elbow\", and \"left forearm\" and so\n on. Starting from the \"left shoulder\" as the parent of this hierarchy,\n \"left upper arm\" would be assigned as a child. The children of \"left upper\n arm\" might be the \"left elbow\" and lower bones. When the shoulder bone is\n rotated, the upper arm, forearm, elbow and any bones below would move in\n tandem.\n\n Sceneform doesn't have an API for changing the parent-child relationships\n between bones in the skeleton. This must be done ahead of time in an\n external modeling and animation package.\n\n Even models depicting inorganic objects can utilize skeletons to facilitate\n realism. For example, a model of a couch could have bones and a skeleton.\n- **Skin.** The *skin* is a weight applied to the drawn surface mesh of the\n model. The position and shape of the skin mesh is calculated from the nearby\n bones. This bone to skin connection maps to how the model deforms, providing\n for more realistic movement.\n\n The skin must be prepared ahead of time using a modeling and animation\n package. Sceneform can alter the material of the skin mesh to change a\n model's appearance."]]