Forum Discussion
9of9
12 years agoExpert Protege
Getting IR Camera Transform
Just curious if anyone's poked around and found a way to get the transform for the IR camera in worldspace? It's the sort of thing that would be quite nice to have, similar to the way you can enable c...
9of9
12 years agoExpert Protege
Yay! At last, this works. It kinda sucks that the Unity integration doesn't seem to have any obvious methods for doing this - unlike UE4, for instance - but it's proven reasonably simple to add.
You'll want to create a function something like this one - I've included with the appropriate references so you can stick it into an arbitrary component, but it really makes the most sense for it to be part of OVRDevice.cs:
For the sake of convenience, I've also uploaded a hastily thrown-together .unitypackage with everything anyone else might need in order to set up a quick and effective viewCone, to show the user the bounds of the camera cone - or just to salvage for reusable code. To set it up with an OVRCameraController just stick the OVRHelper/ViewCone prefab as a child under the OVRCameraController in your scene/prefab and make sure its transform is properly zeroed out. Then add in the OVRCameraController component of its parent into the Camera Controller slot on the ViewCone's own OVRViewCone component.
The result will be that as you lean toward the outer boundaries of the camera's view cone, little squares will fade in when you get too close, indicating that it's a boundary. You can tweak the included material to change the colour, tiling and the distance at which they start to fade in.
The ViewCone script also includes by default mapping the Enter key and the 'A' button on the controller to resetting the view, which needs to trigger updating the ViewCone position.
The correct setup:

The expected result.
You should be able to grab the .unitypackage itself from here.
You'll want to create a function something like this one - I've included with the appropriate references so you can stick it into an arbitrary component, but it really makes the most sense for it to be part of OVRDevice.cs:
using OVR;
bool GetIRCamera(ref Vector3 position,
ref Quaternion rotation,
ref float cameraHFov,
ref float cameraVFov,
ref float cameraNearZ,
ref float cameraFarZ)
{
if (OVRDevice.HMD == null || !OVRDevice.SupportedPlatform)
return false;
ovrTrackingState ss = OVRDevice.HMD.GetTrackingState();
rotation = new Quaternion( ss.CameraPose.Orientation.x,
ss.CameraPose.Orientation.y,
ss.CameraPose.Orientation.z,
ss.CameraPose.Orientation.w);
position = new Vector3( ss.CameraPose.Position.x,
ss.CameraPose.Position.y,
ss.CameraPose.Position.z);
ovrHmdDesc desc = OVRDevice.HMD.GetDesc();
cameraHFov = desc.CameraFrustumHFovInRadians;
cameraVFov = desc.CameraFrustumVFovInRadians;
cameraNearZ = desc.CameraFrustumNearZInMeters;
cameraFarZ = desc.CameraFrustumFarZInMeters;
OVRDevice.OrientSensor (ref rotation);
return true;
}
For the sake of convenience, I've also uploaded a hastily thrown-together .unitypackage with everything anyone else might need in order to set up a quick and effective viewCone, to show the user the bounds of the camera cone - or just to salvage for reusable code. To set it up with an OVRCameraController just stick the OVRHelper/ViewCone prefab as a child under the OVRCameraController in your scene/prefab and make sure its transform is properly zeroed out. Then add in the OVRCameraController component of its parent into the Camera Controller slot on the ViewCone's own OVRViewCone component.
The result will be that as you lean toward the outer boundaries of the camera's view cone, little squares will fade in when you get too close, indicating that it's a boundary. You can tweak the included material to change the colour, tiling and the distance at which they start to fade in.
The ViewCone script also includes by default mapping the Enter key and the 'A' button on the controller to resetting the view, which needs to trigger updating the ViewCone position.
The correct setup:

The expected result.
You should be able to grab the .unitypackage itself from here.
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
- 7 months ago