Skip to content

Commit e056898

Browse files
committed
Supporting Flystick2+; Fixing github issue #3
1 parent 0dc2e62 commit e056898

17 files changed

Lines changed: 478 additions & 302 deletions

CHANGELOG.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11

2-
# List of Unity DTrack plugin releases
2+
# List of Unity DTrack Plugin releases
33

4-
## v1.0.0 (2020-25-02)
4+
## v1.0.3 (2022-05-13)
55

6-
- Initial release for Unity v2019.1.0f2
7-
- Supports 6DoF targets (6d), Flysticks 2 and 3 (6df2)
6+
- Supports additional Flystick2+ buttons and trigger
7+
- Fixing Flystick parsing error (cf. GitHub issue #3)
8+
9+
## v1.0.2 (2020-07-28)
10+
11+
- Fixing locale issue (cf. GitHub issue #1)
12+
- Fixing incorrect accessor (cf. GitHub issue #2)
13+
14+
## v1.0.0 (2020-02-25)
15+
16+
- Initial release for Unity 2019.1.0f2 or later
17+
- Supports 6DOF standard targets (6d), Flysticks (6df2)
818

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019, Advanced Realtime Tracking GmbH
1+
Copyright (c) 2019-2022 Advanced Realtime Tracking GmbH & Co. KG
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
# DTrack Plugin for the Unity Game Engine 2019.x
1+
# DTrack Plugin for Unity Game Engine 2019.x or later
22

33
This is a component for Unity 2019.1 or later with the purpose of
44
native integration of the Advanded Realtime Tracking (ART) DTrack
5-
(versions 2 and 3) tracking solutions. This Unity Asset provides
5+
(DTrack2 or DTrack3) tracking solutions. This Unity Asset provides
66
access to DTrack tracking data, that is send over network using
77
UDP/IP datagrams. Each UDP packet contains one frame of tracking
88
data including all outputs activated via the DTrack software (see
99
Section [**DTrack**](#DTrackShortGuide)). This package currently
10-
supports the DTrack body `6d` and flystick `6df2` data formats.
10+
supports the DTrack standard body `6d` and Flystick `6df2` data formats.
1111

1212
## Download <a name="download"></a>
1313

1414
You can download or clone sources for this Asset package at
15-
[GitHub](http://github.com/ar-tracking/UnityDTrackPlugin)
15+
[GitHub](http://github.com/ar-tracking/UnityDTrackPlugin).
16+
17+
You can download a ready-to-use Unity package ( UnityDTrackPlugin-vX.X.X.unitypackage ) at
18+
[GitHub releases](http://github.com/ar-tracking/UnityDTrackPlugin/releases).
1619

1720
## Prerequisites
1821

19-
To use this Asset the following components are required.
22+
To use this Asset the following components are required:
2023

2124
- Unity Editor 2019.1 or later
2225
- Windows 64 bit, Linux 64 bit
@@ -30,6 +33,9 @@ To use this Asset the following components are required.
3033
In order to create a Unity package from the provided sources, follow
3134
the steps below.
3235

36+
If you downloaded a ready-to-use Unity package ( UnityDTrackPlugin-vX.X.X.unitypackage ),
37+
proceed with [**Importing Unity package**](#importing).
38+
3339
1. Download or clone sources for this Asset package ( see [**Download**](#download) )
3440
- Launch Unity
3541
- Create new Unity project ( e.g., "MyUnityProject" )
@@ -38,22 +44,25 @@ the steps below.
3844
- Export package ( right-click on DTrack in the **Project** window and
3945
select **Export Package...** )
4046

41-
### Importing Unity package
47+
**Please note:** if you created the Unity package from sources and you want to try the available example scene,
48+
you need to assign DTrack scripts and to configure the plugin manually ( see [**Plugin Configuration**](#pluginconfiguration) ).
49+
50+
### Importing Unity package <a name="importing"></a>
4251

4352
1. Launch Unity
4453
- Create/Open Unity project
4554
- Import package ( *Assets* &rarr; *Import Package...* &rarr; *Custom Package...* )
4655

56+
4757
## DTrack Configuration
4858

4959
Find here a quick-start guide to DTrack. For details, please, refer
5060
to your DTrack User's Guide and DTrack Programmer's Guide, that is
5161
shipped with the DTrack distribution. In this section we assume that
5262
the ART tracking system is properly set up and a room calibration
53-
was done. Further, a set of 6DOF targets and flysticks are
63+
was done. Further, a set of 6DOF targets and/or Flysticks are
5464
calibrated.
5565

56-
5766
### Room Calibration
5867

5968
For general information about the DTrack room calibration and room
@@ -89,14 +98,11 @@ and Z axes, i.e.,<br>
8998
![Figure: DTrack and Unity coordinate systems](Doc/images/dtrack-vs-unity.png)
9099
<br><br>
91100

92-
93101
DTrack offers a multitude of ways to adjust coordinate systems for
94102
room and bodies, e.g., offsets, scaling, additional rotations, or
95103
shifting the origin of bodies. Consult your manual for details on
96104
*Room adjustment* and *Body adjustment*.
97105

98-
99-
100106
### Setting outputs <a name="DTrackSettingOutputs"></a>
101107

102108
To configure the tracking data stream generated by DTrack, execute
@@ -105,14 +111,13 @@ these steps:
105111
1. Activate a channel if needed
106112
- Fill in the IP/Port of the device receiving tracking data
107113
- Select outputs you are interested in (i.e., currently frame counter `fr`,
108-
time stamp `ts`, 6DOF standard body `6d` and flystick `6df2` are
114+
6DOF standard body `6d` and Flystick `6df2` are
109115
supported) via the menu *Tracking* &rarr; *Output* (DTrack3) or *Settings*
110116
&rarr; *Output* (DTrack2), respectively.
111117

112118
![Figure: DTrack output dialog](Doc/images/dtrack-output.png)
113119
<br><br>
114120

115-
116121
### Data display ( 6DOF ) <a name="DTrackDataDisplay6DOF"></a>
117122

118123
Enable the *data display* view ( *View* &rarr; *Data* ) to find
@@ -123,22 +128,20 @@ tracking volume.
123128
![Figure: DTrack data display body](Doc/images/dtrack-data-body.png)
124129
<br><br>
125130

126-
127131
### Data display ( Flystick ) <a name="DTrackDataDisplayFlystick"></a>
128132

129-
Enable the *flystick* view ( *View* &rarr; *Flystick* ) to find
130-
assigned flystick IDs. Listed flystick IDs are prefixed with a
131-
capital **`F`**. When referencing flysticks from within Unity in the
133+
Enable the *Flystick* view ( *View* &rarr; *Flystick* ) to find
134+
assigned Flystick IDs. Listed Flystick IDs are prefixed with a
135+
capital **`F`**. When referencing Flysticks from within Unity in the
132136
`DTrackReceiverFlystick` mask, this prefix must be removed. In addition to
133-
position and rotation data, button presses (_b1_,...,_b6_), joystick movement
134-
(_jx_,_jy_) are illustrated in the table.
137+
position and rotation data, button presses (_b1_,...,_b8_), joystick movement
138+
(_jx_,_jy_) and trigger (_jt_) are illustrated in the table.
135139

136140
![Figure: DTrack data display flystick](Doc/images/dtrack-data-flystick.png)
137141
<br><br>
138142

139143

140-
141-
## Plugin Configuration
144+
## Plugin Configuration <a name="pluginconfiguration"></a>
142145

143146
Streaming position, rotation and button events data from DTrack
144147
tracking systems to objects in your scene, requires appropriate
@@ -147,7 +150,7 @@ it a name, e.g., **DTrackSource**. To this object attach the
147150
**DTrack** script via *Add Component* &rarr; *Scripts* &rarr;
148151
*DTrack* &rarr; *DTrack*. Set *Listen Port* number matching the
149152
setting for DTrack (see Section [**Setting outputs**](#DTrackSettingOutputs)
150-
below). Note that 3D position data in the DTrack output stream have unit
153+
below). Note that 3DOF position data in the DTrack output stream have unit
151154
millimeters. The DTrack Unity Plugin converts such values to unit meter.
152155

153156
![Figure: Unity DTrackSource inspector](Doc/images/unity-dtrack-source.png)
@@ -174,18 +177,17 @@ In your scene attach via *Add Component* the DTrack script
174177
`DTrackReceiverFlystick` to an object you want to receive positional
175178
and rotational data as well as interactive button and joystick
176179
events. In the `DTrackReceiverFlystick` mask type in the ID that was
177-
assigned to the flystick by DTrack
180+
assigned to the Flystick by DTrack
178181
(see Section [**Data display (Flysticks)**](#DTrackDataDisplayFlystick)).
179182

180183
![Figure: Unity Flystick inspector](Doc/images/unity-dtrack-flystick.png)
181184
<br><br>
182185

183-
184186
### Attaching 6DOF Targets to Camera
185187

186188
For non-static, point-of-view cameras, you can attach a DTrack
187189
Receiver with positional and rotational data, e.g., 6DOF body or
188-
flystick.
190+
Flystick.
189191

190192
![Figure: Unity POV Camera inspector](Doc/images/unity-dtrack-pov.png)
191193
<br><br>

Scenes/DTrackExample.unity

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Transform:
370370
m_PrefabAsset: {fileID: 0}
371371
m_GameObject: {fileID: 534669902}
372372
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
373-
m_LocalPosition: {x: 0, y: 2, z: -10}
373+
m_LocalPosition: {x: 0, y: 1, z: -1}
374374
m_LocalScale: {x: 1, y: 1, z: 1}
375375
m_Children: []
376376
m_Father: {fileID: 0}
@@ -487,8 +487,8 @@ Transform:
487487
m_PrefabAsset: {fileID: 0}
488488
m_GameObject: {fileID: 788681089}
489489
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
490-
m_LocalPosition: {x: 0, y: 0, z: 0}
491-
m_LocalScale: {x: 95, y: 95, z: 95}
490+
m_LocalPosition: {x: -0.2, y: 0.8, z: 0}
491+
m_LocalScale: {x: 0.095, y: 0.095, z: 0.095}
492492
m_Children:
493493
- {fileID: 384705472}
494494
m_Father: {fileID: 0}
@@ -596,8 +596,8 @@ Transform:
596596
m_PrefabAsset: {fileID: 0}
597597
m_GameObject: {fileID: 832688257}
598598
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
599-
m_LocalPosition: {x: 0, y: 0, z: 0}
600-
m_LocalScale: {x: 75, y: 95, z: 75}
599+
m_LocalPosition: {x: 0, y: 1.2, z: 0}
600+
m_LocalScale: {x: 0.075, y: 0.095, z: 0.075}
601601
m_Children: []
602602
m_Father: {fileID: 0}
603603
m_RootOrder: 4
@@ -704,8 +704,8 @@ Transform:
704704
m_PrefabAsset: {fileID: 0}
705705
m_GameObject: {fileID: 1467775502}
706706
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
707-
m_LocalPosition: {x: 0, y: 0, z: 0}
708-
m_LocalScale: {x: 100, y: 100, z: 100}
707+
m_LocalPosition: {x: 0, y: 1, z: 0}
708+
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
709709
m_Children: []
710710
m_Father: {fileID: 0}
711711
m_RootOrder: 3
@@ -957,8 +957,8 @@ Transform:
957957
m_PrefabAsset: {fileID: 0}
958958
m_GameObject: {fileID: 1860915836}
959959
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
960-
m_LocalPosition: {x: 0, y: 0, z: 0}
961-
m_LocalScale: {x: 125, y: 125, z: 125}
960+
m_LocalPosition: {x: 0.2, y: 0.8, z: 0}
961+
m_LocalScale: {x: 0.125, y: 0.125, z: 0.125}
962962
m_Children:
963963
- {fileID: 1610434898}
964964
m_Father: {fileID: 0}

Source/DTrack.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
/* Copyright (c) 2019, Advanced Realtime Tracking GmbH
1+
/* Unity DTrack Plugin: script DTrack
2+
*
3+
* Main script providing DTrack tracking data to Unity
4+
*
5+
* Copyright (c) 2019-2022 Advanced Realtime Tracking GmbH & Co. KG
26
*
37
* Redistribution and use in source and binary forms, with or without
48
* modification, are permitted provided that the following conditions are met:
@@ -36,15 +40,15 @@
3640

3741
namespace DTrack
3842
{
43+
44+
3945
public class DTrack : MonoBehaviour
4046
{
4147
[Tooltip("Port for incoming DTrack tracking data")]
4248
public int listenPort = 5000;
4349
[Tooltip("Game objects receiving tracking data from DTrack")]
4450
public GameObject[] receivers = new GameObject[0];
4551

46-
//public Axis axis = Axis.XZY;
47-
4852
private IPEndPoint _endPoint;
4953
private UdpClient _client;
5054
private Thread _thread;
@@ -55,8 +59,6 @@ public class DTrack : MonoBehaviour
5559

5660
void Start()
5761
{
58-
//usedAxis = this.axis;
59-
6062
_endPoint = new IPEndPoint(IPAddress.Any, listenPort);
6163

6264
_client = new UdpClient(_endPoint);
@@ -68,7 +70,6 @@ void Start()
6870
{
6971
var result = await _client.ReceiveAsync();
7072
var rawString = Encoding.UTF8.GetString(result.Buffer);
71-
//usedAxis = this.axis;
7273
var packet = RawParser.Parse(rawString);
7374
_currentPacket = packet;
7475
}
@@ -86,16 +87,16 @@ void Start()
8687

8788
public void RegisterTarget(GameObject obj)
8889
{
89-
var objs = new List<GameObject>(receivers);
90+
var objs = new List< GameObject >( this.receivers );
9091
objs.Add(obj);
91-
receivers = objs.ToArray();
92+
this.receivers = objs.ToArray();
9293
}
9394

9495
public void UnregisterTarget(GameObject obj)
9596
{
96-
var objs = new List<GameObject>(receivers);
97+
var objs = new List< GameObject >( this.receivers );
9798
objs.Remove(obj);
98-
receivers = objs.ToArray();
99+
this.receivers = objs.ToArray();
99100
}
100101

101102
void OnDestroy()
@@ -110,11 +111,11 @@ void FixedUpdate()
110111
{
111112
if (_currentPacket != null)
112113
{
113-
foreach (var i in receivers)
114+
foreach ( var receiver in this.receivers )
114115
{
115116
try
116117
{
117-
i.GetComponent<IDTrackReceiver>().ReceiveDTrackPacket(_currentPacket);
118+
receiver.GetComponent< IDTrackReceiver >().ReceiveDTrackPacket( _currentPacket );
118119
}
119120
catch (Exception e)
120121
{
@@ -124,4 +125,7 @@ void FixedUpdate()
124125
}
125126
}
126127
}
127-
}
128+
129+
130+
} // namespace DTrack
131+

Source/DataObjects/Interfaces/IEulerRotationProvider.cs renamed to Source/DTrackReceiver.cs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
/* Copyright (c) 2019, Advanced Realtime Tracking GmbH
1+
/* Unity DTrack Plugin: script DTrackReceiver
2+
*
3+
* Abstract class to provide DTrack tracking data to a Game Object
4+
*
5+
* Copyright (c) 2020-2022 Advanced Realtime Tracking GmbH & Co. KG
26
*
37
* Redistribution and use in source and binary forms, with or without
48
* modification, are permitted provided that the following conditions are met:
@@ -25,12 +29,35 @@
2529
*/
2630

2731
using UnityEngine;
32+
using DTrack.DataObjects;
2833

29-
namespace DTrack.DataObjects.Interfaces
34+
namespace DTrack
3035
{
31-
public interface IEulerRotationProvider
32-
{
33-
// ReSharper disable once UnusedMember.Global
34-
Vector3 GetEulerRotation();
35-
}
36+
37+
38+
public abstract class DTrackReceiver : MonoBehaviour, IDTrackReceiver
39+
{
40+
/* DTrack object this receiver is associated to */
41+
private DTrack _source = null;
42+
43+
public abstract void ReceiveDTrackPacket( Packet packet );
44+
45+
public void Register()
46+
{
47+
var dtracksource = FindObjectOfType< DTrack >();
48+
dtracksource.RegisterTarget( this.gameObject );
49+
this._source = dtracksource;
50+
}
51+
52+
public void Unregister()
53+
{
54+
if ( this._source != null )
55+
{
56+
this._source.UnregisterTarget( this.gameObject );
57+
}
58+
}
3659
}
60+
61+
62+
} // namespace DTrack
63+

0 commit comments

Comments
 (0)