Extending Vive Trackers Functionality in UE4 Editor

Yuri
6 min readNov 20, 2020

Hey,

I am YuriNK, developer of the ViveMocapKit — UE4 plugin for full-body mocap. A lot of customers use it to capture animation (rather than real-time avatars), so I provide a ViveMocap project, ready to calibrate a player to Vive Trackers and easily switch between different skeletal meshes.

There are some bugs in the SteamVR module in UE4. So ViveMocap project contains a small helper plugin SteamVRTrackingLib to fix mapping between internal SteamVR IDs of tracked devices and UE4 “Motion Sources”. SteamVRTrackingLib also has a class to enable Vive Trackers and controllers in the editor viewport in editing mode (i.e. not in simulation).

Recently I got a few requests for a full-body mocap in viewport. To do that, I modified the SteamVRTrackingLib plugin. Now it provides three features:

  • Tracking Vive Trackers and motion controllers in UE4 editor viewport (in editing mode);
  • Custom static names for tracked devices associated with serial numbers to support more then 8 trackers in UE4;
  • Full-body motion capture in editor viewport.

As you can see, SteamVRTrackingLib now requires VMK for p.3 to work. But if you needed it for pp.1–2, you can find a free version is here.

Full-body mocap in editor is explained in this video. In this article I’d like to explain how to use other features.

Before that, I have a small tip for ViveMocapKit users. The plugin has two options to save and load body-to-trackers calibration. First is available via in-project startup menu, and it’s player-independent. To restore animation, player should be in T-pose to measure his/her height and arm span. Also, as SteamVR IDs aren’t static, this calibration looks for Vive Trackers closest to saved positions to rebuild associations. The seconds save/load option is intended for restoring calibration for the same player within the same session. It can be used to restore and activate motion capture when you need to respawn or load a new level.

Latest version of ViveMocap project automatically saves such instantaneous calibration data when you click “Save Calibration” to Saved/SaveGames/hmd_calibration_editor.sav or Saved/SaveGames/calibration_editor.sav. This means you can add or import a new map and your own player blueprint in ViveMocap demo project, then calibrate on default map, close it, open your map, quickly restore calibration in your player blueprint and continue work without a need to recreate calibration UI in your project.

The same process — but for editor viewport setup — is shown in the video above.

Loading quick calibration from file

Using Tracked Devices in the Editor Viewport

Find SteamVRTrackingLib/Blueprints/BP_EditorViveTrackersController blueprint which is a child of EditorSteamVRController class (i.e. you can create another implementation, and it makes sense in some cases).

BP_EditorViveTrackersController has pre-created Static Mesh components to represent trackers. To activate a Vive Tracker, which was turned on first, add a new line to “Tracked Objects”. Use “Special_1” (default UE4 motion source for first Vive Tracker) as key, select BP_EditorViveTrackersController actor itself and put name of the Static Mesh component to use. Then click “Update Objects List” and set “Is Enabled” checkbox.

Later, click “Update Objects List” to apply any changes in the “Tracked Objects”.

You can click “Hide Devices” and “Show Devices” to hide/show Device1–Device12 components.

In most cases, you need to update another object (for example, light source) rather than Static Mesh component representing Vive Tracker.

To do that, create your own actor blueprint and add a component (for example, Point Light) inside of this blueprint.

Note, this component shouldn’t be a root, because EditorSteamVRController updates location and rotation of the specified component relative to its parent component.

Then place an actor of this blueprint on level and select it in “Tracked Objects”.

Custom Names for Tracked Devices

IDs generated by SteamVR for tracked devices aren’t static (and “Motion Sources” in UE4 either). Any motion controller or Vive Tracker gets the next free ID after turning on. This isn’t very convenient if you use devices to track some real-world objects. For example, you need one tracker attached to a camera, another tracker on a light source and all other trackers free to use in full-body mocap.

SteamVRTrackingLib now allows users to create custom names for tracked devices associated with their serial numbers.

There are two ways to find a serial number for your device. First, you can open the SteamVR menu, then select Devices → Manage Vive Trackers → Press “Manage Vive Trackers” button.

Secondly, SteamVRTrackingLib has a blueprint to visualize serial numbers: SteamVRTrackingLib/Blueprints/BP_EditorViveTrackersShowSN. This is actually just another implementation of the EditorSteamVRController, but it has widgets with serial numbers for each tracked device.

Add it on level (it already has pre-defined “Tracked Objects”), click “Update Objects List”, then set “Is Enabled” and click “Update Serial Numbers”.

To create custom names, in Content Browser click Add New → Miscellaneous → Data Asset and select “SteamVR Tracking Setup”. Then double click on the created asset to open it.

SteamVRTrackingSetup is a list of SteamVR tracked devices with their serial numbers and associated names. Turn on your devices and click “Update Devices List”, then fill names for devices you need, and save the asset.

You can export SteamVRTrackingSetup to JSON file and reimport it from JSON file (right mouse click on an asset in Content Browser).

When starting your game, call the global function “Set SteamVR Tracking Setup” or “Load SteamVR Tracking Setup From File” to initialize custom names either from an asset or from a JSON file.

SteamVRTrackingLib supports two ways to use SteamVRTrackingSetup. In any blueprint instead of default Motion Controller components use SteamVR Tracked Device components. They’re very similar but have a “Tracked Device Name” property instead of “Motion Source”. Put a custom name from the active “SteamVR Tracking Setup” asset (or from a JSON file you used) in this field. “Tracked Device Name” actually can read default motion sources, so “Right”, “Left”, “Special_1” etc values would work as well.

Also, you can use these names in EditorSteamVRController (BP_EditorViveTrackersController) as shown below.

That’s all. I hope this plugin’ll help you to work with Vive Trackers in UE4.

--

--