ARKit - 获得“意外发现为零";使用 SCN 文件时300 MB [英] ARKit – Getting "Unexpectedly found nil" when using SCN file > 300 MB

查看:18
本文介绍了ARKit - 获得“意外发现为零";使用 SCN 文件时300 MB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在加载一个 300mb 的 .dae 扩展 3d 模型,转换为 .scn,有 440 万个顶点,150 万个多边形,这是一个建筑的 3d 模型,由一位艺术家在 3DS MAX 中创建,如下所示:

让sceneToLoad = SCNScene(命名为:art.scnassets/building1.scn")!

(它被加载到应用程序的 SCNView 默认查看器中,以便用户可以查看、旋转它等,通过 SCNView.allowsCameraControl = true)

Xcode 在读取该行时会立即崩溃,只有编译器信息在解开可选值时意外发现 nil".

当它运行到该行时,内存根本没有增加 - 表明它拒绝读取它,而是崩溃了.3d 模型在 XCODE Scenekit 编辑器图形查看器中完美加载、可查看、可旋转等.当我将其替换为指向较小 3d 模型的另一个文件名时,它工作正常,即使我删除同一文件中的模型 SCNNode(在同一个building1.scn"文件中)并替换为较小的 SCNNode另一个随机对象,然后奇迹般地它也可以正常工作并且加载良好.

我没有在 SO 上找到任何类似的东西 - 在其他类似的答案中,即使模型很大,iOS 也会尝试加载模型,但在任​​何一个模型中它都会立即崩溃,找到一个 nil 值.

已尝试所有解决方法,删除/删除文件并再次添加,以原始形式将其加载为 .dae,加载场景而不展开并稍后在搜索节点时展开 - 没有任何效果,总是以相同的方式崩溃.当我尝试在 ARKIT 场景中加载它时会发生同样的事情 - 它在上面试图加载文件的行崩溃.

有没有人遇到过这个问题,或者知道任何解决方法?

非常感谢

解决方案

当将具有 1.5M 多边形的 3D 模型加载到 SceneKit/ARKit、RealityKit 或 AR Quick Look 时,您将始终失败.这是因为每个 3D 模型的强大多边形数量不得超过 10K(UV 纹理的最大分辨率为 2Kx2K,或常规纹理分辨率为 1Kx1K),以及

附言

您可以使用命令行工具在usdz 中转换objfbxabc.在此处阅读相关信息.

I am loading a 300mb 3d model of extension .dae, converted into .scn, with 4.4 million vertices, 1.5 million polygons, which is a 3d model of a building, created in 3DS MAX by an artist, like so:

let sceneToLoad = SCNScene(named: "art.scnassets/building1.scn")!

(It is loaded in a SCNView default viewer in the app so that the user can view, rotate it etc., by SCNView.allowsCameraControl = true)

Xcode will immediately crash when it reads that line, with only compiler info "unexpectedly found nil while unwrapping an optional value".

The memory does not go up at all when it runs to that line - suggesting it refuses to read it , and crashes instead. The 3d model is perfectly loaded and vieweable, rotateable etc in the XCODE Scenekit editor graphical viewer. When I replace it to point to another file name of a smaller 3d model it works fine, and even when I remove the model SCNNode in the same file (in the same "building1.scn" file) and replace with a smaller SCNNode of another random object, then miraculously it also works and loads fine.

I have not found anything similar on SO - in other similar answers iOS tries to load the model even if it's huge, but in none it crashes immediately finding a nil value.

Have tried all workarounds, remove/delete file and add again, load it as .dae in its original form, load the scene without unwrapping and unwrap later when searching for a node - nothing works, always crashes in the same way. The same thing happens when I try to load it in an ARKIT scene - it crashes at the above line that tries to just load the file.

Has anyone come across this, or knows of any workaround?

Many thanks

解决方案

When load a 3D model with 1.5M polygons into SceneKit/ARKit, into RealityKit, or into AR Quick Look you'll always fail. That's because a robust number of polygons per 3D model must be not greater that 10K (with UV-texture having max resolution 2Kx2K, or with a regular texture rez 1Kx1K), and a maximum number of polygons per 3D scene must be not greater that 100K. You have exceeded the "unspoken" AR limit in 15 times.

Game engines and AR frameworks, like SceneKit, RealityKit and AR Quick Look, are incapable of rendering such a huge number of polygons using 60 fps framerate on iOS device (even most desktop computers fail to do this). The best solution for an ARKit/RealityKit applications is to use an optimized low-poly models. The most preferred format for working with AR on mobile platform is Pixar USDZ. A USDZ file is a no compression, unencrypted zip archive of USD file.

Look at this low-poly model from Turbosquid. It has just 5K polygons and it looks fine, doesn't it?

P.S.

You can convert obj, fbx or abc in usdz using command line tools. Read about it HERE.

这篇关于ARKit - 获得“意外发现为零";使用 SCN 文件时300 MB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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