所以我是 ARKit 和 SceneKit 的新手,我正在按照 Apple 的教程进行操作。 https://developer.apple.com/documentation/arkit/tracking_and_visualizing_faces .
我想做的是创建一个类似于 Animoji 屏幕的 View ,其中包含 BlendShape 的 SCNNode 在 View 中居中,并且 Blendshape 的 z 值不会根据面部的距离远近而改变从相机。我还想让相机不可见,这样您就只能看到 BlendShape。
解决这个问题的最佳方法是什么?如何做?
我试过将 pivot 设置为 0 并将 position.z 也设置为 0,但我认为这不是正确的方法。
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
guard let faceAnchor = anchor as? ARFaceAnchor
else { return }
let blendShapes = faceAnchor.blendShapes
guard let eyeBlinkLeft = blendShapes[.eyeBlinkLeft] as? Float,
let eyeBlinkRight = blendShapes[.eyeBlinkRight] as? Float,
let jawOpen = blendShapes[.jawOpen] as? Float
else { return }
eyeLeftNode.scale.z = 1 - eyeBlinkLeft
eyeRightNode.scale.z = 1 - eyeBlinkRight
jawNode.position.y = originalJawY - jawHeight * jawOpen
node.pivot = SCNMatrix4MakeTranslation(0,0,0)
node.position.z = 0
}
下面的 View 类似于我要实现的 View ,但没有列出其他混合形状。
最佳答案
如果您对 ARKit 自动移动场景中的节点不感兴趣,您可以避免绑定(bind) SCNNode
到 ARAnchor
(即不实现 -renderer:nodeForAnchor:
)。相反,您会查询 ARAnchor
在 -session:didUpdateAnchors:
.
事实上,由于您实际上并没有 AR 体验,而只是面部跟踪,您甚至不需要 ARSCNView
但只是一个SCNView
.
关于ios - 如何居中混合变形 SCNNode 以查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57317476/