2
votes

I am trying to create a demo application by watching WWDC 2017 video.

let planeNode = SCNNode(geometry: imageplane)
sceneView.scene.rootNode.addChildNode(planeNode) 
var translation=matrix_identity_float4x4
translation.columns.3.z = -0.1
planeNode.simdTransform = matrix_multiply(currentFrame.camera.transform,
                                          translation)

The above code works fine and displays plane properly. However on tap it changes snapshot's rotation, tried different ways but nothing worked.

Any help will be really appreciated.

2
What do you mean "it changes snapshot's rotation" ? It should put the snapshot in front of the camera, parallel to it. So if your camera is turner, the snapshot will be turned as wellGuig
@guig it should show the screenshot as it is. Currently it changes the rotation of the image. eg if the snapshot is in portait mode, final added screenshot will show in landscape. basically like a 90 degree rotation is applied to the captured image.Mohit
Same here. Any ideas?dobranoc
@monikazee nope. no ideas :( dint find any solution for thisMohit

2 Answers

2
votes

Change the rotation of the SCNNode prior adopting the translation of the camera:

let planeNode = SCNNode (geometry: imageplane)
planeNode.eulerAngles.z = Float.pi / 2

var translation = planeNode.simdTransform
translation.columns.3.z = -0.1
planeNode.simdTransform = matrix_multiply(currentFrame.camera.transform,translation)

sceneView.scene.rootNode.addChildNode(planeNode)
0
votes

I ran into this same issue, solved it by rotating the translation matrix prior to applying the camera transformation to the node.

Code in Obj-C:

SCNNode *planeNode = [SCNNode nodeWithGeometry:imagePlane];

simd_float4x4 translation = planeNode.simdTransform;
translation.columns[3].z = -0.1;
translation =  SCNMatrix4ToMat4(SCNMatrix4Rotate(SCNMatrix4FromMat4(translation), GLKMathDegreesToRadians(90), 0, 0, 1.0));
planeNode.simdTransform = matrix_multiply(currentFrame.camera.transform, translation);

[self.sceneView.scene.rootNode addChildNode:planeNode];