SceneKit. Which way is up?
It seems that most 3D authoring applications use Z as the ‘Up’ axis. While SceneKit uses Y as the ‘Up’ axis. SceneKit allows you to load scenes as Collada .DAE files. When loading a Scene via either:
SCNScene(named: String?, inDirectory: String?, options: [NSObject : AnyObject]?)
SCNSceneSource(URL url: NSURL!, options: [NSObject : AnyObject]!)
You can specify options including SCNSceneSourceConvertToYUpKey and SCNSceneSourceConvertUnitsToMetersKey.
Setting these accordingly, I expected the various nodes to be transformed and scaled when I added them to my own scene constructed from Nodes in the loaded scene. But these options appear to have no effect.
let myScene = SCNScene(named: "Scene.dae", inDirectory: nil, options: [SCNSceneSourceConvertToYUpKey:true, SCNSceneSourceConvertUnitsToMetersKey:25.4])
Have I misunderstood the meaning of these option parameters?
- Can't display 3d file from cache directory
- Including textures when exporting from Blender to COLLADA/.dae format for use in SceneKit
- Load uncompressed collada file using iOS Scene Kit
- How can I export DAE files for use in Scene Kit without seeing “untitled-animations”?
- How do you load a .dae file into an SCNNode in iOS SceneKit?
- how to convert .dae to .scn files in SceneKit
Solutions Collect From Internet About “SceneKit. Which way is up?”
SceneKit does not directly load DAE (or ABC) files on iOS — it loads scenes from a private Apple format, which Xcode automatically converts to when you include scene files in your project. Part of this conversion is the option to transform the up axis.
I don’t believe that option is exposed when you simply include the DAE file as a bundle resource. (That might be a good bug to file.) However, it’s a good idea to use the new SceneKit Asset Catalog feature instead, anyway — put your DAE files and whatever external resources (textures) into a folder with a
.scnassets extension, and Xcode will process them together to optimize for the target device when you build. Then, when you select that folder in the Xcode navigator, you’ll get an editor for scene building options:
All the boxes there are good to check. 🙂 (Since the first one doesn’t come with an explanation: interleaving means organizing the vertex data for a geometry so you get better GPU-memory locality for fewer cache misses during vertex processing, which is important for performance on embedded devices.)
Hm, I don’t see anything about units in there, though. Might be another good bug to file.
There’s another option, too — all SceneKit objects implement the
NSSecureCoding protocol, so you can load and preprocess your scene on OS X, then use
NSKeyedArchiver to write it out. Include the resulting file in your iOS project as a bundle resource, and Xcode won’t preprocess it (it’s already as compressed and optimized as it can get) — and if you name it with an
.scn extension, you can use all the
SCNSceneSource methods for loading it just like you would a (preprocessed) DAE file.
- How to get active users distributed by Campaign source? Google Analytics campaign tracking ios
- UITextField format in xx-xx-xxx
- Hide keyboard when scroll UITableView
- What Is the Code to Install FirebaseUI on iOS (Swift)
- Is there any way to programatically send my iPhone app to the background
- Load custom UIView with XIB from a View Controller's view using IB
- Search-like highlighting in NSTextView
- How can I merge two arrays into a dictionary?
- Reachability takes too long to fail when connected to WIFI without internet
- Facebook App Requests aren't shown on iOS devices?
- iPhone Objective C: How to get a pixel's color of the touched point on an UIImageView?
- How do I parse a JSON object that has type-dependent sub-objects, in Swift?
- iOS Bar Item image displaying wrong color
- Add GPX File to Xcode 6 Project
- Error in dateFormat returns nil