示例#1
0
        public void Initialize()
        {
            if (isInitialized)
            {
                return;
            }

            int status = natNetClient.Initialize("127.0.0.1", "127.0.0.1");

            if (status != 0)
            {
                throw new InvalidOperationException("OptiTrack system initialization failed. Is Motive application running?");
            }

            status = natNetClient.GetServerDescription(serverDescription);

            if (status != 0)
            {
                throw new InvalidOperationException("Connection failed. Is Motive application running?");
            }

            isInitialized = true;
            Initialized?.Invoke();

            natNetClient.OnFrameReady += (data, client) => {
                FrameReceived?.Invoke(new InputFrame(data));
            };
        }
示例#2
0
        public void Initialize()
        {
            if (isInitialized)
            {
                return;
            }

            int status = natNetClient.Initialize("127.0.0.1", "127.0.0.1");

            if (status != 0)
            {
                throw new InvalidOperationException("OptiTrack system initialization failed. Is Motive application running?");
            }

            status = natNetClient.GetServerDescription(ServerDescription);

            if (status != 0)
            {
                throw new InvalidOperationException("Connection failed. Is Motive application running?");
            }

            isInitialized = true;
            Initialized?.Invoke(this, EventArgs.Empty);

            natNetClient.OnFrameReady += ProcessFrame;
        }
示例#3
0
        public void TryConnect()
        {
            Rhino.RhinoApp.Write("Attemping to connect to NatNet server... ");
            client = new NatNetClientML();
            int res = client.Initialize("127.0.0.1", "127.0.0.1");

            if (res != 0)
            {
                Rhino.RhinoApp.WriteLine("Failed.");
                client      = null;
                IsConnected = false;
                return;
            }
            Rhino.RhinoApp.WriteLine("Success.");
            IsConnected = true;


            // testing only

            /*
             * System.Random rnd = new Random();
             * for (int i = 0; i < 10; ++i)
             * {
             *  markers.Add(new Point3d((rnd.NextDouble() - 0.5) * 500.0, (rnd.NextDouble() - 0.5) * 500.0, (rnd.NextDouble() - 0.5) * 500.0));
             * }
             */

            client.OnFrameReady += GetMarkersCallback;
            Rhino.Display.DisplayPipeline.PostDrawObjects      += DisplayPipeline_DrawMarkers;
            Rhino.Display.DisplayPipeline.CalculateBoundingBox += DisplayPipeline_MarkersBoundingBox;

            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }
示例#4
0
        public bool Connect(string ipAddress)
        {
            int returnCode = m_natNetClient.Initialize(
                m_localAddr.ToString(), ipAddress);

            if (returnCode == 0)
            {
                if (Constants.DebugPrint)
                {
                    Debug.WriteLine("Initialization succeeded ...");
                }

                m_rigidBodies.Clear();

                List <DataDescriptor> descs = new List <DataDescriptor>();
                bool success = m_natNetClient.GetDataDescriptions(out descs);
                if (success)
                {
                    foreach (DataDescriptor d in descs)
                    {
                        if (d.type == (int)DataDescriptorType.eRigidbodyData)
                        {
                            RigidBody rigidBody = (RigidBody)d;
                            m_rigidBodies.Add(rigidBody);
                        }
                    }

                    IsConnected = true;
                    return(true);
                }
                else
                {
                    if (Constants.DebugPrint)
                    {
                        Debug.WriteLine("Could not get data descriptors ...");
                    }

                    m_natNetClient.Uninitialize();
                    return(false);
                }
            }
            else
            {
                if (Constants.DebugPrint)
                {
                    Debug.WriteLine("Error Initializing!");
                }

                IsConnected = false;
                return(false);
            }
        }