private void calcDataReceived(IntPtr customObject, IntPtr sockRef, IntPtr header, IntPtr data)
        {
            _calcHeader = (CalcDataHeader)Marshal.PtrToStructure(header, typeof(CalcDataHeader));
            // Change the buffer length if necessary
            if (_calcHeader.DataCount != _valuesBufferCalc.Length)
            {
                _valuesBufferCalc = new float[_calcHeader.DataCount];
            }

            Marshal.Copy(data, _valuesBufferCalc, 0, (int)_calcHeader.DataCount);

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

                this.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    int index = cbBoneID2.SelectedIndex;
                    UpdateCalcDataUI(_valuesBufferCalc, index);
                    txtLog.Text = _frameCount.ToString();
                }));
            }

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

                this.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    int index = cbBoneID2.SelectedIndex;
                    UpdateCalcDataUI(_valuesBufferCalc, index);
                    txtLog.Text = _frameCount.ToString();
                }));
            }
        }
Esempio n. 2
0
//		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 );
//			}
//		}

        public void OnReceivedMotionData(CalcDataHeader header, IntPtr data)
        {
            this.CalcdHeader = header;
            try
            {
//				Debug.Log("header::" + header.DataCount + "," + header.FrameIndex + ",name "+header.AvatarName);
                //Marshal.Copy( data, this.data, 0, (int)header.DataCount );
                Marshal.Copy(data, this.data, 0, 338);
                timeStamp = GetTimeStamp();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Esempio n. 3
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;
//            // 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);
//            }
//        }

        public virtual void OnCalcFrameDataReceived(IntPtr CalcDataHeader, IntPtr data)
        {
            var header = new CalcDataHeader();

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

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

            // find active actor
            actor = FindActiveActor(actorID);
            Debug.Log("find actor:" + 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);
            }
        }