Convert ( .obj / .fbx ) to .dae runtime which must support iOS SceneKit

风流意气都作罢 提交于 2019-12-11 17:31:27

问题


I am facing trouble to find a way to convert .obj / .fbx to .dae (iOS scenefit Supported) automatically in background.

In python, it may be available to convert the file from .obj / .fbx to .dae file format. This process should run in background, immediately run after we will get .obj / .fbx file on server.

Here is the sample file, which we are trying to convert.

https://s3.ap-south-1.amazonaws.com/p9-platform/DAE/barware_s11624.obj

Please help me, if you have any suggestion.


回答1:


Scenekit on IOS doesn’t support dae unless it was included in the app. So because of the “iOS Scenekit Supported” requirement there is no right answer, sort of. Although there are third party libraries (like https://github.com/dmsurti/AssimpKit ) to read and convert many 3d model formats, it won’t change the fact dae isn’t properly supported on IOS Scenekit .

That said, it is possible to convert OBJ to DAE in SceneKit using the following steps (in IOS 11.2 and later)

  1. Load the obj file into a SCNScene.

  2. Write the scene to a file with .dae extension using SCNScene’s writeToURL method.

That will create a .dae file SceneKit can support (but not directly, i.e. would need to be included in xcode or converted first) that starts with the following:

<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
 <asset>
  <contributor>
   <authoring_tool>SceneKit Collada Exporter v1.0</authoring_tool>
  </contributor>



回答2:


I would second the recommendation for using Assimp or AssimpKit (I’ve only used the former but the latter might be an easier starting point).

I believe the DAEs on iOS aren’t DAEs at all, they just left the suffix the same and the actual files are SceneKit archives. I’m not sure if the API to write them is exposed yet, but I think it might be now since Xcode is now willing to load DAEs and write out SceneKit archives (but it adds the “.scn” suffix, not “.dae”).

It’s possible that iOS SceneKit can just load “.scn” files — it won’t load true DAEs because the DEA-reading/writing framework was licensed from Sony and is HUGE and the iOS team just doesn’t want that giant ugly framework on its system.

Another option would be to just link the iOS app against Assimp — it can load a ton of formats natively so you could skip all the intermediate stuff. It’s not NEARLY as huge as Sony’s DAE library so it might be acceptable to ship it with your app.



来源:https://stackoverflow.com/questions/48441162/convert-obj-fbx-to-dae-runtime-which-must-support-ios-scenekit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!