2016-12-22 3 views
1

vuforia를 사용하여 Augmented Reality 기반 iOS 앱을 만듭니다. 내 프로젝트에 Vuforia SDK를 통합했습니다. 대상 이미지를 스캔하는 동안 대상 이미지 위에 개체를 표시해야합니다. 그것은 잘 작동합니다. 또한 사용자가 객체를 터치 할 때 화면 위에 일부 메시지를 표시해야합니다. 사용자가 어떤 물체를 만졌는지 식별하려면 어떻게해야합니까? 장치가 확대되고 축소 될 때 터치 이벤트가 작동하는 방식은 무엇입니까?vuforia iOS 앱의 터치 이벤트

+0

도미노 예제 프로젝트 및 Vuforia 포럼에서 터치 이벤트를 구현 한 방법을 확인하십시오. 증강 현실 질문을 https://developer.vuforia.com/forum/ios/handling-touches에 요청할 수 있습니다. –

+0

도미노를 확인했는데 제대로 작동하지 않습니다. 터치 이벤트를 수행하는 방법을 알고 있습니까? –

+0

나는 이것을 Dominoes 예제를 사용하여 만들었습니다. 나는 도미노 3d 모델을 이미지 타겟으로 대체했습니다. –

답변

0

ImageTarget과 Dominoes 샘플을 결합하여보십시오. 도미노에서 터치 이벤트 핸들은 도미노 샘플에서 EAGLView.mm에서 시작 :

// Pass touch events through to the Dominoes module 
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch* touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:self]; 
    dominoesTouchEvent(ACTION_DOWN, 0, location.x, location.y); 
} 

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch* touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:self]; 
    dominoesTouchEvent(ACTION_CANCEL, 0, location.x, location.y); 
} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch* touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:self]; 
    dominoesTouchEvent(ACTION_UP, 0, location.x, location.y); 
} 

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch* touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:self]; 
    dominoesTouchEvent(ACTION_MOVE, 0, location.x, location.y); 
} 

들이 이러한 접촉을 처리하는 방법을 이해하고 동일한 작업을 수행하려고합니다. 자세한 내용은 Vuforia 개발자 포럼을 참조하십시오. https://developer.vuforia.com/forum/ios/getting-touch-event-3d-model

+0

이제 내가 만진 물건을 확인할 수 있습니다. 그러나 장치가 확대되거나 축소되면 제대로 작동하지 않습니다. 즉, 물체의 접촉을 식별 할 수 없습니다. –

+0

도미노에서의 회전과 같이 장치 회전을 올바르게 처리 했습니까? 개체에 터치 이벤트를 올바르게 추가 한 경우 확대/축소 수준에서 터치 이벤트를 감지 할 수 있습니다. –

+0

답장을 보내 주셔서 감사합니다. vuforia 및 iOS를 처음 사용합니다. 내가 예를 든다. 대상 이미지 (좌표 0,0)의 가운데에 너비 40.0f 높이 40.0f의 개체를 놓았습니다.이 좌표는 (0,0,40,40)입니다. 사용자가이 좌표 내부를 터치하면 터치가 작동해야합니다. . 때로는 잘 작동합니다. 그러나 장치가 확대되거나 축소 될 때 작동하지 않습니다. 장치가 확대되거나 축소 될 때 개체의 좌표가 변경된다는 것을 알고 있습니다. 나는 도미노 샘플과 함께 일하는 법을 알지 못했다. –