Cocoa 更改SCNRender';s的观点

Cocoa 更改SCNRender';s的观点,cocoa,3d,scenekit,Cocoa,3d,Scenekit,我从一个场景中创建了一个具有特定视角的场景渲染器。我使用SCNView使我的视角可见,当对象场景看起来像我想要的时,我在脱机openGLContext中渲染它以使其成为图像。这是相关的代码位: SCNRenderer *lRenderer = [SCNRenderer rendererWithContext:openGLContext.CGLContextObj options: nil]; lRenderer.scene = self.sceneView.scene; lRenderer.po

我从一个场景中创建了一个具有特定视角的场景渲染器。我使用SCNView使我的视角可见,当对象场景看起来像我想要的时,我在脱机openGLContext中渲染它以使其成为图像。这是相关的代码位:

SCNRenderer *lRenderer = [SCNRenderer rendererWithContext:openGLContext.CGLContextObj options: nil];
lRenderer.scene = self.sceneView.scene;
lRenderer.pointOfView = [self.sceneView.pointOfView clone];
[ lRenderer render ];
我发现克隆视点可以使渲染器以与SCNView完全相同的方式渲染场景。很好,到目前为止

现在我想调整一下观点。例如,我想将旋转设置为独立于场景视图的某个位置,比如说0。因此,我确实:

lRenderer.pointOfView.rotation = SCNVector4Make(1,1,1,M_PI_2);
在调用
[lRenderer render]
之前,这不会改变任何事情


我在lRenderer.pointOfView上更改的任何属性似乎都无关紧要。但是,如果我省略行
lRenderer.pointOfView=[self.sceneView.pointOfView clone]
渲染器将从默认的角度而不是self.sceneView的角度进行渲染,因此,克隆的SCNNode中一定有什么东西我可以在lRenderer.pointOfView上更改,这将产生影响?

这里唯一看起来可疑的是,你的“克隆”视角不是场景的一部分。因此,我会尝试:

SCNNode *anotherPointOfView = [self.sceneView.pointOfView clone]; //clone
[[self.sceneView.pointOfView parentNode] addChildNode:anotherPointOfView]; //add to the scene (here at the same hierarchy level as the original point of view)

lRenderer.pointOfView = anotherPointOfView; //set the new point of view as the pov of the offscreen renderer

这里唯一看起来可疑的是,你的“克隆”视角不是场景的一部分。因此,我会尝试:

SCNNode *anotherPointOfView = [self.sceneView.pointOfView clone]; //clone
[[self.sceneView.pointOfView parentNode] addChildNode:anotherPointOfView]; //add to the scene (here at the same hierarchy level as the original point of view)

lRenderer.pointOfView = anotherPointOfView; //set the new point of view as the pov of the offscreen renderer

你可能是指
[lRenderer.scene.rootNode addChildNode:lRenderer.pointOfView]
对吗?self.scene没有pointOfView成员,它的类型是SCNScene.ho否,我的意思是[self.sceneView.pointOfView addChildNode:anotherPointOfView];修正你的意思可能是
[lRenderer.scene.rootNode addChildNode:lRenderer.pointOfView]
对吗?self.scene没有pointOfView成员,它的类型是SCNScene.ho否,我的意思是[self.sceneView.pointOfView addChildNode:anotherPointOfView];固定的