从Collada(.dae)文件(在Maya中创建)导入的SceneKit键控混合形状动画无法播放 [英] SceneKit keyed blend shape animation imported from Collada (.dae) file (created in Maya) not playing

查看:118
本文介绍了从Collada(.dae)文件(在Maya中创建)导入的SceneKit键控混合形状动画无法播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Maya 来创建要在 SceneKit 中使用的动画。我正在使用Maya内置的 FBX DAE 导出器导出为 COLLADA 文件( .dae )。

I'm using Maya to create animations to use in SceneKit. I'm exporting as COLLADA file (.dae) using Maya's built-in FBX DAE exporter.

节点上的动画可以完美运行。例如,如果我们有一个平移,旋转或缩放的动画(或这些动画的组合),则该动画会随节点正确导入。

Animations on the node transform all work perfectly. For example, if we have an animation of the translation, rotation, or scale -- or a combination of those -- the animation imports correctly with the node.

但是,当我基于键混合形状输入导入动画时,动画无法播放。

However, when I import an animation based on keyed blend shape inputs, the animation doesn't play.

在Xcode中,如果我单击.dae文件并开始查看属性,该节点在那里并且具有混合形状(几何变形器),并且可以操作。

Within Xcode, if I click on the .dae file and start looking at attributes, the node is there and has the blend shape (geometry morpher) attached, and it is manipulable.

另外,还会列出一个动画,如果我查看其中的属性

Additionally, an animation is listed, and if I look at attributes within the node, the animation is listed there as well.

如果我通过SCNNode的 animationKeys 属性进行迭代,则有一个动画,并且具有与之相关的正确时间。

If I iterate through the SCNNode's animationKeys property, an animation is there and it has the correct amount of time associated with it. But I can't seem to get it to work.

在Xcode方面,我尝试过:

On the Xcode side of things, I have tried:


  • 在提示更新Xcode中的.dae文件时说更新。

  • Saying "Update" when prompted to update the .dae file within Xcode.

不更新。提示时显示dae文件

Not updating the .dae file when prompted

应用Jon Allee的 Collada将其变形为.dae文件,然后将其提供给Xcode。

Applying Jon Allee's Collada Morph Adjuster to the .dae file, before giving it to Xcode.

加载为SCNSceneSource而不是SCNScene

Loading as SCNSceneSource instead of SCNScene

在Maya方面,我尝试了一些创建/导出过程的变体:

On the Maya side of things, I've tried several variations on the creation/export process:


  • 尝试了 删除单个键复选框(有无)

尝试在导出窗口中设置 烘焙动画

Tried the "bake animation" setting in the export window

尝试选中并取消选中 变形的模型混合形状

Tried checking and unchecking "Deformed models" and "Blend Shapes"

在t以下他在导出窗口中选择了 Collada 选项,但我尝试了是否选中 单一矩阵。我通常现在立即检查 单个矩阵,否则我会在Xcode中看到很多动画。但是,选中或不选中此选项不会 not 对SceneKit的行为产生任何影响。变换动画无论哪种方式都起作用,而混合形状动画则不一样。

Under the "Collada" option in the export window, I've tried with and without "Single Matrix" checked. I usually check "Single Matrix" now or I get a bunch of animations within Xcode. However, checking or not checking this option does not appear to have any effect on SceneKit's behavior. The transform animations work either way, and the blend shape animations don't work either way.

我也仔细查看了数十个Stack Overflow问题-这不是重复的问题,也不是苹果论坛中的问题,而且是个主意。

I've also looked at dozens of Stack Overflow questions carefully -- this is not a duplicate question, as well as ones in Apple's forums and am out of ideas.

我整理了一个快速示例项目,该示例项目演示了工作和非工作状态,并包括源Maya文件以及一些解释器视频。

I put together a quick sample project that demonstrates both the working and non-working, and includes the source Maya files as well as a couple of explainer videos.

我正在使用:

Maya 2018.2(Cut ID:201711281015-8e846c9074)

Xcode 9.3(9E145)

macOS High Sierra 10.13.4

iOS 11.3.1

代码段:

let scene = SCNScene()

let fileName = "anim.scnassets/cube-blend.dae"
let modelName = "pCube2"

guard let nodeScene = SCNScene(named: fileName) else {
    fatalError("COULD NOT OPEN SCENE FILE \(fileName)")
}   
guard let node = nodeScene.rootNode.childNode(withName: modelName, recursively: true) else {
    fatalError("COULD NOT FIND NODE \(modelName) in file \(fileName)")
}   
scene.rootNode.addChildNode(node)

加载并运行其他动画。

更新1:
这是我向Apple提交的一个bug,测试并回来后说

UPDATE 1: I filed this as a bug with Apple who tested and came back and said the Maya is generating a bogus .dae file.

具体来说,他们写道:


cube-blend.dae包含一个混合形状动画,但目标语法
不正确:pCube2-lib-morph-weights(Weight_0_0)。这是一个
出口商的问题(我们尝试在Modo中导入此文件[无法打开]
和Cinema4D [正确加载但没有动画])。

cube-blend.dae contains a blend shape animation but the target syntax is incorrect: pCube2-lib-morph-weights(Weight_0_0). This is an exporter issue (we tried to import this file in Modo [can’t open it] and Cinema4D [loads correctly but with no animation]).

这是Maya出口商中的错误。

This is a bug in Maya’s exporter.

基于我自己测试,我倾向于同意他们的观点,尽管很难理解动画中使用的最顶级软件之一是如何彻底破坏出口商的。

Based on my own tests, I'm inclined to agree with them, though it's hard to understand how one of the very top pieces of software used in animation has a completely broken exporter.

I试图在此处粘贴实际的COLLADA .dae文件,但文件太大。这是一个保管箱链接:
cube-blend.dae

I tried to paste the actual COLLADA .dae file here but it's too big. Here's a dropbox link: cube-blend.dae

以下是:

<library_animations>
    <animation id="pCube2-anim" name="pCube2"><animation><source id="pCube2-Matrix-animation-input"><float_array id="pCube2-Matrix-animation-input-array" count="25">

0.041667 0.083333 0.125000 0.166667 0.208333 0.250000 0.291667 0.333333 0.375000 0.416667 0.458333 0.500000 0.541667 0.583333 0.625000 0.666667
0.708333 0.750000 0.791667 0.833333 0.875000 0.916667 0.958333 1.000000 1.041667</float_array><technique_common><accessor source="#pCube2-Matrix-animation-input-array" count="25"><param name="TIME" type="float"/></accessor></technique_common></source><source id="pCube2-Matrix-animation-output-transform"><float_array id="pCube2-Matrix-animation-output-transform-array" count="400">

0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000
0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000 1.000000</float_array><technique_common><accessor source="#pCube2-Matrix-animation-output-transform-array" count="25" stride="16"><param type="float4x4"/></accessor></technique_common></source><source id="pCube2-Interpolations"><Name_array id="pCube2-Interpolations-array" count="25">
 LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR
LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR
LINEAR LINEAR</Name_array><technique_common><accessor source="#pCube2-Interpolations-array" count="25"><param type="name"/></accessor></technique_common></source><sampler id="pCube2-Matrix-animation-transform"><input semantic="INPUT" source="#pCube2-Matrix-animation-input"/><input semantic="OUTPUT" source="#pCube2-Matrix-animation-output-transform"/><input semantic="INTERPOLATION" source="#pCube2-Interpolations"/></sampler><channel source="#pCube2-Matrix-animation-transform" target="pCube2/matrix"/></animation><animation><source id="pCube2-lib-morph-weights-animation-inputWeight_0_0"><float_array id="pCube2-lib-morph-weights-animation-inputWeight_0_0-array" count="5">

0.041667 1.041667 1.541667 1.583333 3.875000</float_array><technique_common><accessor source="#pCube2-lib-morph-weights-animation-inputWeight_0_0-array" count="5"><param name="TIME" type="float"/></accessor></technique_common></source><source id="pCube2-lib-morph-weights-animation-outputWeight_0_0"><float_array id="pCube2-lib-morph-weights-animation-outputWeight_0_0-array" count="5">

0.000000 0.788732 1.000000 1.000000 0.000000</float_array><technique_common><accessor source="#pCube2-lib-morph-weights-animation-outputWeight_0_0-array" count="5"><param name="Weight_0_0" type="float"/></accessor></technique_common></source><source id="pCube2-lib-morph-weights-animation-intanWeight_0_0"><float_array id="pCube2-lib-morph-weights-animation-intanWeight_0_0-array" count="5">

0.000000 0.222222 0.000000 0.000000 0.000000</float_array><technique_common><accessor source="#pCube2-lib-morph-weights-animation-intanWeight_0_0-array" count="5"><param name="Weight_0_0" type="float"/></accessor></technique_common></source><source id="pCube2-lib-morph-weights-animation-outtanWeight_0_0"><float_array id="pCube2-lib-morph-weights-animation-outtanWeight_0_0-array" count="5">

0.000000 0.111111 0.000000 0.000000 0.000000</float_array><technique_common><accessor source="#pCube2-lib-morph-weights-animation-outtanWeight_0_0-array" count="5"><param name="Weight_0_0" type="float"/></accessor></technique_common></source><source id="pCube2-lib-morph-weights-animation-interpolationWeight_0_0"><Name_array id="pCube2-lib-morph-weights-animation-interpolationWeight_0_0-array" count="5">
 BEZIER BEZIER BEZIER BEZIER BEZIER</Name_array><technique_common><accessor source="#pCube2-lib-morph-weights-animation-interpolationWeight_0_0-array" count="5"><param type="name"/></accessor></technique_common></source><sampler id="pCube2-lib-morph-weights-animationWeight_0_0"><input semantic="INPUT" source="#pCube2-lib-morph-weights-animation-inputWeight_0_0"/><input semantic="OUTPUT" source="#pCube2-lib-morph-weights-animation-outputWeight_0_0"/><input semantic="IN_TANGENT" source="#pCube2-lib-morph-weights-animation-intanWeight_0_0"/><input semantic="OUT_TANGENT" source="#pCube2-lib-morph-weights-animation-outtanWeight_0_0"/><input semantic="INTERPOLATION" source="#pCube2-lib-morph-weights-animation-interpolationWeight_0_0"/></sampler><channel source="#pCube2-lib-morph-weights-animationWeight_0_0" target="pCube2-lib-morph-weights(Weight_0_0)"/></animation></animation>
  </library_animations>

更新2:

苹果工程师也表示 用 pCube2-lib-morph-weights(0)替换目标 pCube2-lib-morph-weights(Weight_0_0) 。但是,在我的测试中,我无法证实这一点。

UPDATE 2:
Apple engineer also stated "Replacing the target "pCube2-lib-morph-weights(Weight_0_0)" by "pCube2-lib-morph-weights(0)" works". In my testing, however, I could not confirm this.

关于如何在动画块中引用混合形状权重的任何想法?

Any idea on how the blend shape weights are supposed to be referenced within the animation block?

谢谢!

推荐答案

您可以使用 Script烘焙动画在Maya中编辑器,然后将其导出为 .dae 格式。有时编辑导出预设 窗口中的烘焙选项不起作用。

You could bake an animation using Script Editor in Maya before exporting it as .dae format. Sometimes the baking option in Edit Export Preset window doesn't work.

因此,选择具有动画blendshape的3d模型并执行以下python命令:

So, select your 3d model with animated blendshape and execute this python command:

import maya.cmds as cmds

cmds.bakeSimulation('pFace1', t=(1,96), sb=1, at=["rx","ry","rz"], hi="below") # obsolete command

# 'pFace1' = a name of your geo in DAG ;
# t = timerange in frames ;
# sb = sampleBy (amount to sample) ;
# at = list of attributes to select ;
# hi = hierarchy. Valid values are "above", "below", "both", "none" ;

cmds.bakeResults('pFace1', t=(1,96), simulation=True) 
# brand new command

或直接使用主菜单:编辑烘焙模拟

Or simply use a main menu: EditKeysBake Simulation.

另一种有效的做法是使用 OBJ序列导出器 .obj 个文件)。

Another robust practise is to use OBJ sequence exporter (a padded sequence of .obj files).

这篇关于从Collada(.dae)文件(在Maya中创建)导入的SceneKit键控混合形状动画无法播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆