Question

Is there a way to create a SCNNode starting from a COLLADA Object and then add the node as child of the rootNode?

I see the with ScenKit I can create a SCNScene starting from a .dae file using

[SCNScene sceneWithURL:url options:nil error:&error];

But I can't find a way to create a Node starting just from a dae.

Was it helpful?

Solution

If you want to read objects from a file and insert them into another scene then you can create a scene source and get the entries from there.

Creating a scene source is very similar to creating a full scene

SCNSceneSource *source = [SCNSceneSource sceneSourceWithURL:url options:nil]; 

If you know the id of the node you are looking for then you can get it directly using

SCNNode *someNode = [source entryWithIdentifier:@"yourIdentifier" withClass:[SCNNode class]];

Otherwise you can ask for the identifiers for all the nodes and from there figure out what identifier you are looking for.

NSArray *nodeIdentifiers = [source identifiersOfEntriesWithClass:[SCNNode class]];

OTHER TIPS

Once you have a SCNScene instance created from a Collada file, you can retrieve any node with its name with:

SCNNode *myNode = [myScene.rootNode childNodeWithName:@"aNodeName" recursively:YES];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top