【问题标题】:ARKit add snap Picture but it causes rotationARKit 添加快照图片但它会导致旋转
【发布时间】:2017-11-08 08:55:49
【问题描述】:

我创建了一个 AR 应用项目,然后在视图中添加一键手势。但图片是旋转的。我发现self.sceneView.session.currentFrame.camera.transform 导致旋转,如何解决这个问题?

- (void)handleTapGesture:(UITapGestureRecognizer *)tap {

    SCNPlane * plane = [SCNPlane planeWithWidth:self.sceneView.bounds.size.width / 6000 height:self.sceneView.bounds.size.height / 6000];
    UIImage * image = self.sceneView.snapshot;
    plane.firstMaterial.diffuse.contents = image;

    SCNNode * node = [SCNNode nodeWithGeometry:plane];
    [self.sceneView.scene.rootNode addChildNode:node];

    simd_float4x4 translation = matrix_identity_float4x4;
    translation.columns[3][2] = -0.3;

    translation = matrix_multiply(self.sceneView.session.currentFrame.camera.transform,translation);
    node.simdTransform = translation;
}

【问题讨论】:

    标签: ios objective-c augmented-reality arkit


    【解决方案1】:

    我不喜欢为什么相机变换有旋转,但是我乘以一个变换来修复它,它工作得很好。

    SCNMatrix4 stranslation =  SCNMatrix4Translate(SCNMatrix4Identity, 0, 0, -0.3);
        stranslation = SCNMatrix4Rotate(stranslation, M_PI_2, 0, 0, 1);
        simd_float4x4 translation = SCNMatrix4ToMat4(stranslation);
    
        translation = matrix_multiply(scameraTranstion,translation);
    

    【讨论】:

      猜你喜欢
      • 2019-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多