如何以编程方式以 .dae 格式保存 arkit 对象 [英] How to programatically save arkit object in .dae format

查看:23
本文介绍了如何以编程方式以 .dae 格式保存 arkit 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序可创建用户面部的 3d 网格.我成功地生成了用户面部的数据.

I am working on an app the creates a 3d mesh of users face. I am successful in generating data of a users face.

我想以编程方式以 .dae 格式保存这些数据,以便我可以导出我的 .dae 文件,在 Blender 等 3d 软件中编辑它,然后将其进一步导入我的 iPhone 并在场景视图中显示该文件.

I want to programatically save this data in .dae format so that i could export my .dae file, edit that in 3d softwares like blender, and than further import it in my iphone and display that file in sceneview.

长话短说,我想以编程方式将数据保存为 .dae 格式.我在互联网上找不到任何关于此的信息.

Long story short i want programatically save the data in .dae format. I am not able to find anything on internet about this.

如果有其他方法,请告诉我.

If there could be another approach then please tell me.

推荐答案

SceneKit 在 iOS 中无法读取或写入 DAE 格式.(SceneKit 仅在 macOS 中读取/写入 DAE.当您在应用的捆绑资源中发布 DAE 时,Xcode 会在构建时将其转换为 iOS 优化格式.)

SceneKit doesn’t natively read or write DAE format in iOS. (SceneKit reads/writes DAE only in macOS. When you ship a DAE in your app’s bundle resources, Xcode converts it to an iOS-optimized format at build time.)

将网格从 iOS 导出为常见文件格式的最佳选择是 模型 I/O.该框架支持多种格式,但不支持 DAE.如果你只是想输出 ARKit 生成的 ARFaceGeometry 网格,你真的不需要比 OBJ 更复杂的格式,模型 I/O 可以做到这一点.

Your best bet for exporting a mesh to common file formats from iOS is Model I/O. That framework supports several formats, but not DAE. If you’re just looking to output the ARFaceGeometry mesh generated by ARKit, you don’t really need a format more complicated than OBJ, and Model I/O does that.

要点:

  1. 从你的顶点创建一个 MDLMesh/索引数据.这将需要 MDLMeshBuffers 用于顶点和纹理坐标数据,以及三角形索引数据的MDLSubmeshes.或者,如果您已经在 SceneKit 中拥有网格,请使用 MDLMesh(scnGeometry:).

创建一个空的 MDLAsset,然后添加您的网格作为子对象.

Create an empty MDLAsset, and add your mesh to it as a child object.

导出资产到文件.您为写入资产而提供的 URL 的文件扩展名决定了导出的文件格式,因此如果您想写入 OBJ 文件,请使用.obj"文件名.

Export the asset to a file. The filename extension of the URL you provide for writing the asset to determines the file format for export, so use a ".obj" filename if you want to write an OBJ file.

这篇关于如何以编程方式以 .dae 格式保存 arkit 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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