Exemplo n.º 1
0
        void LateUpdate()
        {
            MyClient.GetFrame();

            Output_GetSubjectRootSegmentName OGSRSN = MyClient.GetSubjectRootSegmentName(SubjectName);



//			ApplyBoneTransform(Root);

            // keep the camera looking at the model
            Output_GetSegmentGlobalTranslation RootPos = MyClient.GetSegmentGlobalTranslation(SubjectName, OGSRSN.SegmentName);

            if (RootPos.Occluded)
            {
                return;
            }

            Output_GetSegmentGlobalRotationQuaternion RootRotation = MyClient.GetSegmentGlobalRotationQuaternion(SubjectName, OGSRSN.SegmentName);

            Quaternion pose   = new Quaternion((float)RootRotation.Rotation[0], (float)RootRotation.Rotation[1], (float)RootRotation.Rotation[2], (float)RootRotation.Rotation[3]);
            Vector3    Target = new Vector3(-(float)RootPos.Translation[0] / 1000f, (float)RootPos.Translation[1] / 1000f, (float)RootPos.Translation[2] / 1000f);

            gameObject.transform.position = Target;
            gameObject.transform.rotation = pose;
        }
Exemplo n.º 2
0
 private void GetMotionCapture()
 {
     while (trackButton.Text == "Stop Tracking")
     {
         while (client.GetFrame().Result != Result.Success)
         {
             Thread.Sleep(200);
         }
         string SubjectName = client.GetSubjectName(0).SubjectName;
         string SegmentName = client.GetSegmentName(SubjectName, 0).SegmentName;
         Output_GetSegmentGlobalTranslation _Output_GetSegmentGlobalTranslation =
             client.GetSegmentGlobalTranslation(SubjectName, SegmentName);
         Output_GetSegmentGlobalRotationMatrix _Output_GetSegmentGlobalRotationMatrix =
             client.GetSegmentGlobalRotationMatrix(SubjectName, SegmentName);
         if (!_Output_GetSegmentGlobalTranslation.Occluded)
         {
             xActual     = _Output_GetSegmentGlobalTranslation.Translation[0];
             yActual     = _Output_GetSegmentGlobalTranslation.Translation[1];
             rotation[0] = _Output_GetSegmentGlobalRotationMatrix.Rotation[0];
             rotation[1] = _Output_GetSegmentGlobalRotationMatrix.Rotation[1];
             rotation[2] = _Output_GetSegmentGlobalRotationMatrix.Rotation[3];
             rotation[3] = _Output_GetSegmentGlobalRotationMatrix.Rotation[4];
         }
         else
         {
             continue;
         }
     }
 }
Exemplo n.º 3
0
    void LateUpdate()
    {
        // Get frame on late update if we've not got a separate frame acquisition thread

        //Output_GetSubjectCount out_2 = m_Client.GetSubjectCount();
        //Output_GetSubjectName out_3 = m_Client.GetSubjectName(1);
        Output_GetSegmentName out_4 = m_Client.GetSegmentName("Glasses01", 0);
        Output_GetSegmentGlobalTranslation out_5 = m_Client.GetSegmentGlobalTranslation("Glasses01", "Glasses01");

        //Output_GetSegmentCount out_3 = m_Client.GetSegmentCount(0);
        //Output_GetMarkerCount out_4 = m_Client.GetMarkerCount(0);

        //print(out_2.SubjectCount);
        //print(out_3.SegmentCount);
        //print(out_4.MarkerCount);
        //print(out_3.SubjectName);
        //print(output.MarkerCount);
        //data_UI.GetComponent<Image>().color = new Color32(0, 255, 0, 100);
        // print(out_4.SegmentName);
        //print(out_5.Translation[0]);
        //print(output.Result);
        if (!GetFrameThread)
        {
            if (!bConnected)
            {
                return;
            }

            GetNewFrame();
        }
    }
Exemplo n.º 4
0
        void Start()
        {
            print("Starting...");

            // Make a new client
            Output_GetVersion OGV = MyClient.GetVersion();

            print("GetVersion Major: " + OGV.Major);


            // Connect to a server
            string HostName   = "192.168.1.119:801";
            int    noAttempts = 0;

            print("Connecting to " + HostName + "...");
            while (!MyClient.IsConnected().Connected)
            {
                // Direct connection
                Output_Connect OC = MyClient.Connect(HostName);
                print("Connect result: " + OC.Result);

                noAttempts += 1;
                if (noAttempts == 3)
                {
                    break;
                }
                System.Threading.Thread.Sleep(200);
            }

            MyClient.EnableSegmentData();
            MyClient.EnableMarkerData();
            MyClient.EnableUnlabeledMarkerData();


            // get a frame from the data stream so we can inspect the list of subjects
            MyClient.GetFrame();

            Output_GetSubjectCount OGSC = MyClient.GetSubjectCount();

            print("GetSubjectCount: " + OGSC.Result + "|" + OGSC.SubjectCount);

            // the first subjects in the data stream will be the original subjects unmodified by pegasus
            Output_GetSubjectName OGSN = MyClient.GetSubjectName(OGSC.SubjectCount - 1);

            print("GetSubjectName: " + OGSN.Result + "|" + OGSN.SubjectName);

            SubjectName = OGSN.SubjectName;

            // get the position of the root and point the camera at it
            Output_GetSubjectRootSegmentName   OGSRSN  = MyClient.GetSubjectRootSegmentName(SubjectName);
            Output_GetSegmentGlobalTranslation RootPos = MyClient.GetSegmentGlobalTranslation(SubjectName, OGSRSN.SegmentName);
            Output_GetMarkerCount mcount = MyClient.GetMarkerCount(SubjectName);

            Output_GetUnlabeledMarkerGlobalTranslation OGSGT = MyClient.GetUnlabeledMarkerGlobalTranslation(0);

            Vector3 Target = new Vector3(-(float)OGSGT.Translation[0] / 1000f, (float)OGSGT.Translation[1] / 1000f, (float)OGSGT.Translation[2] / 1000f);

            Camera.main.transform.LookAt(Target);
        }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (!mConnected)
        {
            return;
        }

        Output_GetFrame frame_result = pClient.GetFrame();

        if (frame_result.Result != Result.Success)
        {
            return;
        }

        Output_GetSubjectCount subjectCountResult = pClient.GetSubjectCount();
        uint count = subjectCountResult.SubjectCount;

        if (count == 0)
        {
            return;
        }

        bool subjectSet    = false;
        uint oculusSubject = 0;

        for (uint i = 0; i < count; i++)
        {
            Output_GetSubjectName name = pClient.GetSubjectName(i);
            Debug.Log(name.SubjectName);

            if (name.SubjectName.Equals("OCULUS"))
            {
                oculusSubject = i;
                subjectSet    = true;
            }
        }

        if (!subjectSet)
        {
            return;
        }


        Output_GetSubjectRootSegmentName rsn = pClient.GetSubjectRootSegmentName("OCULUS");
        Output_GetSegmentCount           sg  = pClient.GetSegmentCount("OCULUS");

        Output_GetSegmentGlobalTranslation grans = pClient.GetSegmentGlobalTranslation("OCULUS", rsn.SegmentName);
        Vector3 ret;

        ret.x = (float)grans.Translation [0];
        ret.y = (float)grans.Translation [1];
        ret.z = (float)grans.Translation [2];

        outTransform.localPosition = ret;
    }
Exemplo n.º 6
0
    // Creating a position vector using the Vicon data
    public Vector3 MakePositionVector(string subjectName, string rootSegmentName)
    {
        Output_GetSegmentGlobalTranslation globalPosition = mViconClient.GetSegmentGlobalTranslation(subjectName, rootSegmentName);
        Vector3 localPosition = new Vector3(
            (float)(globalPosition.Translation[0] / 100f),
            (float)(globalPosition.Translation[2] / 100f),
            (float)(globalPosition.Translation[1] / 100f)
            );

        return(localPosition);
    }
Exemplo n.º 7
0
        void LateUpdate()
        {
            MyClient.GetFrame();

            Output_GetSubjectRootSegmentName OGSRSN = MyClient.GetSubjectRootSegmentName(SubjectName);
            Transform Root = transform.FindChild(OGSRSN.SegmentName);

            ApplyBoneTransform(Root);

            // keep the camera looking at the model
            Output_GetSegmentGlobalTranslation RootPos = MyClient.GetSegmentGlobalTranslation(SubjectName, OGSRSN.SegmentName);
            Vector3 Target = new Vector3(-(float)RootPos.Translation[0], (float)RootPos.Translation[1], (float)RootPos.Translation[2]);

            Camera.main.transform.LookAt(Target);
        }