Forum Discussion
sredburn
12 years agoHonored Guest
Finding the OVRCrosshair in 3D Space
Okay, so I have a problem where I need to get the OVRGUI Crosshair's position in 3D space so I can apply raycasting on it. I have dug through all of the Oculus scripts and cannot determine a way to calculate this.
I want to use the way the cursor is currently set up, ie, where it has a certain deadspace where it turns the player once it reaches a certain position in pixels. It is simple to calculate the crosshair when it is initially centered by calculating the forward direction of the centerAnchor. Unfortunately, I do not know how to calculate the offset on the crosshair since it is measured in 2D pixels on the plane instead of a vector3 coordinate in 3D space.
The code that creates the crosshair at the desired location is:
Anyone have any ideas on how to accomplish this? Thanks in advance.
I want to use the way the cursor is currently set up, ie, where it has a certain deadspace where it turns the player once it reaches a certain position in pixels. It is simple to calculate the crosshair when it is initially centered by calculating the forward direction of the centerAnchor. Unfortunately, I do not know how to calculate the offset on the crosshair since it is measured in 2D pixels on the plane instead of a vector3 coordinate in 3D space.
The code that creates the crosshair at the desired location is:
GUI.DrawTexture(new Rect(XL - (ImageCrosshair.width * 0.5f),
YL - (ImageCrosshair.height * 0.5f),
ImageCrosshair.width,
ImageCrosshair.height), ImageCrosshair);
Anyone have any ideas on how to accomplish this? Thanks in advance.
2 Replies
Replies have been turned off for this discussion
- vrdavebOculus StaffOVRCrosshair is not drawn in 3D space. It's drawn at the center of the screen for each eye, making it infinitely far away. So you could approximate its position as OVRCameraRig.centerEyeAnchor.position + 100f * OVRCameraRig.centerEyeAnchor.forward.
- sredburnHonored GuestOkay that actually answers a lot of questions about my playing around with it.
Although that helps, the issue I am having involves determining the GUI offset value. For example, when the cursor is moved while on-screen with GUI coordinates, it is changed from the center x,y - (640,400) to another value, say (540, 450) for example. When the cursor is offset from the center, I do not know how to approximate the position.
Any ideas on how I could attempt to do this?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 5 years ago
- 2 months ago
- 8 years ago