示例#1
0
    private void OnFrameDataReceived(IntPtr customObject, IntPtr socketRef, IntPtr header, IntPtr data)
    {
        // read header info
        _bvhHeader = (BvhDataHeader)Marshal.PtrToStructure(header, typeof(BvhDataHeader));

        // show in gui
        WithDisplacement = _bvhHeader.bWithDisp != 0;
        WithPrefix       = _bvhHeader.bWithReference != 0;

        // frame counter
        _receivedFramesCounter++;

        // Change the buffer length if necessory
        if (_bvhHeader.DataCount != _valuesBuffer.Length)
        {
            //Debug.Log("<color=yellow>Received DataCount was not the same length as the buffer! Changing length to: " + _bvhHeader.DataCount + "</color>");
            _valuesBuffer = new float[_bvhHeader.DataCount];
        }

        // read and convert data to values array
        Marshal.Copy(data, _valuesBuffer, 0, (int)_bvhHeader.DataCount);

        // As a demo, only show the first avatar
        if (_bvhHeader.AvatarIndex == 0)
        {
            // Parsing position and rotation data
            ParseBVHData(_valuesBuffer);
        }
    }
示例#2
0
 public void OnReceivedMotionData(BvhDataHeader header, IntPtr data)
 {
     _header = header;
     try
     {
         Marshal.Copy(data, _data, 0, (int)header.DataCount);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
        private void bvhDataReceived(IntPtr customObject, IntPtr sockRef, IntPtr header, IntPtr data)
        {
            _bvhHeader = (BvhDataHeader)Marshal.PtrToStructure(header, typeof(BvhDataHeader));

            // Change the buffer length if necessory
            if (_bvhHeader.DataCount != _valuesBuffer.Length)
            {
                _valuesBuffer = new float[_bvhHeader.DataCount];
            }

            Marshal.Copy(data, _valuesBuffer, 0, (int)_bvhHeader.DataCount);
            //_valuesBuffer = (float[])Marshal.PtrToStructure(data, typeof(float[_bvhHeader.DataCount]));

            if (sockRef == this.sockTCPRef)
            {
                _frameCount++;

                this.Dispatcher.Invoke(new Action(delegate()
                {
                    cbWithDisp.IsChecked   = _bvhHeader.bWithDisp != 0;
                    cbWithPrefix.IsChecked = _bvhHeader.bWithReference != 0;

                    txtLog.Text = _frameCount.ToString();
                }));
            }

            if (sockRef == this.sockTCPRef1)
            {
                _frameCount1++;

                this.Dispatcher.Invoke(new Action(delegate()
                {
                    cbWithDisp.IsChecked   = _bvhHeader.bWithDisp != 0;
                    cbWithPrefix.IsChecked = _bvhHeader.bWithReference != 0;

                    txtLog1.Text = _frameCount1.ToString();
                }));
            }

            if (sockRef == this.sockUDPRef)
            {
                _frameCount++;

                this.Dispatcher.Invoke(new Action(delegate()
                {
                    cbWithDisp.IsChecked   = _bvhHeader.bWithDisp != 0;
                    cbWithPrefix.IsChecked = _bvhHeader.bWithReference != 0;

                    txtLog.Text = _frameCount.ToString();
                }));
            }
        }
 public void OnReceivedMotionData(BvhDataHeader header, IntPtr data)
 {
     this.header = header;
     try
     {
         Marshal.Copy(data, this.data, 0, (int)header.DataCount);
         timeStamp = GetTimeStamp();
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
示例#5
0
        void onFrameDataReceived(IntPtr customObject, IntPtr sockRef, IntPtr bvheader, IntPtr data)
        {
            BvhDataHeader header = (BvhDataHeader)Marshal.PtrToStructure(bvheader, typeof(BvhDataHeader));

            if (header.DataCount != valuesBuffer.Length)
            {
                valuesBuffer = new float[header.DataCount];
            }
            Marshal.Copy(data, valuesBuffer, 0, (int)header.DataCount);

            txtReceivingCounter.Dispatcher.Invoke(new Action(delegate()
            {
                counter++;
                txtReceivingCounter.Text = counter.ToString();
            }));
        }
示例#6
0
        public virtual void OnFrameDataReceived(IntPtr DataHeader, IntPtr data)
        {
            var header = new BvhDataHeader();

            try
            {
                header = (BvhDataHeader)Marshal.PtrToStructure(
                    DataHeader, typeof(BvhDataHeader)
                    );
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                return;
            }

            var actor = FindOrCreateActor((int)header.AvatarIndex);

            actor.OnReceivedMotionData(header, data);
        }
示例#7
0
        public virtual void OnFrameDataReceived(IntPtr DataHeader, IntPtr data)
        {
            BvhDataHeader header = new BvhDataHeader();

            try
            {
                header = (BvhDataHeader)Marshal.PtrToStructure(DataHeader, typeof(BvhDataHeader));
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            int         actorID = (int)header.AvatarIndex;
            NeuronActor actor   = null;

            lock (actorCreateDestroyLock)
            {
                // find active actor
                actor = FindActiveActor(actorID);
                if (actor != null)
                {
                    // if actor is active
                    actor.OnReceivedMotionData(header, data);
                }
                else
                {
                    // find suspended actor
                    actor = FindSuspendedActor(actorID);
                    if (actor == null)
                    {
                        // if no such actor, create one
                        actor = CreateActor(actorID);
                    }

                    actor.OnReceivedMotionData(header, data);
                }
            }
        }
        private void bvhDataReceived(IntPtr customObject, IntPtr sockRef, IntPtr header, IntPtr data)
        {
            _bvhHeader = (BvhDataHeader)Marshal.PtrToStructure(header, typeof(BvhDataHeader));

            // Change the buffer length if necessary
            if (_bvhHeader.DataCount != _valuesBuffer.Length)
            {
                _valuesBuffer = new float[_bvhHeader.DataCount];
            }

            Marshal.Copy(data, _valuesBuffer, 0, (int)_bvhHeader.DataCount);
            //_valuesBuffer = (float[])Marshal.PtrToStructure(data, typeof(float[_bvhHeader.DataCount]));

            if (sockRef == this.sockTCPRef)
            {
                _frameCount++;

                this.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    int index = cbBoneID.SelectedIndex;
                    UpdateBvhDataUI(_valuesBuffer, index, _bvhHeader.bWithDisp == 1 ? true : false);
                    txtLog.Text = _frameCount.ToString();
                }));
            }

            if (sockRef == this.sockUDPRef)
            {
                _frameCount++;

                this.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    int index = cbBoneID.SelectedIndex;
                    UpdateBvhDataUI(_valuesBuffer, index, _bvhHeader.bWithDisp == 1 ?  true : false);
                    txtLog.Text = _frameCount.ToString();
                }));
            }
        }