Search Unity

How to get coordinates of viewport corners?

Discussion in 'AR/VR (XR) Discussion' started by khg2478, Dec 17, 2017.

  1. khg2478

    khg2478

    Joined:
    Dec 10, 2017
    Posts:
    6
    Hi. I am working on a 360 video related project which uses HTC-Vive.

    I want to get the current coordinates of viewport corners. An example is drawn below.

    upload_2017-12-17_21-8-53.png

    I was able to extract Yaw, Pitch, and Roll by accessing "Camera.main.transform.rotation.eulerAngles.y" and when I move the HTC-Vive headset, it seems to work properly.

    However, I am not sure how I can get the current coordinates of viewport corners as I mentioned above.

    It seems that "Vector3 v3 = Camera.main.ViewportToScreenPoint(new Vector3(0, 0, 0));" can be used to extract the point in the above picture (30,30) but it gives nothing now.

    Any ideas?

    Thank you.
     
  2. BrandonFogerty

    BrandonFogerty

    Joined:
    Jan 29, 2016
    Posts:
    83
    Last edited: Dec 20, 2017
    khg2478 likes this.
  3. khg2478

    khg2478

    Joined:
    Dec 10, 2017
    Posts:
    6
    Hi @BrandonFogerty,

    I am new to Unity and figured out that I misunderstood the concept of viewport, screen, and world.

    My question was in fact there will be other ways to match a point of pixel coordinates in screen to a point in original equirectangular photo. This information is important to me because my research is related to gaze position of users.

    Do you have any recommendations to this matter in the circumstance of Unity environment?

    Thank you.