如何导出DAE文件以在Scene Kit中使用而看不到“无标题动画"? [英] How can I export DAE files for use in Scene Kit without seeing "untitled-animations"?

查看:142
本文介绍了如何导出DAE文件以在Scene Kit中使用而看不到“无标题动画"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to load animations created in Cheetah 3D and Blender 3D into Scene Kit, but all I get is a bunch of "untitled-animations" with each one being the same animation.

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

Does anyone know how to properly export these from Blender or Cheetah 3D so that Scene Kit can use them?

推荐答案

我挖了这个,因为它也很烦我.所有无标题动画"都是每个骨骼的单独动画.您可以从xcode右侧面板中的属性检查器获取ID.像这样快速使用动画,就可以制作动画.

I dug into this because it was annoying me too. All of the "untitled animations" are individual animations for each bone. You can get the id from the attributes inspecter in the panel on the right side of xcode. Using swift like so, you can get your animation.

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

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

This must be done for All the bones in your armature. **Annoying!!!*

Apple在所有示例项目中均使用3dmax,每个collada文件仅显示一个动画.这是因为3dmax会在一个动画下导出所有骨骼,而Blender会分离每个骨骼.

Apple used 3dmax for all their sample projects which only show one animation for each collada file. This is because 3dmax exports all the bones under one animation while blender seperates each bone.

临时解决问题 使用TextEdit或在.dae文件的末尾附加.xml扩展名,然后使用xml编辑器将其打开(很多在线免费). xml编辑器更易于使用.向下滚动到动画开始块.看起来像这样...

Temp Work Around Use TextEdit or append a .xml extension on the end of your .dae file and open it with an xml editor (plenty are free online). xml editors are a little easier to work with. Scroll down to the animation start block. It will look like so...

<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"> 

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

At the end of each animation will be an end block like so...

</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">  

当然,在最后一根骨头的末端像这样离开动画结束块...

Of course at the end of your last bone leave the animation end block like so...

</animation>
</library_animations>

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

This will give you a single animation within your .dae file which has the same name as your file with a -1 appended to the end!

编辑-这是指向Automator服务的链接,该服务将为您转换上面的代码!

自动collada转换器下载

解压缩文件并将其拖放到〜/Library/services文件夹中.从那里,您可以右键单击collada文件,然后向下滚动到ConvertToXcodeCollada并保存!完成后会弹出一个窗口(大约半秒钟).

Unzip and drop the file in your ~/Library/services folder. From there you can just right click on your collada file and scroll down to ConvertToXcodeCollada and presto! A window will pop up when complete (about half a second).

这篇关于如何导出DAE文件以在Scene Kit中使用而看不到“无标题动画"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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