Receiving optitrack data in Unity
This is documented by optitrack. You should be mostly interested by tracking rigid bodies, and maybe HMDs. We don't have the optitrack software for tracking skeletons.
Check the new C++ programs and Unity script to relay optitrack data towards unity. Especially useful when needing marker data in unity (see "gil_optitrack" at the bottom of the README.md).
Steps
In Motive
- Calibrate the cameras.
- Create one (or more) rigid bodies. In the Rigid Bodies pane, define an integer user data for each rigid body that you define: this integer is what you use to identify the rigid bodies in Unity.
- In the streaming pane, check that the network configuration is OK:
- the local interface must be set to the one connected to the white network switch next to the optitrack PC (address in 10.10.0.x)
- network type is multicast.
- Stream Ridid Body is true
- Broadcast frame data (top of the pane) is checked
In unity
- Open a project, and then in the windows explorer double-click the optitrack unity plugin. This imports the optitrack plugin into your unity project.
- Create an object in your scene (which could be an empty object), we will call it the "streaming client". Drag and drop the Optitrack/Script/OptitrackStreamingClient script from the optitrack plugin onto this new object.
- Set the network parameters of this script in unity's inspector:
- Connection type: multicast
- Local address: an adresse in 10.10.0.x. To get such an addresse on the client PC, connect its second ethernet card to the white network switch. After a few moment, the switch will provide such an address to the card. On the client PC, go to "Panneaux de configuration/Centre réseau et partage". You should see that one of the "Connexion au réseau local" does not have internet access: that's the one connected to the optitrack switch. Click on this connexion, and then on the "details..." button. Enter its IPv4 address in unity, it must be in the form 10.10.0.x. (e.g. 10.10.0.7).
- Server address: the address of the optitrack PC, as in step 3.1 "In Motive".
- Don't modify the other parameters
- Create an object that will move and rotate as the physical rigid body, for example a cube or a sphere.
- Make it a child of the previously created "streaming client" object
- Drag and drop the Optitrack/Script/OptitrackRigidBody script on this object and set its parameters:
- you can drag and drop the streamin client object on the "Streamin client" parameter, although this is optional.
- you must define the Rigid Body Id to match the user data value define in step 2 "In Motive".
Run your application, the object should reproduce the motion of the tracked physical object.