3

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.

4

2 回答 2

6

如果您想从文件中读取对象并将它们插入到另一个场景中,那么您可以创建一个场景源并从那里获取条目。

创建场景源与创建完整场景非常相似

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

如果您知道要查找的节点的 ID,则可以直接使用

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

否则,您可以询问所有节点的标识符,并从那里找出您要查找的标识符。

NSArray *nodeIdentifiers = [source identifiersOfEntriesWithClass:[SCNNode class]];
于 2013-10-07T17:26:24.830 回答
2

从 Collada 文件创建 SCNScene 实例后,您可以使用以下名称检索任何节点:

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

于 2013-10-08T02:26:41.530 回答