Understand Vicon plugin components
This section describes the different elements that are included in the Vicon Unity plugin, so you can better understand what they do and when to use them.
The plugin is organized into folders to separate the different components, as shown in the Unity Project window this image.
This section contains information on each of these folders and their components:
Materials
The Materials folder contains the basic materials used by the GameObjects in the sample scenes.
In your project, you don't need to change or edit any of these materials - these examples are primarily for demonstration purposes.
Plugins
ThePluginsfolder contains Vicon Datastream libraries and dependencies that the Vicon VR for Unity plugin uses to stream subjects and headsets to Unity software.
The scripts use these plugins to add streaming functionality to the plugin.
In your project, you don't need to change or edit any of these plugins.
Prefab
The Prefab folder contains pre-built GameObjects with scripts attached.
Use these prefabs to quickly set up your project.
HMDPrefab
This prefab is an empty GameObject with Camera and Pose Provider child objects.
Use the HMDPrefab to quickly set up head-mounted displays (HMDs) in your Unity project.
Use the Camera object to capture an area of the Unity scene to send to the HMD.
The Pose Provider contains the HMDScript component, which connects the Unity GameObject to the HMD object in Vicon. For more detailed information on how this works, see the description of the HMDScript.
In your project, you don't need to use this prefab. To use an HMD without this prefab, create your own HMD GameObject with both a Camera and an HMDScript component.
Note
The HMD Script only works in projects that have been successfully set up in VR. See Set Up Unity for Virtual Reality for more information.
ViconDataStreamPrefab
This prefab is an empty GameObject that contains the Vicon Data Stream Client script component.
Use this prefab to quickly connect your Unity project to the Vicon Data Stream server as a client. For more detailed information on how this works, see the description of the Vicon Data Stream Client script.
Each of the provided sample Scenes has an instance of the ViconDataStreamPrefab already.
In your project, you don't need to use this prefab. To use the Vicon plugin without this prefab, create your own custom DataStream GameObject with a ViconDataStreamClient component and add it to every scene.
PropMeshes
The PropMeshes folder contains four example prop meshes to help you start adding props to your Unity project; a flashlight, a katana, a raygun, and a Vicon Pulsar.
These are all single-segment props, so work with the SubjectScript rather than the RBScript.
Use these to quickly see your motion capture props as virtual representations in your Unity project.
In your project, you can use these meshes or your own custom prop meshes.
Scenes
The Scenes folder contains two example scenes, pre-filled with GameObjects and prefabs.
Use the example scenes to quickly set up your Unity project to communicate with your Vicon software.
In your project, you can expand these scenes as needed, or use them as a reference to set up new or existing scenes to work with the plugin.
ViconSubjectScriptExample
This scene demonstrates how to use the Vicon plugin with a subject.
There is an instance of the ViconDataStreamPrefab in the scene to create the client connection.
There is a single character model in the scene, with the SubjectScript already attached.
Use this scene to quickly test the connection between your Vicon software and your Unity project:
- Start capturing a subject's movement in Vicon.
- Enter the Host Name and Port in the ViconDataStreamPrefab.
- Enter the Subject Name in the SubjectScript on the character model.
- Select play to see the animation information translated onto the Unity mesh.
For more thorough documentation on streaming data from a subject to Unity with any assets or project, see Stream data from a full body and retarget to a mesh in Unity.
ViconHMDScriptExample
This scene demonstrates how to use the Vicon VR plugin with a head-mounted display (HMD).
The scene includes a basic arrangement of models to explore.
The scene had an instance of the ViconDataStreamPrefab to create the client connection.
The scene also includes a HMDPrefab GameObject ready for use with a headset.
Use this scene to quickly test the connection between an HMD, Vicon software, and your Unity project:
- Create an HMD object in Vicon and enter the capture volume.
- Enter the Host Name and Port in the ViconDataStreamPrefab.
- Enter the HMD Name in the HMDScript on the HMDPrefab.
- Select play to look around the Unity scene with the HMD.
For more thorough documentation on streaming data between an HMD and Unity with any assets or project, see Use a head-mounted display.
Scripts
The Scripts folder contains scripts that set up communication between the plugin and your Vicon software.
In your project, add these scripts to your GameObjects to set them up to work with your Vicon software.
HMDScript
This script combines the head-mounted display (HMD) inertial movement unit (IMU) data with the Vicon positional data. This means that the XR plugin in Unity can access the position, rotation, and acceleration information of the headset and apply it to the HMD GameObject in the Scene.
When you add the HMDScript to a GameObject as a component, it has the following public fields:
Field Name | Type | Description |
---|---|---|
HMD Name | string | Set the name of the HMD here. It should match the HMD name in your Vicon software. |
Client | ViconDataStreamClient | Set the Vicon Data Stream Client here. There should be one instance of the ViconDataStreamPrefab in the Scene, which you can drag and drop into this field. |
Log | checkbox | Select this option to produce log files in .csv format in the <project root>/Assets/Logs folder. |
Both the HMD Name and Client fields need to be correctly populated for the HMDScript to work as expected.
In your project, you can choose to add this component directly to your own custom HMD GameObject, rather than using the provided HMDPrefab. Your HMD GameObject must be set up with the same structure as the HMDPrefab, including a child object with a Camera attached, for this script to work.
RBScript
This script streams Vicon data onto a GameObject that is not rigged and does not contain any segment bones, such as a cube.
When you add the RBScript to a GameObject as a component, it has the following public fields:
Field Name | Type | Description |
---|---|---|
Object Name | string | Set the name of the object here. It should match the object name in your Vicon software. |
Client | ViconDataStreamClient | Set the Vicon Data Stream Client here. There should be one instance of the ViconDataStreamPrefab in the Scene, which you can drag and drop into this field. |
Both the Object Name and Client fields need to be correctly populated for the RBScript to work as expected.
In your project, add this component to simple GameObjects to create a link with Vicon mocap data.
Use RBScript and non-skeletal objects sparingly
We recommend you only use RBScript and non-skeletal objects sparingly. For best results, use a skeletal prop with SubjectScript; this includes single-segment props, such as those included in the PropMeshes folder.
SubjectScript
This script streams Vicon data onto a rigged skeleton. This includes single-segment props, such as those included in the PropMeshes folder.
When you add the SubjectScript to a GameObject as a component, it has the following public fields:
Field Name | Type | Description |
---|---|---|
Subject Name | string | Set the name of the subject here. It should match the subject name in your Vicon software. |
Client | ViconDataStreamClient | Set the Vicon Data Stream Client here. There should be one instance of the ViconDataStreamPrefab in the Scene, which you can drag and drop into this field. |
Both theSubject Name and Client fields need to be correctly populated for the SubjectScript to work as expected.
In your project, add this component to GameObjects with rigged skeletons to create a link with Vicon mocap data.
ViconDataStreamClient
This script connects your Unity project to the Vicon Data Stream server as a client.
When you add the SubjectScript to a GameObject as a component, it has the following public fields:
Field Name | Type | Description |
---|---|---|
Host name | string | Set the IP address or hostname of the Vicon application server PC. See more information on how to connect 2 servers with a multi-route connection. |
Port | string | Set the port number to 801 or 804 according to the Vicon software you are using:
|
Subject Filter | string | To reduce the amount of data sent over the network, you can set up a Subject Filter so only data from named Subjects is passed from the Vicon datastream to Unity. To set up the filter, enter one or more subject names, separated by commas. |
Use Pre Fetch | checkbox | If WiFi performance is poor and a multi-route connection is not possible, use pre-fetch to reduce the effects of latency spikes. When this option is selected, the client can pre-request a frame of data, rather than having data continually pushed to the client. |
Is Retimed | checkbox | Select this option to provide subject data at a different rate from the Vicon system rate, to match that of the engine. It does this via interpolation and forward prediction of samples. When used with unstable and unpredictable WiFi connections, it can cause erratic behavior. Ensure your connection is stable. If tracking is not consistent across the volume, it can also cause problems with poor data quality. Ensure tracking is good across the volume. |
Offset | float | If Is Retimed is selected, use this field to specify (in milliseconds) the amount of prediction that the retiming client will use, dependent on latency time from the Vicon server to the client application. 0-3 ms is recommended (the default is 0.0). |
Log | checkbox | Select this option to produce log files in .csv format in the <project root>/Assets/Logs folder. |
Configure Wireless | checkbox | Select this option to optimize the onboard wireless adapter during Datastream connection. |
Both the Host Name and Portfields need to be correctly populated for the ViconDataStreamClient to work as expected. The other fields are optional and don't need to be populated.
In your project, you can choose to add this component directly to your own custom version of a ViconDataStream GameObject, rather than using the provided ViconDataStreamPrefab.
ViconSkins
The ViconSkins folder contains example full-body meshes and skins to help you start setting up full-body motion capture in your Unity project.
Use these to quickly see your motion capture subjects as virtual representations in your Unity project.
The folder contains six meshes you can use, each suitable for a different marker set or subject type.
Two skins are in separate folders - ViconFemaleEvoke.fbm and ViconMaleEvoke.fbm. You can add these to any of the provided meshes to change their appearance.
In your project, you can use these meshes and skins or your own custom subject versions.
In Shogun 1.7, Vicon changed the default solve skeleton to be more in line with industry practice.
This means that if you try and use old mocap footage with an updated skeleton in Unity, or new mocap footage with an outdated skeleton in Unity, the Unity mesh will be distorted.
The meshes included in the plugin use the outdated skeleton.
See Troubleshoot common issues for options to resolve this issue.