コード例 #1
0
        private static void sendLocalRotationQuaternion(Client MyClient, UDPSender sender)
        {
            // Count the number of subjects
            uint SubjectCount = MyClient.GetSubjectCount().SubjectCount;
            for (uint SubjectIndex = 0; SubjectIndex < SubjectCount; ++SubjectIndex)
            {

                // Get the subject name
                string SubjectName = MyClient.GetSubjectName(SubjectIndex).SubjectName;
                Console.WriteLine("    Name: {0}", SubjectName);

                // Get the root segment
                string RootSegment = MyClient.GetSubjectRootSegmentName(SubjectName).SegmentName;
                Console.WriteLine("    Root Segment: {0}", RootSegment);

                //Get the static segment translation
                Output_GetSegmentLocalRotationQuaternion Output =
                MyClient.GetSegmentLocalRotationQuaternion(SubjectName, RootSegment);

                Console.WriteLine("        LOCAL Rotation Quaternion: ({0},{1},{2},{3})",
                                   Output.Rotation[0],
                                   Output.Rotation[1],
                                   Output.Rotation[2],
                                   Output.Rotation[3]);

                String[] msg = new String[5];
                msg[0] = "RigidBody Name: " + SubjectName;
                msg[1] = "q.x: " + Output.Rotation[0].ToString();
                msg[2] = "q.y: " + Output.Rotation[1].ToString();
                msg[3] = "q.z: " + Output.Rotation[2].ToString();
                msg[4] = "q.w: " + Output.Rotation[3].ToString();

                var message = new SharpOSC.OscMessage("/localQuat", msg);
                sender.Send(message);

            }
        }
コード例 #2
0
        /*
            Sends rigid body data out over OSC.
            Address Pattern: \rigidBody
            Format: String[4]
                RigidBodyName
                GlobalPosition.x
                GlobalPosition.y
                GlobalPosition.z
                GlobalOrientation.qx
                GlobalOrientation.qy
                GlobalOrientation.qz
                GlobalOrientation.qw
        */
        private static void sendRigidBodies(Client MyClient, UDPSender sender)
        {
            // Count the number of subjects
            uint SubjectCount = MyClient.GetSubjectCount().SubjectCount;
            for (uint SubjectIndex = 0; SubjectIndex < SubjectCount; ++SubjectIndex)
            {

                // Get the subject name
                string SubjectName = MyClient.GetSubjectName(SubjectIndex).SubjectName;
                Console.WriteLine("    Name: {0}", SubjectName);

                // Get the root segment
                string RootSegment = MyClient.GetSubjectRootSegmentName(SubjectName).SegmentName;
                Console.WriteLine("    Root Segment: {0}", RootSegment);

                //Get the static segment translation
                Output_GetSegmentGlobalTranslation _Output_GetSegmentGlobalTranslation =
                MyClient.GetSegmentGlobalTranslation(SubjectName, RootSegment);
                Console.WriteLine("        Global Translation: ({0},{1},{2}) {3}",
                                   _Output_GetSegmentGlobalTranslation.Translation[0],
                                   _Output_GetSegmentGlobalTranslation.Translation[1],
                                   _Output_GetSegmentGlobalTranslation.Translation[2],
                                   _Output_GetSegmentGlobalTranslation.Occluded);

                // Get the global segment rotation in quaternion co-ordinates
                Output_GetSegmentGlobalRotationQuaternion _Output_GetSegmentGlobalRotationQuaternion =
                MyClient.GetSegmentGlobalRotationQuaternion(SubjectName, RootSegment);
                Console.WriteLine("        Global Rotation Quaternion: ({0},{1},{2},{3}) {4}",
                                   _Output_GetSegmentGlobalRotationQuaternion.Rotation[0],
                                   _Output_GetSegmentGlobalRotationQuaternion.Rotation[1],
                                   _Output_GetSegmentGlobalRotationQuaternion.Rotation[2],
                                   _Output_GetSegmentGlobalRotationQuaternion.Rotation[3],
                                   _Output_GetSegmentGlobalRotationQuaternion.Occluded);

                String[] msg = new String[8];
                msg[0] = "RigidBody Name: "+ SubjectName;
                msg[1] = "pos.x: " + _Output_GetSegmentGlobalTranslation.Translation[0].ToString();
                msg[2] = "pos.y: " + _Output_GetSegmentGlobalTranslation.Translation[1].ToString();
                msg[3] = "pos.z: " + _Output_GetSegmentGlobalTranslation.Translation[2].ToString();
                msg[4] = "q.x: " + _Output_GetSegmentGlobalRotationQuaternion.Rotation[0].ToString();
                msg[5] = "q.y: " + _Output_GetSegmentGlobalRotationQuaternion.Rotation[1].ToString();
                msg[6] = "q.z: " + _Output_GetSegmentGlobalRotationQuaternion.Rotation[2].ToString();
                msg[7] = "q.w: " + _Output_GetSegmentGlobalRotationQuaternion.Rotation[3].ToString();

                // ignore dropped tracking frames
                if (_Output_GetSegmentGlobalTranslation.Translation[0] != 0 &&
                    _Output_GetSegmentGlobalTranslation.Translation[1] != 0 &&
                    _Output_GetSegmentGlobalTranslation.Translation[2] != 0 ) {
                    var message = new SharpOSC.OscMessage("/rigidBody", msg);
                    sender.Send(message);
                }

            }
        }
コード例 #3
0
        /*
            Sends any labled markers out over OSC.
            Address Pattern: \labledMarker
            Format: String[5]
                MarkerID
                MarkerName
                GlobalMarkerPosition.x
                GlobalMarkerPosition.y
                GlobalMarkerPosition.z
        */
        private static void sendLabledMarkers(Client MyClient, UDPSender sender)
        {
            // For each subject in the scene
            uint SubjectCount = MyClient.GetSubjectCount().SubjectCount;
            for (uint SubjectIndex = 0; SubjectIndex < SubjectCount; ++SubjectIndex)
            {
                // Get the subject name
                string SubjectName = MyClient.GetSubjectName(SubjectIndex).SubjectName;

                // Count the number of markers
                uint MarkerCount = MyClient.GetMarkerCount(SubjectName).MarkerCount;

                // for each marker in subject
                for (uint MarkerIndex = 0; MarkerIndex < MarkerCount; ++MarkerIndex)
                {
                    // Get the marker name
                    string MarkerName = MyClient.GetMarkerName(SubjectName, MarkerIndex).MarkerName;

                    // Get the global marker translation
                    Output_GetMarkerGlobalTranslation _Output_GetMarkerGlobalTranslation =
                      MyClient.GetMarkerGlobalTranslation(SubjectName, MarkerName);

                    String[] msg = new String[5];
                    msg[0] = "RigidBody Name: "+MarkerName;
                    msg[1] = "MarkerID: " + MarkerIndex;
                    msg[2] = "pos.x: " + _Output_GetMarkerGlobalTranslation.Translation[0].ToString();
                    msg[3] = "pos.y: " + _Output_GetMarkerGlobalTranslation.Translation[1].ToString();
                    msg[4] = "pos.z: " + _Output_GetMarkerGlobalTranslation.Translation[2].ToString();

                    // ignore dropped tracking locations
                    if (_Output_GetMarkerGlobalTranslation.Translation[0] != 0 &&
                        _Output_GetMarkerGlobalTranslation.Translation[1] != 0 &&
                        _Output_GetMarkerGlobalTranslation.Translation[2] != 0)
                    {
                        var message = new SharpOSC.OscMessage("/labledMarker", msg);
                        sender.Send(message);
                    }

                    Console.WriteLine("      Marker #{0}: {1} ({2}, {3}, {4}) {5}",
                                       MarkerIndex,
                                       MarkerName,
                                       _Output_GetMarkerGlobalTranslation.Translation[0],
                                       _Output_GetMarkerGlobalTranslation.Translation[1],
                                       _Output_GetMarkerGlobalTranslation.Translation[2],
                                       _Output_GetMarkerGlobalTranslation.Occluded);
               }
            }
        }