XRC Alignment Tool
Overview
This script provides an example for aligning virtual and real cordinate systems. This can be useful for remote XR experiences where it is important to have content align in a certain way. It is also useful for colocated experiences where multiple users align their world cordinates to a common origin so that avatars and interactalbes share a common space.
The package video can be viewed here.
Components
Alignment
The Alignment component is responsible for creating a horizontal, vertical, or freeform surfaces. The script allows the user to interactively place three points to create a quad that represents the alignment. The quad is used to determine the position and orientation (pose) of a virtual object in the scene.
If you wish to use a Horizontal Plane for alignment, make sure you have the Horizontal Plane
selected and are also using a Horizontal Marker. Make sure you assign references to the Rig transform and the Target transform. If using a Vertical Plane
make sure the Target transform is referencing a Vertical marker. This script requires Alignment Input component to handle user input. Make sure to add both of these components on the same GameObject.
Property | Description |
---|---|
Rig Transform | XR Rig transform, typically the XR Origin . |
Target Transform | The transform of the virtual object you will be aligning the XR Rig to. |
Cursor Transform | Cursor transform used to mark the alignment points. |
Current Alignment | An enum with options for Horizontal Plane , Vertical Plane , and FreeForm . |
Alignment Input
Alignment Input is responsible for assigning Input Action References for Create Plane Action, Confirm Create Plane, and Cancel Create Plane Action..
Property | Description |
---|---|
Create Plane Action | The Input Action Reference starting the calibration process. |
Confirm Alignment Action | The Input Action Reference used for confirming the alignment. You can also confirm using UI. |
Cancel Alignment Action | The Input Action Reference used for canceling the alignment. |
Alignment Feedback
The Alignment Feedback component handles the visual feedback for the alignment tool. This includes placing spheres at each point for the corners of the quad, a LineRenderer between the first two points, and a quad from the first 3 points. Alignment Feedback uses events (OnUpdatePoseMarker, OnUpdateLineRenderer, OnUpdateIndicator, and OnAddDebugSphere) to provide visual feedback to the user. The prefabs in this script can be swapped or this script can be extended to change the visual feedback.
Ensure that the m_QuadMaterial
is set to a Material with appropriate transparency settings to achieve a visually transparent effect for the generated quad.
Property | Description |
---|---|
Indicator Prefab | The prefab used for the cursor. |
Indicator Prefab | The prefab used for the cursor. |
Pose Marker Prefab | The prefab used for the Pose Marker to indicate the aligned world coordinates. |
Quad Material | The material used for the generated alignment marker. |
Draw Debug Spheres | Flag to toggle the debug spheres on/off. |
Installation instructions
Package Manager
Note
Before you install this package, you would need to install edu.cornell.xrc.core. Follow these installation instructions to fulfill this dependency. To install this package, follow these steps:
- In the Unity Editor, click on Window > Package Manager
- Click the + button and choose Add package from git URL option
- Paste this URL https://github.com/xrcollaboratory/edu.cornell.xrc.tools.alignment.git in the prompt and click on Add
- You might have to authenticate as this is a private repository
- The package should be installed into your project
- You can download Samples from under Samples
Requirements
This version of XRC Alignment Tool Tool is compatible with the following versions of the Unity Editor:
- 2022.4.7f1 LTS
Dependencies:
Samples
The package comes with a number of samples which can be installed directly from the Package Manager (from Unity's main menu, go to Window > Package Manager). Select the XRC Alignment Tool, then click Import next to a sample to copy it into the current project.
Sample | Description |
---|---|
XRC Alignment Tool | A basic XR scene setup with a alignment Tool. All the input and feedback is already configured. |
Notes
There is also an optional script called AlignmentMenu
on the Canvas that handles alignment confirmation.
Depending on the logic of your application, you may want to disalbe the Alignment object once the XR Rig has been aligned.
Passthrough
Passthrough depends on the OVR Camera Rig. To keep this package simple, we have not included this in our samples package, however, it is easy to setup on your own.
You will need to import Oculus Integration which can be found here. https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022
We have a Wiki page how to do this up here.
https://github.com/xrcollaboratory/xrc/wiki/Guides#combining-ovr-passthrough-with-xri-player-rig