1

我一直在玩增强示例并阅读完整的 SDK 文档,但我无法弄清楚这个问题。我正在尝试将 self.cameraView 上的触摸转换为 ARVector3,以便可以将 3D 模型移动到该位置。目前我正在尝试将 CGPoint 从 tapGesture 转换为世界 ARNode 但到目前为止还没有运气。

float x = [gesture locationInView:self.cameraView].x;
float y = [gesture locationInView:self.cameraView].y;
CGPoint gesturePoint = CGPointMake(x, y);
ARVector3 *newPosition = [arbiTrack.world nodeFromViewPort:gesturePoint];   

ARNode *touchNode = [ARNode nodeWithName:@"touchNode"];
ARImageNode *targetImageNode = [[ARImageNode alloc] initWithImage:[UIImage imageNamed:@"drop.png"]];
[touchNode addChild:targetImageNode];
[targetImageNode scaleByUniform:1];

touchNode.position = newPosition;
[arbiTrack.world addChild:touchNode];

这会导致以下情况: 将世界渲染为模式

在我的 iPhone 上看到:

iPhone 截图

为什么触摸self.cameraView的左上角是最近的点?我实际上想单击屏幕并返回 X、Y、Z (ARVector3) 坐标。

4

0 回答 0