[英]how to convert .dae to .scn files in SceneKit
This is a screenshot from Apple's Fox sample code.这是 Apple 的 Fox 示例代码的屏幕截图。 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.
如您所见,他们使用 .scn 文件格式的图形 object。他们在 wwdc2015 视频中明确 state 这是由艺术家完成的。 So far I only worked with.dae and was until recently convinced that this is the only supported format.
到目前为止,我只使用 .dae 并且直到最近才确信这是唯一受支持的格式。 My question is, how do I export objects stored in.dae file to.scn file?
我的问题是,如何将存储在.dae 文件中的对象导出到.scn 文件?
EDIT: this is what I get if go to Editor-> Convert to SceneKit scene file format (.scn)编辑:如果 go 到编辑器-> 转换为 SceneKit 场景文件格式(.scn),这就是我得到的
open your DAE file in the SceneKit scene editor, then go to the Editor menu and click "Convert to scn file format". 在SceneKit场景编辑器中打开DAE文件,然后转到“编辑器”菜单并单击“转换为scn文件格式”。
Your artist won't be able to export a scn file from their favourite tool. 您的艺术家将无法从他们喜爱的工具中导出scn文件。 You'll have to use Xcode to convert a DAE to SCN.
您必须使用Xcode将DAE转换为SCN。
You can programmatically convert .dae
to .scn
using the following code.您可以使用以下代码以编程方式将
.dae
转换为.scn
。 The instance method called write(to:options:delegate:progressHandler:)
works in iOS 10.0+ and macOS 10.9+.名为
write(to:options:delegate:progressHandler:)
的实例方法适用于 iOS 10.0+ 和 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
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.