File tree Expand file tree Collapse file tree
OSVR-Unity/Assets/OSVRUnity/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,38 +19,17 @@ namespace Unity
1919 ///
2020 /// Attach to a GameObject that you'd like to have updated in this way.
2121 /// </summary>
22- public class PoseInterface : MonoBehaviour
22+ public class PoseInterface : InterfaceGameObject
2323 {
24- /// <summary>
25- /// The interface path you want to connect to.
26- /// </summary>
27- public string path ;
28-
29- private OSVR . ClientKit . Interface iface ;
30- private OSVR . ClientKit . PoseCallback cb ;
31-
32- void Start ( )
33- {
34- if ( 0 == path . Length )
35- {
36- Debug . LogError ( "Missing path for PoseInterface " + gameObject . name ) ;
37- return ;
38- }
39-
40- iface = OSVR . Unity . ClientKit . instance . context . getInterface ( path ) ;
41- cb = new OSVR . ClientKit . PoseCallback ( callback ) ;
42- iface . registerCallback ( cb , IntPtr . Zero ) ;
43- }
44-
45- private void callback ( IntPtr userdata , ref OSVR . ClientKit . TimeValue timestamp , ref OSVR . ClientKit . PoseReport report )
24+ new void Start ( )
4625 {
47- transform . localPosition = Math . ConvertPosition ( report . pose . translation ) ;
48- transform . localRotation = Math . ConvertOrientation ( report . pose . rotation ) ;
26+ osvrInterface . RegisterCallback ( callback ) ;
4927 }
5028
51- void OnDestroy ( )
29+ private void callback ( string source , Vector3 position , Quaternion rotation )
5230 {
53- iface = null ;
31+ transform . localPosition = position ;
32+ transform . localRotation = rotation ;
5433 }
5534 }
5635 }
You can’t perform that action at this time.
0 commit comments