适用于 iOS 的 Big SCNGeometry SceneKit [英] Big SCNGeometry SceneKit for iOS
问题描述
我正在开发可可/iOS 项目.我有一个管理 Scenekit 场景的通用 swift 类.
I am working on a cocoa/iOS projet. I have a common swift class which manage a Scenekit scene.
我想画一个大地形(大约 5000x5000 点).我每 4 点有 2 个三角形.我为整个地形创建了一个 scngeometry 对象(这是一件好事吗?)
I want to draw a big terrain (about 5000x5000 points). I have 2 triangles per 4 points. I have created a scngeometry object for the whole terrain (is it a good thing ?)
我决定将这些点存储在一个 6-Float 结构(x,y,z 和 r,g,b)中.我试图在开始时创建一个空数组或分配一个大数组:我遇到了同样的问题.我使用 Int 数据类型来处理索引数组.该项目在 Cocoa 上运行良好,但在 iOS 上出现内存错误.我认为这是因为需要有一个大而连续的顶点数组.
I decided to store those points in a 6-Float structure (x,y,z and r,g,b). I tried to create an empty array or to allocate a big array at the begining : i got the same issue. I work with Int datatype for indices array. The project works fine on Cocoa but i get memory errors on iOS. I think this is because of the need to have a big and contigous array for vertex.
我尝试创建几个几何对象块,但如果我们擦除以前的缓冲区,场景套件不喜欢.
I tried to create several chunks of geometry objects but scene kit does not like if we erase a previous buffer.
这种情况下的最佳实践是什么?
What is the best practice in this case ?
有没有办法将顶点存储在大容量存储上而不是内存阵列/缓冲区上?
Is there a way to store vertex on the mass storage instead of memory arrays/buffers ?
谢谢
推荐答案
那么……在闪亮的全新 5K 显示器上,地形点数是像素数的两倍?这是在 iOS 上一次使用的大量内存.而且您将无法在 iOS 设备上看到该分辨率.
So...twice as many terrain points as there are pixels on a shiny new 5K display? That's a huge amount of memory to be using at once on iOS. And you won't be able to see that resolution on an iOS device.
那怎么样:
- 将您的 2500 万像素地形分解成更小的图块,每个图块都在自己的 SCNNode 中.循环遍历图块,创建一个 SCNNode,丢弃该图块的 6-Float 数组并移至下一个.
- 使用 SCNLevelOfDetail 生成这些节点的更简单版本,以便在它们距离很远时显示.
- 在 OS X 上进行构建工作.存档您的场景 (NSSecureCoding).将该场景捆绑到 iOS 应用中.
- 考虑在主 SCNScene 中使用参考节点,并将每个图块存档为单独的 SCNScene 文件.
- 希望您已经在使用三角形条带而不是三角形来构建几何图形.
这篇关于适用于 iOS 的 Big SCNGeometry SceneKit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!