Reputation: 4589
This is a screenshot from Apple's Fox sample code. As you can see, they use .scn file format for graphics object. They explicitly state in the wwdc2015 video that this was done by an artist. So far I only worked with .dae and was until recently convinced that this is the only supported format. My question is, how do I export objects stored in .dae file to .scn file?
EDIT: this is what I get if go to Editor-> Convert to SceneKit scene file format (.scn)
Upvotes: 42
Views: 39191
Reputation: 58043
You can programmatically convert .dae
to .scn
using the following code. The instance method called write(to:options:delegate:progressHandler:)
works in iOS 10.0+ and macOS 10.9+.
import SceneKit
class GameViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
let sceneView = self.view as! SCNView
sceneView.allowsCameraControl = true
let dae = SCNScene(named: "art.scnassets/model.dae")!
let path = FileManager.default.urls(for: .documentDirectory,
in: .userDomainMask)[0]
.appendingPathComponent("Model.scn")
dae.write(to: path, options: nil, delegate: nil, progressHandler: nil)
print(path)
let scene = try! SCNScene(url: path)
sceneView.scene = scene
}
}
Upvotes: 0
Reputation: 13462
open your DAE file in the SceneKit scene editor, then go to the Editor menu and click "Convert to scn file format".
Your artist won't be able to export a scn file from their favourite tool. You'll have to use Xcode to convert a DAE to SCN.
Upvotes: 28
Reputation: 47159
Exporting the .dae
is unnecessary; you can place the object directly into a .scn
file:
Create the new .scn
file in the .scnassets
folder, then drag the .dae
file into the scene.
Upvotes: 39