Log in or register to post comments

Raycasting for Two Camera AR

July 27, 2015 - 3:23am #1

Vuforia 4.2.3

Unity 5.1.1

Epson BT 200 (Moverio)

hey guys,

There are two interrelated issues I am experiencing at the moment working with a stereo AR camera.

Both the issues are absent when I switch to monocamera (in the AR camera object).

[A] Getting world points corresponding to a screen point.

I have a Camera object which I set to the main camera i.e., (both the left and right cams are tagged "MainCamera" btw, so not sure which one comes into play)

Camera mainC= Camera.main;

Then I try to get the world point corresponding to some screen point (center of the screen as an example)...

Vector3 screenCenter = new Vector3 (Screen.width / 2.0f, Screen.height / 2.0f, mainC.nearClipPlane+80.0f);
//Problem here.
Vector3 worldCenter = mainC.ScreenToWorldPoint (screenCenter);

I then try to set an object at this point,

public GameObject someObject; //Set externally.
someObject.transform.position= worldCenter;

At this point I should be able to see the object in the display, and I do see it using a mono AR cam. However if I switch to Stereo, it's not in the cam frustum.

[B] Raycasting from a screen point.

Needless to say, if I try to cast a ray from the screen point (center of the screen as an example) it does not hit an object sitting bang in the middle of the screen (again, works fine in mono AR cam).

Extra information: In the context of [A] I tried to move the object progressively away from the camera (by setting the Z component of screenCenter variable to 4.0f*Time.time.

With a mono AR cam, the object kept getting farther and farther away staying at the center of the screen, as it should. But in the case of the stereo camera version, it actually went across the display starting from the upper right hand corner and moving towards the left. Coincidentally (or so I think) the upper right hand corner is where the device camera is.

Any help appreciated!



Log in or register to post comments