【问题标题】:Xamarin ARcore change position of 3D objectXamarin ARcore 更改 3D 对象的位置
【发布时间】:2018-04-25 11:55:35
【问题描述】:

我正在尝试使用Xamarin 实现ARcore,并希望在特定的geolocation (like in pokemongo) 中设置3D 对象。我试图浏览我在这个论坛中找到的这个示例:https://blog.xamarin.com/augmented-reality-xamarin-android-arcore/,但似乎我无法更改 3d 对象的位置,并且它是根据gesture 仅在plane 上的点击设置的。

有没有办法放置一个对象并跟踪它?我确实设法用ARkit 做到了这一点,但直到现在ARcore Android 还没有成功。

任何想法都会有所帮助。

【问题讨论】:

    标签: android xamarin augmented-reality arcore


    【解决方案1】:

    看起来 ARCore 的 Xamarin 包装器只是简单地包装了 OpenGL。因此,绘制对象需要设置多个矩阵(模型、视图和投影)矩阵:

    objectRenderer.UpdateModelMatrix(anchorMatrix, scaleFactor);
    objectRenderer.Draw(viewMatrix, projectionMatrix, lightIntensity);
    

    如果您只是从foreach (var planeAttachment in planeAttachments) { 循环中删除它,那么您可以将anchorMatrix(又名modelMatrix)设置为固定/硬编码转换,然后它会相对于相机进行自我修复。

    这是一篇关于视图矩阵的不错的文章:https://www.3dgep.com/understanding-the-view-matrix/#The_View_Matrix

    -- 开始无耻插件--

    但是,如果您愿意尝试新平台,我的团队已经为 AR/VR 开发 (Viro React) 构建了一个跨平台 React-Native 库:https://viromedia.com/viroreact/

    如果您更熟悉 iOS 上的 SceneKit,我们在 Android 上构建了一个类似的解决方案,支持 AR/VR (ViroCore):https://viromedia.com/virocore/

    任何一种解决方案都可以让您跳过 OpenGL 的复杂性,并相对轻松地定位您的对象/模型。

    即。

    将模型放置在您面前 1 米处就像(在 Viro React 中)一样简单:

    <Viro3dObject source={require("./res/model.obj")} position={[0,0,-1]} type="OBJ" />
    

    【讨论】:

      猜你喜欢
      • 2022-04-28
      • 1970-01-01
      • 2018-06-25
      • 2016-09-07
      • 1970-01-01
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      相关资源
      最近更新 更多