首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >增强现实在景观模式中的应用

增强现实在景观模式中的应用
EN

Stack Overflow用户
提问于 2012-08-10 17:37:18
回答 2查看 1.1K关注 0票数 1

我正在尝试使用CoreMotion框架构建一个增强现实应用程序。我试着脱离苹果的pARk示例代码项目,但它只在纵向模式下工作。我需要它在风景中发挥作用。当切换到景观模式时,重叠视图中的子视图以相反的方向以错误的速度移动(它们要么移动得太快,要么在屏幕上移动太慢)

我读过其他职位,它提供了两个解决方案:

  • 创建一个参考态度并将该态度的反向应用于当前态度,如CoreMotion茶壶示例中所建议的那样。
  • 旋转姿态的四元数表示90度

我不认为第一个会起作用,因为我的增强现实应用程序要求它被引用到真正的北方。

我也不明白做第二题所需的数学。

对于如何解决这个复杂的问题,我表示欢迎。

EN

回答 2

Stack Overflow用户

发布于 2012-10-28 19:23:32

你现在在你的增强现实应用程序中有多远?我认为从苹果公司的PARk开始是很残酷的。你需要有一些先进的数学理解。但如果你这么做了,为什么不呢?

你可以看看这个存储库,这是一个增强现实项目,致力于肖像和景观模式。以下是如何处理轮调:

代码语言:javascript
复制
- (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
EN

Stack Overflow用户

发布于 2013-01-04 15:35:03

如果您真的被困住了,并且愿意使用另一个工具包,请尝试iPhone-AR-工具包。它既适用于肖像,也适用于景观。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11906611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档