Reality Kit ARCamera,最后一行始终为零。为什么?

问题描述 投票:1回答:1

我已经使用Xcode的默认模板启动了一个新的增强现实项目。

我完成了arView.session.delegate = self

  override func viewDidLoad() {
    super.viewDidLoad()

    // Load the "Box" scene from the "Experience" Reality File
    let boxAnchor = try! Experience.loadBox()

    // Add the box anchor to the scene
    arView.scene.anchors.append(boxAnchor)

    arView.session.delegate = self
}

并在我打印相机变换的地方添加了此委托方法

func session(_ session: ARSession, didUpdate frame: ARFrame) {
  print(frame.camera.transform)
}

打印是这样的:

simd_float4x4([[-0.99477124, -0.02513871, 0.09898488, 0.0], [0.04075573, -0.98642635, 0.15906614, 0.0], [0.09364258, 0.16226865, 0.9822931, 0.0], [-0.031830817, -0.025311433, 0.007536184, 1.0]])

此打印列出了列,对吗?并且列顺序为xyzw,对吧?

如果是这样,则该矩阵的最后一行始终为0 0 0 1

为什么?这条线代表什么?

ios arkit simd realitykit arcamera
1个回答
0
投票

我想您忘记遵守ARSessionDelegate协议:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        arView.session.delegate = self
    }
}

extension ViewController: ARSessionDelegate {

    func session(_ session: ARSession, didUpdate frame: ARFrame) {
        print(frame.camera.transform)
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.