我有一个名为wc的子节点的场景。我想在该节点上添加dae / model文件。
我可以通过以下方式添加模型/ dae:
以下是摘录:
代码段(在viewDidLoad中)
//Create Scene
SCNScene *scene = [SCNScene sceneNamed:@"bathScene.scnassets/peace01.dae"];
SCNView *scnView = (SCNView *)self.view;
scnView.scene = scene;
scnView.allowsCameraControl = YES;
scnView.delegate = self;
scnView.autoenablesDefaultLighting = YES;
//Get the required node where dae is to be added
SCNNode * wcNode = [scnView.scene.rootNode childNodeWithName:@"wc" recursively:YES];
SCNVector3 wcNodeScreenPosition = [scnView projectPoint:wcNode.position];
NSLog(@"wcNode position %f, %f, %f",wcNodeScreenPosition.x, wcNodeScreenPosition.y, wcNodeScreenPosition.z);
//Create sub-Scene
SCNScene* wcScene = [SCNScene sceneNamed:@"bathScene.scnassets/closet.dae"];
//Add the sub-scene root node to the required node of parent scene
[scnView.scene.rootNode addChildNode:[wcScene.rootNode childNodeWithName:@"ceramic" recursively: false]];
SCNNode * wcDAENode = [wcScene.rootNode childNodeWithName:@"ceramic" recursively: false];
wcDAENode.position = [wcNode position];
SCNVector3 wcDAENodeScreenPosition = [scnView projectPoint:wcDAENode.position];
NSLog(@"DAE position %f, %f, %f",wcDAENodeScreenPosition.x, wcDAENodeScreenPosition.y, wcDAENodeScreenPosition.z);
日志输出
wcNode职位275.306549,157.163620,0.956176
DAE位置284.000000,160.000000,0.959596
正如您在上述日志输出中所看到的,所需节点及其子Dae节点的位置与渲染模型在场景中移动的位置不同。
为什么职位不同?
如何补偿转变?