gpt4 book ai didi

swift - 如何在不看到 "untitled-animations"的情况下导出 DAE 文件以在 Scene Kit 中使用?

转载 作者:IT王子 更新时间:2023-10-29 05:25:05 26 4
gpt4 key购买 nike

我试图将在 Cheetah 3D 和 Blender 3D 中创建的动画加载到 Scene Kit 中,但我得到的只是一堆“无标题动画”,每个都是相同的动画。

有谁知道如何从 Blender 或 Cheetah 3D 中正确导出这些以便 Scene Kit 可以使用它们?

最佳答案

我深入研究了这个,因为它也让我很烦。所有“无标题动画”都是每个骨骼的单独动画。您可以从 xcode 右侧面板中的属性检查器中获取 id。像这样使用 swift,你可以得到你的动画。

let urlOfScene = Bundle.main.url(forResources: "your url", withExtension: "dae")
let source = SCNSceneSource(url: urlOfScene, options: nil)
let armature = source.entryWithIdentifier("Armature", withClass: SCNNode.self) as SCNNode

let animation = armature.entryWithIdentifier("your bone id", withClass: CAAnimation.self) as CAAnimation

必须对骨架中的所有 骨骼执行此操作。 **烦人!!!*

Apple 的所有示例项目都使用 3dmax,每个 collada 文件只显示一个动画。这是因为 3dmax 在一个动画下导出所有骨骼,而 blender 将每个骨骼分开。

临时工作使用 TextEdit 或在 .dae 文件的末尾附加一个 .xml 扩展名,然后使用 xml 编辑器打开它(网上有很多免费的)。 xml 编辑器更容易使用。向下滚动到动画开始 block 。看起来会像这样……

<library_animations>
<animation id= "first_bone">
<source id= "first_bone-input">

将其更改为...

<library_animations>
<animation> ---this is the only modified line
<source id="first_bone-input">

在每个动画的结尾都会有一个结束 block ,就像这样......

</animtion>                      ---delete this line as long as its not your last bone    
<animation id="second_bone"> ---delete this line too
<source id="second_bone-input">

当然,在你最后一个骨骼的末尾,像这样离开动画结束 block ......

</animation>
</library_animations>

这将在您的 .dae 文件中为您提供一个动画,该动画与您的文件同名并在末尾附加 -1!

编辑 - 这是一个 Automator 服务的链接,它将为您转换上述代码!

Automater collada converter download

将文件解压并放到您的 ~/Library/services 文件夹中。从那里您可以右键单击您的 collada 文件并向下滚动到 ConvertToXcodeCollada 和 presto!完成后会弹出一个窗口(大约半秒)。

关于swift - 如何在不看到 "untitled-animations"的情况下导出 DAE 文件以在 Scene Kit 中使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24539607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com