static bool Get6DOFSettings(RTState state, RTProtocol mProtocol)
        {
            // Get settings and information for streamed bodies
            bool getstatus = mProtocol.Get6dSettings();

            if (getstatus)
            {
                state.bodies.Clear();
                Settings6D settings = mProtocol.Settings6DOF;
                foreach (Settings6DOF body in settings.Bodies)
                {
                    SixDOFBody newbody = new SixDOFBody();
                    newbody.Name     = body.Name;
                    newbody.Color.r  = (body.ColorRGB) & 0xFF;
                    newbody.Color.g  = (body.ColorRGB >> 8) & 0xFF;
                    newbody.Color.b  = (body.ColorRGB >> 16) & 0xFF;
                    newbody.Color   /= 255;
                    newbody.Color.a  = 1F;
                    newbody.Position = Vector3.zero;
                    newbody.Rotation = Quaternion.identity;
                    state.bodies.Add(newbody);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public void ClearSettings()
 {
     m3DSettings         = null;
     m6DOFSettings       = null;
     mAnalogSettings     = null;
     mForceSettings      = null;
     mGazeVectorSettings = null;
     mGeneralSettings    = null;
     mImageSettings      = null;
 }
Exemplo n.º 3
0
 public void ClearSettings()
 {
     m3DSettings                 = null;
     m6DOFSettings               = null;
     mAnalogSettings             = null;
     mForceSettings              = null;
     mGazeVectorSettings         = null;
     mSkeletonSettingsCollection = null;
     mGeneralSettings            = null;
     mImageSettings              = null;
 }
Exemplo n.º 4
0
        /// <summary>Disconnect from server</summary>
        public void Disconnect()
        {
            mBroadcastSocketCreated = false;
            mNetwork.Disconnect();

            m3DSettings     = null;
            m6DOFSettings   = null;
            mAnalogSettings = null;
            mDiscoveryResponses.Clear();
            mForceSettings      = null;
            mGazeVectorSettings = null;
            mGeneralSettings    = null;
            mImageSettings      = null;
        }
Exemplo n.º 5
0
        private bool Get6DOFSettings()
        {
            // Get settings and information for streamed bodies
            bool getstatus = mProtocol.Get6DSettings();

            if (getstatus)
            {
                mBodies.Clear();
                Settings6D settings = mProtocol.Settings6DOF;
                foreach (Settings6DOF body in settings.bodies)
                {
                    SixDOFBody newbody = new SixDOFBody();
                    newbody.Name     = body.Name;
                    newbody.Position = Vector3.zero;
                    newbody.Rotation = Quaternion.identity;
                    mBodies.Add(newbody);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        private static RTProtocol EstablishConnection(string qtmName)
        {
            RTProtocol rtProtocol = new RTProtocol();

            Console.WriteLine("Discovering QTM servers on the network...");
            // We know the name of the computer we want to connect to, find out its IP
            DiscoveryResponse qtmToConnect = new DiscoveryResponse();

            if (rtProtocol.DiscoverRTServers(qtmDiscoveryPort))
            {
                var discoveryResponses = rtProtocol.DiscoveryResponses;
                if (discoveryResponses.Count != 0)
                {
                    foreach (var discoveryResponse in discoveryResponses)
                    {
                        Console.WriteLine(
                            "Discovered {0,16} {1,16} {2,16} {3,3} cameras",
                            discoveryResponse.HostName,
                            discoveryResponse.IpAddress,
                            discoveryResponse.InfoText,
                            discoveryResponse.CameraCount
                            );
                        if (discoveryResponse.HostName == qtmName)
                        {
                            qtmToConnect = discoveryResponse;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No QTM servers found on available networks!");
                }
            }

            // Only connect if the desired computer name is found
            if (qtmToConnect.HostName == qtmName)
            {
                // Try max. 5 times, then admit failure
                for (int i = 0; i < 5; i++)
                {
                    if (rtProtocol.IsConnected())
                    {
                        break;
                    }
                    if (!rtProtocol.Connect(qtmToConnect.IpAddress))
                    {
                        Console.WriteLine("Trying to connect...");
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        Console.WriteLine(
                            "Connected to {0} @ {1}!",
                            qtmToConnect.HostName,
                            qtmToConnect.IpAddress
                            );
                    }
                }
            }
            else
            {
                Console.WriteLine("The desired QTM server ({0}) was not found!", qtmName);
            }

            // Get settings if connected to QTM, otherwise alert user and continue
            if (rtProtocol.IsConnected())
            {
                // 6DOF settings
                Console.WriteLine("Getting 6DOF settings...");
                // Try max. 5 times, then admit failure
                for (int i = 0; i < 5; i++)
                {
                    if (rtProtocol.Get6dSettings())
                    {
                        Settings6D settings6D = rtProtocol.Settings6DOF;
                        int        bodyCount  = settings6D.BodyCount;
                        Console.WriteLine("{0} 6DOF bodies found.", bodyCount);
                        List <Settings6DOF> qtmBodies = settings6D.Bodies;
                        foreach (Settings6DOF body in qtmBodies)
                        {
                            Console.WriteLine("\t Found 6DOF body: {0}", body.Name);
                        }
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Failed to get 6DOF settings!");
                    }
                }
            }
            else
            {
                Console.WriteLine("Could not communicate with QTM!");
            }

            // Disconnect on exit
            AppDomain.CurrentDomain.ProcessExit += (sender, e) => OnProcessExit(sender, e, rtProtocol);

            return(rtProtocol);
        }