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

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

问题描述

我正在开发一个可创建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中并在Sceneview中显示该文件.

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更复杂的格式,而Model 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 .这将需要 MDLMeshBuffer s用于顶点和纹理坐标数据,以及 MDLSubmesh es.或者,如果SceneKit中已经有网格,请使用 MDLMesh(scnGeometry:) .

  1. Create an MDLMesh from your vertex/index data. That’ll require MDLMeshBuffers for the vertex and texture coordinate data, and MDLSubmeshes for the triangle index data. Or, if you already have the mesh in SceneKit, convert it with 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.

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

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