You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, this project is really awesome! I just want to ask one question about coordinates mapping:
let mat = SCNMatrix4FromMat4(currentFrame.camera.transform)
let dir = SCNVector3(-1 * mat.m31, -1 * mat.m32, -1 * mat.m33)
let currentPosition = pointOfView.position + (dir * 0.1)
Could you please explain what does these code do?
What's the meaning of sceneView.pointOfView and its difference between currentFrame?
And , I also wondered to calculate the current position of line point to start drawing, why can't I use the following code?
sceneView.pointOfView is the current ARKit point of view in the scene. The position of the currentFrame.camera and the position of the sceneView.pointOfView should be the same.
Now regarding the code that gets the orientation of the camera, that was actually done by someone else in this pull request: #2
let mat = SCNMatrix4FromMat4(currentFrame.camera.transform)
// here we get the 4x4 transform matrix from the current frame's camera
let dir = SCNVector3(-1 * mat.m31, -1 * mat.m32, -1 * mat.m33)
// .m31, .m32 and .m33 stand for the x, y and z components of the out vector of the matrix
// which has a magnitude of 1 and is parallel to the user's point of view (going outwards I think)
let currentPosition = pointOfView.position + (dir * 0.1)
// and here we multiply the camera's "out" vector by 0.1 (for 10 cm) and then add that to the
// camera's position to get the position of a point that's exactly 10 cm in front of the camera
Also yes, it does look like your code would work (also could be simplified to simply return sceneView.pointOfView.position) but it would "only" return the position of the camera, not 10 cm in front of it. I'm not an expert at 3D programming at all so that was my first approach too, to simply draw where the camera is positioned ! 😄
Hi, this project is really awesome! I just want to ask one question about coordinates mapping:
Could you please explain what does these code do?
What's the meaning of
sceneView.pointOfView
and its difference between currentFrame?And , I also wondered to calculate the current position of line point to start drawing, why can't I use the following code?
Thank you very much.
The text was updated successfully, but these errors were encountered: