Apple have recently announced Model I/O Framework and, understandably, documentation is currently quite sparse with many classes still not fully documented. The Model I/O talk suggests a two-way link between SceneKit classes and Model I/O classes, but I can't find a way to do this in practice.
SCNGeometry
has a convenience init
which accepts a MDLMesh
object, but I'm not sure how to go the other way and generate a MDLMesh
object from a pre-existing SCNGeometry
.
The init
for MDLMesh
is:
init(vertexBuffer vertexBuffer: MDLMeshBuffer,
vertexCount vertexCount: Int,
descriptor descriptor: MDLVertexDescriptor,
submeshes submeshes: [MDLSubmesh])
or, alternatively, the same but with vertexBuffers: [MDLMeshBuffer]
(where a vertex buffer corresponds to a SceneKit geometry source), I can't figure out where to go from here.
(It looks like MDLMeshBuffer
has a method which takes a fillData: NSData
parameter, and I know SCNGeometry.geometrySources
gives an array of SCNGeometrySources
each with a .data
that provides these geometry sources as an NSData
object, but I'm not sure if this is the right way to go about doing it.)
Any guidance would be much appreciated.
According to engineers in the labs at WWDC, the SceneKit to Model I/O bridge isn't in the first beta, but should show up in another beta later in the summer.