/// <summary>
 /// Updates the rotation and position of the Character
 /// </summary>
 public void Update()
 {
     if (rtClient == null)
     {
         rtClient = RTClient.GetInstance();
     }
     if (!rtClient.GetStreamingStatus())
     {
         return;
     }
     markerData = rtClient.Markers;
     if ((markerData == null || markerData.Count == 0))
     {
         Debug.LogError("The stream does not contain any markers");
         return;
     }
     if (skeletonBuilder != null)
     {
         skeleton = skeletonBuilder.SolveSkeleton(markerData);
     }
     else
     {
         ResetSkeleton();
     }
     SetAll();
     if (!headCam.UseHeadCamera && headCamera)
     {
         DestroyCamera();
     }
 }
    void Start()
    {
        // Get the global RTClient object from the Qualisys system
        rtClient = RTClient.GetInstance();

        // Loop through discovered servers to find one that matches our needs
        foreach (var discoveryResponse in rtClient.GetServers())
        {
            // Check if the response has the right IP address
            if (discoveryResponse.IpAddress == host)
            {
                Debug.Log("Desired Host Found");
                server      = discoveryResponse;
                foundServer = true;
            }
            Debug.Log(discoveryResponse.IpAddress);
            // else{
            //     Debug.Log("Desired Host not found");
            // }
        }

        // If a server is found at the correct host, connect to the server
        if (foundServer)
        {
            rtClient.Connect(server, 4545, true, true, false, false, false);
        }
    }
Example #3
0
 void Update()
 {
     if (RTClient.GetInstance().GetStreamingStatus())
     {
         Disable();
     }
     if (contentPanel.childCount < 1)
     {
         UpdateList();
     }
 }
Example #4
0
 void Connect()
 {
     if (!RTClient.GetInstance().Connect(response, response.Port, true, true, true))
     {
         InfoText.color = Color.red;
         InfoText.text  = "Could not connect to this server";
     }
     else
     {
         SendMessageUpwards("Disable");
     }
 }
        /// <summary>
        /// Locating the joints of the character and find the scale by which the position should be applied to
        /// </summary>
        public void Start()
        {
            rtClient = RTClient.GetInstance();
            //Find all joints of the characters
            jointsFound = charactersJoints.SetLimbs(this.transform, UseFingers);
            // disable the animation
            var animation = this.GetComponent <Animation>();

            if (animation)
            {
                animation.enabled = false;
            }
        }
Example #6
0
 public void UpdateList()
 {
     for (int i = 0; i < contentPanel.childCount; i++)
     {
         Destroy(contentPanel.GetChild(i).gameObject);
     }
     discoveryResponses = RTClient.GetInstance().GetServers();
     foreach (DiscoveryResponse server in discoveryResponses)
     {
         GameObject   newServer    = Instantiate(serverButtonPrefab) as GameObject;
         ServerButton serverButton = newServer.GetComponent <ServerButton>();
         serverButton.HostText.text      = server.HostName;
         serverButton.IpAddressText.text = server.IpAddress + ":" + server.Port;
         serverButton.InfoText.text      = server.InfoText;
         serverButton.response           = server;
         newServer.transform.SetParent(contentPanel);
     }
 }
Example #7
0
    // Start is called before the first frame update
    void Start()
    {
        rtClient = RTClient.GetInstance();

        // Loop through discovered servers to find one that matches our needs
        foreach (var discoveryResponse in rtClient.GetServers())
        {
            if (discoveryResponse.IpAddress == host)
            {
                Debug.Log("Desired Host Found");
                server      = discoveryResponse;
                foundServer = true;
            }
        }

        // Maybe do something on update to attempt again?
        if (foundServer)
        {
            rtClient.Connect(server, 4545, true, true, false, false, false, false);
        }
    }
    IEnumerator Connect()
    {
        RTClient.GetInstance().StartConnecting(response.IpAddress, -1, true, true, false, true, false, true);
        InfoText.color = Color.yellow;
        InfoText.text  = "Connecting ...";

        while (RTClient.GetInstance().ConnectionState == RTConnectionState.Connecting)
        {
            yield return(null);
        }

        if (RTClient.GetInstance().ConnectionState == RTConnectionState.Connected)
        {
            SendMessageUpwards("Disable");
        }
        else
        {
            InfoText.color = Color.red;
            InfoText.text  = "Could not connect to this server";
        }
    }
Example #9
0
    //public float moveMult = 1f;

    void Start()
    {
        // Get a reference to the global Qualisys client object
        rtClient = RTClient.GetInstance();
    }
Example #10
0
        /// <summary>
        /// ...
        /// </summary>
        void LateUpdate()
        {
            if (eyeAnchor == null)
            {
                return;
            }

            // Get streamed rigid body definition of rift
            if (useRiftRigidBody && RTClient.GetInstance().GetStreamingStatus())
            {
                SixDOFBody rift = RTClient.GetInstance().GetBody(bodyName);
                if (rift != null && !rift.Rotation.Convert().IsNaN())
                {
                    sixDOFBodyRotation = new Quaternion(rift.Rotation.x, rift.Rotation.y, rift.Rotation.z, rift.Rotation.w);

                    // Reorientate the camera rig to match the 6 DOF coordinate system
                    if (
                        useInternalTracking &&
                        needsCameraRigReorientation &&
                        sixDOFBodyRotation != Quaternion.identity
                        )
                    {
                        Debug.Log("Calibrating Oculus Rift Pose...");
                        Debug.Log("Rift rotation " + rift.Rotation.eulerAngles);
                        Debug.Log("Anchor rotation " + eyeAnchor.localEulerAngles);

                        // Align the camera rig coordinate system to the QTM coordinate system by a rotation over the y-axis
                        //offsetAngle = (360 - eyeAnchor.eulerAngles.y) + sixDOFBodyRotation.eulerAngles.y;
                        //offsetAngle = eyeAnchor.localEulerAngles.y + sixDOFBodyRotation.eulerAngles.y + 180; // 180 cause of the rigid body axes
                        offsetAngle = 180 + sixDOFBodyRotation.eulerAngles.y - eyeAnchor.localEulerAngles.y;

                        // Enable avatar mesh
                        foreach (SkinnedMeshRenderer renderer in renderers)
                        {
                            renderer.enabled = true;
                        }

                        // OVR global coordinate system is calibrated
                        needsCameraRigReorientation = false;
                    }

                    // Show mirrored avatar when camera rig is orientated
                    if (showMirror)
                    {
                        mirroredCharacterJoints.root.gameObject.SetActive(true);
                    }

                    //RTClient.GetInstance().SetStatusMessage("OCULUS_RIFT", "", true);
                }
                else
                {
                    //RTClient.GetInstance().SetStatusMessage("OCULUS_RIFT", "", false);
                }
            }
            else if (!useRiftRigidBody && showMirror)
            {
                mirroredCharacterJoints.root.gameObject.SetActive(true);
            }

            // Get avatars head
            Transform head   = characterJoints.head;
            Vector3   lookAt = eyeAnchor.forward * 10.0f;

            // Set head orientation to rift orientation and position the camera rig in front of the head
            if (useInternalTracking)
            {
                head.rotation = eyeAnchor.rotation;
                cameraRig.transform.eulerAngles = new Vector3(0, this.transform.eulerAngles.y + offsetAngle, 0);
                //cameraRig.transform.position = head.position + head.rotation * cameraOffset;
                //cameraRig.transform.localPosition = head.position + cameraRig.transform.rotation * cameraOffset;
                //cameraRig.transform.localPosition = head.position + eyeAnchor.rotation * cameraOffset;
                // Need to substract the position of the eye anchor
                cameraRig.transform.localPosition =
                    head.position
                    - cameraRig.transform.rotation * eyeAnchor.localPosition
                    + eyeAnchor.rotation * cameraOffset;
            }
            else
            {
                head.localRotation = sixDOFBodyRotation;
            }

            // Draw debug ray in look direction
            Debug.DrawRay(eyeAnchor.position, lookAt, Color.green);

            // Set pose of the mirrored avatar
            if (showMirror)
            {
                setMirroredAvatarPose();
            }
        }
Example #11
0
 // Start is called before the first frame update
 void Start()
 {
     rtClient = RTClient.GetInstance();
 }