I am trying to extract the geometry for each node in my scene. I create a scene using a .obj file and it renders perfectly. I would, however, like to extract the geometry from each node but I am stuck. My code is below
let scn = SCNScene(named: "d.obj")
for i in scn!.rootNode.childNodes {
for a in i.childNodes {
for b in a.childNodes {
let element = b.geometry!.geometryElementAtIndex(0)
let source = b.geometry!.geometrySources[0]
var z: Float = 0
source.data.getBytes(&z, length: sizeof(Float))
print(z)
}
}
}
I would like to get the positions and normals so I can store them in a database.