Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch event in LandscapeLeft or LandscapeRight orientation. #14

Open
jhudziak opened this issue Sep 25, 2016 · 3 comments
Open

Touch event in LandscapeLeft or LandscapeRight orientation. #14

jhudziak opened this issue Sep 25, 2016 · 3 comments

Comments

@jhudziak
Copy link

Do you know how to calculate position x and y used in hitTest method when vuforia and device work in landscape orientation ?

Regards, JH

@yshrkt
Copy link
Owner

yshrkt commented Sep 26, 2016

Maybe you not need to fix hitTest method for landscape orientation.
This sample work in landscape orientation, by prepare like below:

vuforiaManager?.prepare(with: .landscapeLeft)

@jhudziak
Copy link
Author

I wrote this functionality. If you want i can fork this project with rotation support, and later you can add this to your sample.

But my question is about touchedNodWithLocationInView. Did i change it propperly?

- (SCNNode*)touchedNodeWithLocationInView:(CGPoint)location {
    CGPoint pos = location;
    pos.x *= [[UIScreen mainScreen] nativeScale];
    pos.y *= [[UIScreen mainScreen] nativeScale];
    pos.y = _manager.viewport.size.height + _manager.viewport.origin.y - pos.y;

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeLeft){
        pos.x += fabs( _manager.viewport.origin.x);
    }

    NSArray* results = [_renderer hitTest:pos options:nil];
    return [[results firstObject] node];
}

@yshrkt
Copy link
Owner

yshrkt commented Sep 27, 2016

But my question is about touchedNodWithLocationInView. Did i change it properly?

If you want to use in landscape mode only,
I think you don't need to modify touchedNodeWithLocationInView method.
You can you use in landscape mode to setup like below:

  • Sets Device Orientation of Deployment Info to LandscapeLeft or LandscapeRight.
  • Prepare VuforiaManager like this:
    swift vuforiaManager?.prepare(with: .landscapeLeft)

Otherwise, you might need to modify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants