2012-08-10 6 views
1

CoreMotion 프레임 워크를 사용하여 증강 현실 앱을 제작하려고합니다. 필자는 Apple의 pARk 샘플 코드 프로젝트에서 벗어나려고했지만 세로 모드에서만 작동합니다. 나는 그것이 경관에서 일할 필요가있다.가로 모드의 증강 현실 앱

    : 반대 방향에서 오버레이 뷰 이동에 잘못된 속도로 가로 모드로 하위 뷰를 전환 할 때 두 가지 솔루션을 제공하는 내가 other postings을 읽고

    (그들 중 하나가 너무 빠르거나 화면에서 너무 느리게 이동)

  • CoreMotion Tea Pot Example에서 제안한 것처럼, 현재의 태도에 기준 태도를 만들고 그 태도의 역을 적용하십시오.

  • 는 태도의 사원 수의 표현으로 90도

내 증강 현실 응용 프로그램은 사실 북쪽으로 참조 할 것을 요구하기 때문에 첫 번째가 작동합니다 생각하지 않습니다를 돌립니다.

두 번째 계산에 필요한 수학을 이해하지 못합니다.

이 복잡한 문제를 해결하는 방법에 대한 제안을 환영합니다.

답변

0

확대 된 리얼리티 앱에 얼마나 있습니까? Apple의 PARK를 처음 보면서 시작하는 것이 가혹하다고 생각합니다. 좀 더 진보 된 수학적 이해가 필요합니다. 하지만 그렇게한다면 왜 안돼!

repository을보실 수 있습니다.이 사진은 인물 및 풍경 모드에서 작동하는 augmented reality 프로젝트입니다. 회전을 처리하는 방법은 다음과 같습니다.

- (void)deviceOrientationDidChange:(NSNotification *)notification { 

prevHeading = HEADING_NOT_SET; 

[self currentDeviceOrientation]; 

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 

// Later we may handle the Orientation of Faceup to show a Map. For now let's ignore it. 
if (orientation != UIDeviceOrientationUnknown && orientation != UIDeviceOrientationFaceUp && orientation != UIDeviceOrientationFaceDown) { 

    CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(0)); 
    CGRect bounds = [[UIScreen mainScreen] bounds]; 

    switch (orientation) { 
     case UIDeviceOrientationLandscapeLeft: 
      transform   = CGAffineTransformMakeRotation(degreesToRadian(90)); 
      bounds.size.width = [[UIScreen mainScreen] bounds].size.height; 
      bounds.size.height = [[UIScreen mainScreen] bounds].size.width; 
      break; 
     case UIDeviceOrientationLandscapeRight: 
      transform   = CGAffineTransformMakeRotation(degreesToRadian(-90)); 
      bounds.size.width = [[UIScreen mainScreen] bounds].size.height; 
      bounds.size.height = [[UIScreen mainScreen] bounds].size.width; 
      break; 
     case UIDeviceOrientationPortraitUpsideDown: 
      transform = CGAffineTransformMakeRotation(degreesToRadian(180)); 
      break; 
     default: 
      break; 
    } 


    [displayView setTransform:CGAffineTransformIdentity]; 
    [displayView setTransform: transform]; 
    [displayView setBounds:bounds]; 

    degreeRange = [self displayView].bounds.size.width/ADJUST_BY; 

} 
} 

장치 회전 후에 모든 주석을 회전 한 다음 오버레이보기를 회전해야합니다!

+0

저장소의 좋은 예 .. –

0

정말 붙어있어 다른 툴킷을 사용하려는 경우 iPhone-AR-Toolkit을 사용해보십시오. 그것은 초상화와 풍경 모두에서 작동합니다.

+0

프레임 워크를 사용해 보았지만 오버레이보기의 움직임이 너무 고르지 않습니다. Apple의 PARK에서의 움직임은 훨씬 더 부드럽습니다. –