我正在尝试计算z矢量(面部坐标)的x和y世界坐标,但结果不准确。我做错了吗?
由于 这是代码。
public func renderer(_ renderer: SCNSceneRenderer, didUpdate node:
SCNNode, for anchor: ARAnchor) {
guard let faceAnchor = anchor as? ARFaceAnchor else { return }
let blendShapes = faceAnchor.blendShapes
DispatchQueue.main.async {
let eyeParameter = blendShapes[.eyeBlinkRight]
let eyeParameterFloat = CGFloat(truncating: eyeParameter!)
//Obtain transform matrix (World coordinates -> Face coordinates)
let faceMatrix = faceAnchor.transform //Transform property inherent from ARAnchor!
//Inverse the matrix (Face coordinates -> World coordinates)
let inverseFaceMatrix = faceMatrix.inverse
//Convert inverse matrix to inverse SCN Matrix
let scnInvMatrix = SCNMatrix4(inverseFaceMatrix)
//Create 1m SCNVector on the z axe of the face coordinates
let scnVector = SCNVector4(0.0,0.0,1.0,0.0)
//Multiply Vector and Inv Matrix
let FaceVector = self.multiplyMatrixVector(matrix:
scnInvMatrix, vector: scnVector)