swift - 我怎样才能只允许从门户进入我的虚拟场景?

标签 swift augmented-reality arkit coreml apple-vision

我有一个应用程序,可以渲染增强现实场景和一个您可以走进场景的门户。该场景被平面遮挡,无法看到,但如果您走过该平面,您就会“闯入”虚拟环境。

我不是在寻找代码,而是在寻找如何解决此问题的帮助。我想让你进入虚拟场景的唯一方法就是穿过我创建的门口。我首先考虑跟踪相机的位置,并确保在越过阈值以启用渲染之前您非常接近入口,但似乎如果我这样做,用户将无法看穿在接近/进入虚拟场景之前的门口。

最佳答案

首先看How to create a Portal effect in ARKit just using the SceneKit editor? Stack Overflow 发布了如何制作门户本身的文章。

The robust way to prevent users from passing through virtual walls is to have the same configuration of virtual walls like real walls have (where physical wall is – the virtual wall exists too).

enter image description here

您还需要对象检测工具。为了将虚拟墙精确定位在真实的物理墙上,只需使用 Core ML具有预先训练的小型 mlmodel 的框架以及 ARKit 框架的类,如 ARImageTrackingConfiguration()ARWorldTrackingConfiguration() .

enter image description here

In case you have no opportunity to build the same configuration of virtual walls like real walls were built, you can make a user's iPhone vibrate when a user has collided with a virtual wall. Here's a code:

import AudioToolbox.AudioServices

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)

希望这有帮助。

关于swift - 我怎样才能只允许从门户进入我的虚拟场景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55210060/

相关文章:

ios - 使用 AVCaptureSession 录制视频

ios - 无法将排序的字典序列化为 JSON - Swift 3

objective-c - 如何使用 NSNotificationCenter 传递对象

ios - 为什么我不能在 Swift 中通过调用静态函数来初始化静态变量?

c++ - VTK的ProjectionTransformMatrix和OpenGL的GL_PROJECTION有什么区别?

augmented-reality - 如何在 ARCore 中显示从服务器获取的图像?

ios - 变暗/变亮 ARKit 相机在物体后面的反馈

c# - 当前上下文中不存在名称 'ARSubsystemManager'

swift - 为什么定义 SCNNode.look 后 SCNNode 变得不可见?

ios - 为什么我的 ARKit Video 没有显示在应用 View 中