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

Portrait orientation support #1

Open
shaunsahdev opened this issue Nov 12, 2021 · 4 comments
Open

Portrait orientation support #1

shaunsahdev opened this issue Nov 12, 2021 · 4 comments

Comments

@shaunsahdev
Copy link

Hi, this looks great! do you know why it only works in landscape-left orientation? Thanks.

@ibrahimpenekli
Copy link
Member

Hi @shaunsahdev thanks! As far as I remember, if the device rotates, depth and color image from device camera does not rotate. We should transform color and depth information of a point regarding to the device orientation. This is not a big deal to implement. If I had a spare time, I would have already implemented it :)

@tizmon
Copy link

tizmon commented Sep 20, 2022

You don't actually need to do those transformations. It is enough to just take the rotation into account when getting the world point. There might be something that I'm missing here, but it seems to work. E.g.:

switch (Screen.orientation) {
  case ScreenOrientation.Portrait:
    worldPoint = _mainCamera.ScreenToWorldPoint(new Vector3(Screen.width * npy, Screen.height * (1-npx), depth));
    break;
  case ScreenOrientation.LandscapeRight:
    worldPoint =_mainCamera.ScreenToWorldPoint(new Vector3(Screen.width * (1-npx), Screen.height * (1-npy), depth));
    break;
  default:
    // ScreenOrientation.LandscapeLeft
    worldPoint = _mainCamera.ScreenToWorldPoint(new Vector3(Screen.width * npx, Screen.height * npy, depth));
    break;
}

@ibrahimpenekli
Copy link
Member

You don't actually need to do those transformations. It is enough to just take the rotation into account when getting the world point. There might be something that I'm missing here, but it seems to work. E.g.:

switch (Screen.orientation) {
  case ScreenOrientation.Portrait:
    worldPoint = _mainCamera.ScreenToWorldPoint(new Vector3(Screen.width * npy, Screen.height * (1-npx), depth));
    break;
  case ScreenOrientation.LandscapeRight:
    worldPoint =_mainCamera.ScreenToWorldPoint(new Vector3(Screen.width * (1-npx), Screen.height * (1-npy), depth));
    break;
  default:
    // ScreenOrientation.LandscapeLeft
    worldPoint = _mainCamera.ScreenToWorldPoint(new Vector3(Screen.width * npx, Screen.height * npy, depth));
    break;
}

Thanks for code snippet. I meant this by saying 'transform color and depth information of a point regarding to the device orientation'.

@tizmon
Copy link

tizmon commented Sep 20, 2022

Thanks for code snippet. I meant this by saying 'transform color and depth information of a point regarding to the device orientation'.

Right 👍. I first thought it specifically meant rotating the XRCpuImages so they would match with the screen orientation. But of course it does not really matter if it is the screen coordinates that are rotated or the cpu images. Except that the latter would have been a lot more work.

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

3 participants