예제 #1
0
        void Update()
        {
            var skeleton = RTClient.GetInstance().GetSkeleton(SkeletonName);

            if (mQtmSkeletonCache != skeleton)
            {
                mQtmSkeletonCache = skeleton;

                if (mQtmSkeletonCache == null)
                {
                    return;
                }

                CreateMecanimToQtmSegmentNames(SkeletonName);

                if (mStreamedRootObject != null)
                {
                    GameObject.Destroy(mStreamedRootObject);
                }

                mStreamedRootObject = new GameObject(this.SkeletonName);

                mQTmSegmentIdToGameObject = new Dictionary <uint, GameObject>(mQtmSkeletonCache.Segments.Count);

                foreach (var segment in mQtmSkeletonCache.Segments)
                {
                    var gameObject = new GameObject(this.SkeletonName + "_" + segment.Value.Name);
                    gameObject.transform.parent                 = segment.Value.ParentId == 0 ? mStreamedRootObject.transform : mQTmSegmentIdToGameObject[segment.Value.ParentId].transform;
                    gameObject.transform.localPosition          = segment.Value.TPosition;
                    gameObject.transform.localRotation          = segment.Value.TRotation;
                    mQTmSegmentIdToGameObject[segment.Value.Id] = gameObject;
                }

                mStreamedRootObject.transform.SetParent(this.transform, false);
                BuildMecanimAvatarFromQtmTPose();

                return;
            }

            if (mQtmSkeletonCache == null)
            {
                return;
            }

            //Update all the game objects
            foreach (var segment in mQtmSkeletonCache.Segments)
            {
                GameObject gameObject;
                if (mQTmSegmentIdToGameObject.TryGetValue(segment.Key, out gameObject))
                {
                    gameObject.transform.localPosition = segment.Value.Position;
                    gameObject.transform.localRotation = segment.Value.Rotation;
                }
            }
            if (mSourcePoseHandler != null && mDestiationPoseHandler != null)
            {
                mSourcePoseHandler.GetHumanPose(ref mHumanPose);
                mDestiationPoseHandler.SetHumanPose(ref mHumanPose);
            }
        }
예제 #2
0
 void Connect()
 {
     if (selectedDiscoveryResponse.HasValue)
     {
         RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, true, true, false, true, false, true);
     }
 }
예제 #3
0
        void OnDisconnect()
        {
            RTClient.GetInstance().Disconnect();
            connected = false;

            connectionStatus = "Disconnected";
        }
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null) rtClient = RTClient.GetInstance();
            if (rtClient.GetStreamingStatus() && !streaming)
            {
                streaming = true;
            }
            if (!rtClient.GetStreamingStatus() && streaming)
            {
                streaming = false;
            }

            //Seeking fo desired marker name

            markerData = rtClient.Markers;
            if (markerData == null && markerData.Count == 0)
                return;
            LabeledMarker marker = markerData.Find(x => x.Label == markerName);
            if (marker!=null)
            {
                if (marker.Position != null)
                {
                    if(!float.IsNaN(marker.Position.x) && !float.IsNaN(marker.Position.y) && !float.IsNaN(marker.Position.z))
                    {
                       transform.position = marker.Position + PositionOffset;
                    }
                }
            }
        }
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null) rtClient = RTClient.GetInstance();
            if (rtClient.GetStreamingStatus() && !streaming)
            {
                streaming = true;
            }
            if (!rtClient.GetStreamingStatus() && streaming)
            {
                streaming = false;
            }

            //Seeking fo desired marker name

            markerData = rtClient.Markers;
            if (markerData == null && markerData.Count == 0)
                return;
            for (int i = 0; i < markerData.Count; i++)
            {
                if (markerData[i].Label == markerName)
                {
                    //Transfering marker position to parented object

                    markerPosition = markerData[i].Position;
                    transform.position = markerPosition;
                }
            }
        }
예제 #6
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }

            SixDOFBody body = rtClient.GetBody(ObjectName);

            if (body != null)
            {
                if (body.Position.magnitude > 0) //just to avoid error when position is NaN
                {
                    transform.position = body.Position + PositionOffset;
                    if (transform.parent)
                    {
                        transform.position += transform.parent.position;
                    }
                    transform.rotation = body.Rotation * Quaternion.Euler(EulerOffset);
                    if (transform.parent)
                    {
                        transform.rotation *= transform.parent.rotation;
                    }
                }
            }
        }
        void Update()
        {
            var skeleton = RTClient.GetInstance().GetSkeleton(SkeletonName);

            if (mQtmSkeletonCache != skeleton)
            {
                mQtmSkeletonCache = skeleton;

                if (mQtmSkeletonCache == null)
                {
                    return;
                }

                GameObject rootObject = null;

                mQtmSegmentIdToGameObject.Clear();

                foreach (var segment in mQtmSkeletonCache.Segments)
                {
                    GameObject go;
                    if (!mSegmentNameToGameObject.TryGetValue(segment.Value.Name, out go))
                    {
                        Debug.Log("Didn't Find " + RigSegmentPrefix + segment.Value.Name);
                    }
                    else
                    {
                        // First one is assumed to be the root
                        if (rootObject == null)
                        {
                            rootObject = go;
                        }

                        mQtmSegmentIdToGameObject[segment.Value.Id] = go;
                    }
                }

                if (rootObject)
                {
                    rootObject.transform.SetParent(this.transform, false);
                }

                return;
            }

            if (mQtmSkeletonCache == null)
            {
                return;
            }

            // Update all the game objects
            foreach (var segment in mQtmSkeletonCache.Segments)
            {
                GameObject gameObject;
                if (mQtmSegmentIdToGameObject.TryGetValue(segment.Key, out gameObject))
                {
                    gameObject.transform.localPosition = segment.Value.Position;
                    gameObject.transform.localRotation = segment.Value.Rotation;
                }
            }
        }
예제 #8
0
 void Connect()
 {
     if (selectedDiscoveryResponse.HasValue)
     {
         RTClient.GetInstance().StartConnecting(selectedDiscoveryResponse.Value.IpAddress, portUDP, stream6d, stream3d, stream3dNoLabels, streamGaze, streamAnalog, streamSkeleton);
     }
 }
예제 #9
0
        void Update()
        {
            if (!visibleBones)
            {
                allBones.SetActive(false);
                return;
            }
            if (rtClient == null) rtClient = RTClient.GetInstance();
            if (!rtClient.GetStreamingStatus()) return;

            var boneData = rtClient.Bones;

            if (boneData == null || boneData.Count == 0) return;

            if (bones.Count != boneData.Count) InitiateBones();

            allBones.SetActive(true);
            for (int i = 0; i < boneData.Count; i++)
            {
                if (boneData[i].FromMarker.Position.magnitude > 0
                    && boneData[i].ToMarker.Position.magnitude > 0)
                {
                    bones[i].SetPosition(0, boneData[i].FromMarker.Position);
                    bones[i].SetPosition(1, boneData[i].ToMarker.Position);
                    bones[i].SetWidth(boneScale, boneScale);
                    bones[i].gameObject.SetActive(true);
                }
                else
                {
                    //hide bones if we cant find markers.
                    bones[i].gameObject.SetActive(false);
                }
            }
        }
예제 #10
0
        void OnGUI()
        {
            GUIStyle style = new GUIStyle();

            style.fontStyle        = FontStyle.Bold;
            style.normal.textColor = Color.white;
            GUI.Box(new Rect(10, 10, 220, 155), "Qualisys Realtime Streamer");

            GUI.Label(new Rect(20, 40, 200, 40), "QTM Server:\n(switch with arrow keys)");

            if (discoveryResponses == null)
            {
                discoveryResponses = RTClient.GetInstance().GetServers();
            }

            List <GUIContent> serverSelection = new List <GUIContent>();

            foreach (var discoveryResponse in discoveryResponses)
            {
                serverSelection.Add(new GUIContent(discoveryResponse.HostName + " (" + discoveryResponse.IpAddress + ":" + discoveryResponse.Port + ") " + discoveryResponse.InfoText));
            }

            GUI.Label(new Rect(20, 75, 200, 40), serverSelection[selectedServer], style);

            if (Input.GetKeyDown(KeyCode.LeftArrow) && !connected)
            {
                selectedServer--;
                if (selectedServer < 0)
                {
                    selectedServer += serverSelection.Count;
                }
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow) && !connected)
            {
                selectedServer++;
                if (selectedServer > serverSelection.Count - 1)
                {
                    selectedServer = 0;
                }
            }
            selectedDiscoveryResponse = discoveryResponses[selectedServer];

            if (connected)
            {
                if (GUI.Button(new Rect(20, 115, 200, 40), "Disconnect"))
                {
                    OnDisconnect();
                }
            }
            else
            {
                if (GUI.Button(new Rect(20, 115, 200, 40), "Connect"))
                {
                    OnConnect();
                }
            }
            GUI.Label(new Rect(20, 90, 200, 40), "Status: " + connectionStatus);
        }
    //private bool streaming = false;

    // Use this for initialization
    void Start()
    {
        MotionNumber           = 0;
        MdataText.text         = Mdata.ToString();
        InputText.text         = MotionNumberInput.ToString() + MotionNumber.ToString();
        rtClient               = QualisysRealTime.Unity.RTClient.GetInstance();
        mark                   = gameObject;
        MotionNumberInput.text = "Enter Text Here...";
    }
예제 #12
0
 public void Dispose()
 {
     if (!disposed)
     {
         Disconnect();
         disposed = true;
         instance = null;
     }
 }
예제 #13
0
 void Start()
 {
     rtClient = RTClient.GetInstance();
     bones = new List<LineRenderer>();
     allBones = new GameObject("Bones");
     allBones.transform.parent = transform;
     allBones.transform.localPosition = Vector3.zero;
     material = new Material(Shader.Find("Standard"));
 }
예제 #14
0
 public static RTClient GetInstance()
 {
     if (instance == null)
     {
         instance = new RTClient();
     }
     RTClientUpdater.AssertExistence();
     return(instance);
 }
 void OnDestroy()
 {
     if (instance != this)
     {
         return;
     }
     RTClient.GetInstance().Dispose();
     instance = null;
 }
예제 #16
0
 void Start()
 {
     rtClient = RTClient.GetInstance();
     bones    = new List <LineRenderer>();
     allBones = new GameObject("Bones");
     allBones.transform.parent        = transform;
     allBones.transform.localPosition = Vector3.zero;
     material = new Material(Shader.Find("Standard"));
 }
예제 #17
0
 public static RTClient GetInstance()
 {
     //Singleton method since we only want one instance (one connection to server)
     if (mInstance == null)
     {
         mInstance = new RTClient();
     }
     return(mInstance);
 }
        void OnDestroy()
        {
            var instance = RTClient.GetInstance();

            if (instance.IsConnected())
            {
                instance.Disconnect();
            }
            connected = false;
        }
예제 #19
0
        // Use this for initialization
        void Start()
        {
            rtClient = RTClient.GetInstance();

            gazeVectors = new List <LineRenderer>();
            gazeRoot    = new GameObject("GazeVectors");
            gazeRoot.transform.parent        = transform;
            gazeRoot.transform.localPosition = Vector3.zero;
            material = new Material(Shader.Find("Standard"));
        }
        void Disconnect()
        {
            var instance = RTClient.GetInstance();

            if (instance.IsConnected())
            {
                instance.Disconnect();
            }
            connected        = false;
            connectionStatus = "Disconnected";
        }
예제 #21
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }

            body = rtClient.GetBody(ObjectName);
            if (body != null)
            {
                this.applyBody();
            }
        }
예제 #22
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }

            marker = rtClient.GetMarker(MarkerName);
            if (marker != null)
            {
                this.applyMarkerTransform();
            }
        }
        void FixedUpdate()
        {
            if (instance == null)
            {
                instance = this;
            }

            if (instance != this)
            {
                return;
            }

            RTClient.GetInstance().Update();
        }
        // Use this for initialization
        void Start()
        {
            init();
            rtClient   = RTClient.GetInstance();
            markers    = new List <GameObject>();
            markerRoot = gameObject;

            PlayerPerspective = GameObject.Find("PlayerPerspective");

            Plane1 = GameObject.Find("Plane1");
            Plane2 = GameObject.Find("Plane2");
            Plane3 = GameObject.Find("Plane3");
            Plane4 = GameObject.Find("Plane4");
        }
예제 #25
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }

            var body = rtClient.GetBody(ObjectName);

            if (body != null)
            {
                applyBodyTransform(body);
            }
        }
        private string writePath = @"C:\Ian\Thesis\TextFiles\Debugging.txt";// this is used for debugging


        // Use this for initialization
        void Start()
        {
            File.WriteAllText(writePath, String.Empty);
            V_LG       = new Matrix4x4();
            V_LG       = Virtual_LFrame.VLF_LG;
            RUN        = true;
            rtClient   = RTClient.GetInstance();
            V_Lframe   = new List <GameObject>();
            Test       = new List <GameObject>();
            markers    = new List <GameObject>();
            markerRoot = gameObject;
            frame      = 0;

            InitiateCO();
        }
예제 #27
0
        void Update()
        {
            if (!visibleBones)
            {
                allBones.SetActive(false);
                return;
            }
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }
            if (!rtClient.GetStreamingStatus())
            {
                return;
            }

            var boneData = rtClient.Bones;

            if (boneData == null || boneData.Count == 0)
            {
                return;
            }

            if (bones.Count != boneData.Count)
            {
                InitiateBones();
            }

            allBones.SetActive(true);
            for (int i = 0; i < boneData.Count; i++)
            {
                if (!float.IsNaN(boneData[i].FromMarker.Position.sqrMagnitude) &&
                    !float.IsNaN(boneData[i].ToMarker.Position.sqrMagnitude))
                {
                    bones[i].SetPosition(0, boneData[i].FromMarker.Position);
                    bones[i].SetPosition(1, boneData[i].ToMarker.Position);
                    bones[i].startWidth = boneScale;
                    bones[i].endWidth   = boneScale;

                    bones[i].gameObject.SetActive(true);
                }
                else
                {
                    //hide bones if we cant find markers.
                    bones[i].gameObject.SetActive(false);
                }
            }
        }
예제 #28
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }
            if (rtClient.GetStreamingStatus() && !streaming)
            {
                InitiateBodies();
                streaming = true;
            }
            if (!rtClient.GetStreamingStatus() && streaming)
            {
                streaming = false;
                InitiateBodies();
            }

            bodies = rtClient.Bodies;

            if (bodies == null || bodies.Count == 0)
            {
                return;
            }

            if (bodiesGO.Count != bodies.Count)
            {
                InitiateBodies();
            }

            for (int i = 0; i < bodies.Count; i++)
            {
                if (!float.IsNaN(bodies[i].Position.sqrMagnitude))
                {
                    bodiesGO[i].name = bodies[i].Name;
                    bodiesGO[i].GetComponent <Renderer>().material.color = bodies[i].Color;
                    bodiesGO[i].transform.localPosition = bodies[i].Position;
                    bodiesGO[i].transform.localRotation = bodies[i].Rotation;
                    bodiesGO[i].SetActive(true);
                    bodiesGO[i].GetComponent <Renderer>().enabled = visibleBodies;
                    bodiesGO[i].transform.localScale = Vector3.one * bodyScale;
                }
                else
                {
                    // Hide markers if we cant find them
                    bodiesGO[i].SetActive(false);
                }
            }
        }
        void Connect()
        {
            if (selectedDiscoveryResponse.HasValue)
            {
                connected = RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, stream6d, stream3d, stream3dNoLabels, streamGaze, streamAnalog, streamSkeleton);
            }

            if (connected)
            {
                connectionStatus = "Connected";
            }
            else
            {
                connectionStatus = "Connection error - " + RTClient.GetInstance().GetErrorString() + " (also check console)";
            }
        }
예제 #30
0
        void OnConnect()
        {
            if (selectedDiscoveryResponse.HasValue)
            {
                connected = RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, true, true, true);
            }

            if (connected)
            {
                connectionStatus = "Connected";
            }
            else
            {
                connectionStatus = "Connection error - check console";
            }
        }
예제 #31
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null) rtClient = RTClient.GetInstance();

            SixDOFBody body = rtClient.GetBody(ObjectName);
            if (body != null)
            {
                if (body.Position.magnitude > 0) //just to avoid error when position is NaN
                {
                    transform.position = body.Position + PositionOffset;
                    if (transform.parent) transform.position += transform.parent.position;
                    transform.rotation = body.Rotation * Quaternion.Euler(EulerOffset);
                    if (transform.parent) transform.rotation *= transform.parent.rotation;
                }
            }
        }
예제 #32
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }
            if (rtClient.GetStreamingStatus() && !streaming)
            {
                InitiateMarkers();
                streaming = true;
            }
            if (!rtClient.GetStreamingStatus() && streaming)
            {
                streaming = false;
                InitiateMarkers();
            }

            markerData = rtClient.Markers;

            if (markerData == null || markerData.Count == 0)
            {
                return;
            }

            if (markers.Count != markerData.Count)
            {
                InitiateMarkers();
            }

            for (int i = 0; i < markerData.Count; i++)
            {
                if (!float.IsNaN(markerData[i].Position.sqrMagnitude))
                {
                    markers[i].name = markerData[i].Name;
                    markers[i].GetComponent <Renderer>().material.color = markerData[i].Color;
                    markers[i].transform.localPosition = markerData[i].Position;
                    markers[i].SetActive(true);
                    markers[i].GetComponent <Renderer>().enabled = visibleMarkers;
                    markers[i].transform.localScale = Vector3.one * markerScale;
                }
                else
                {
                    // Hide markers if we cant find them
                    markers[i].SetActive(false);
                }
            }
        }
예제 #33
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }
            if (rtClient.GetStreamingStatus() && !streaming)
            {
                InitiateGazeVectors();
                streaming = true;
            }
            if (!rtClient.GetStreamingStatus() && streaming)
            {
                streaming = false;
                InitiateGazeVectors();
            }

            gazeVectorData = rtClient.GazeVectors;

            if (gazeVectorData == null && gazeVectorData.Count == 0)
            {
                return;
            }

            if (gazeVectors.Count != gazeVectorData.Count)
            {
                InitiateGazeVectors();
            }


            gazeRoot.SetActive(true);
            for (int i = 0; i < gazeVectorData.Count; i++)
            {
                if (gazeVectorData[i].Position.magnitude > 0)
                {
                    gazeVectors[i].SetPosition(0, gazeVectorData[i].Position);
                    gazeVectors[i].SetPosition(1, gazeVectorData[i].Position + gazeVectorData[i].Direction * gazeVectorLength);
                    gazeVectors[i].startWidth = gazeVectorWidth;
                    gazeVectors[i].endWidth   = gazeVectorWidth;
                    gazeVectors[i].gameObject.SetActive(true);
                }
                else
                {
                    gazeVectors[i].gameObject.SetActive(true);
                }
            }
        }
예제 #34
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }

            var channel = rtClient.GetAnalogChannel(ChannelName);

            if (channel != null)
            {
                foreach (var value in channel.Values)
                {
                    // TODO::: What do we do with the analog values for this channel...?
                }
            }
        }
예제 #35
0
        void OnConnect()
        {
            if (selectedDiscoveryResponse.HasValue)
            {
                connected = RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, stream6d, stream3d, streamgaze);
            }

            if (connected)
            {
                connectionStatus = "Connected";
                availableBodies  = RTClient.GetInstance().Bodies;
            }
            else
            {
                connectionStatus = "Connection error - " + RTClient.GetInstance().GetErrorString() + " (also check console)";
            }
        }
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null) rtClient = RTClient.GetInstance();
            if (rtClient.GetStreamingStatus() && !streaming)
            {
                InitiateMarkers();
                streaming = true;
            }
            if (!rtClient.GetStreamingStatus() && streaming)
            {
                streaming = false;
                InitiateMarkers();
            }

            markerData = rtClient.Markers;

            if (markerData == null && markerData.Count == 0)
                return;

            if (markers.Count != markerData.Count)
            {
                InitiateMarkers();
            }

            for (int i = 0; i < markerData.Count; i++)
            {
                if (markerData[i].Position.magnitude > 0)
                {
                    markers[i].name = markerData[i].Label;
                    markers[i].GetComponent<Renderer>().material.color = markerData[i].Color;
                    markers[i].transform.localPosition = markerData[i].Position;
                    markers[i].SetActive(true);
                    markers[i].GetComponent<Renderer>().enabled = visibleMarkers;
                    markers[i].transform.localScale = Vector3.one * markerScale;
                }
                else
                {
                    //hide markers if we cant find them.
                    markers[i].SetActive(false);
                }
            }
        }
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null) rtClient = RTClient.GetInstance();

            SixDOFBody body = rtClient.GetBody(ObjectName);
            if (body != null)
            {
                if (body.Position.magnitude > 0) //just to avoid error when position is NaN
                {
                    if (DisableTranslation != true) //checking for DisableTranslation if other Translational data available
                    {
                        transform.position = body.Position + PositionOffset;
                        if (transform.parent) transform.position += transform.parent.position;
                    }
                    if (DisableRotation != true)//checking for DisableRotation if other Rotational data available
                    {
                        transform.rotation = body.Rotation * Quaternion.Euler(EulerOffset);
                        if (transform.parent) transform.rotation *= transform.parent.rotation;
                    }
                }
            }
        }
 // Use this for initialization
 void Start()
 {
     rtClient = RTClient.GetInstance();
 }
 // Use this for initialization
 void Start()
 {
     rtClient = RTClient.GetInstance();
     markers = new List<GameObject>();
     markerRoot = gameObject;
 }
예제 #40
0
 public static RTClient GetInstance()
 {
     //Singleton method since we only want one instance (one connection to server)
     if (mInstance == null)
     {
         mInstance = new RTClient();
     }
     return mInstance;
 }
 // Use this for initialization
 void Start()
 {
     rtClient = RTClient.GetInstance();
     markerRoot = gameObject;
 }