看起来 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" />