void ReceiveInfo(byte[] dataStream) { filling = true; MemoryStream stream = new MemoryStream(dataStream); stream.Position = 0; BinaryFormatter bf = new BinaryFormatter(); KPCL pcl = (KPCL)bf.Deserialize(stream); if (pcl.isFirst) { pclList.Clear(); } pclList.Add(pcl); filling = false; // now you can use the recieved data however you need to! }
// Use this for initialization void Start() { PlayerPrefUpdateBroadcast.Instance.OnPlayerPrefsUpdated += OnPlayerPrefsUpdated; if (loadConfigOnStart) { loadConfig(); } kinect = KinectSensor.GetDefault(); if (kinect != null) { mapper = kinect.CoordinateMapper; var frameDesc = kinect.DepthFrameSource.FrameDescription; // Downsample to lower resolution // CreateMesh(frameDesc.Width / _DownsampleSize, frameDesc.Height / _DownsampleSize); depthWidth = frameDesc.Width; depthHeight = frameDesc.Height; depthMapSize = depthHeight * depthWidth / downSample; Debug.Log("Kinect Depth Width :" + depthWidth + " / Height : " + depthHeight); if (!kinect.IsOpen) { kinect.Open(); } } depthManager = GetComponent <DepthSourceManager>(); if (useTCLStreamer) { int numLines = depthHeight / (downSample - 1); pcl = new KPCL[numLines]; for (int i = 0; i < numLines; i++) { pcl[i] = new KPCL(); pcl[i].points = new KPCL.Vector_3[(depthWidth / (downSample - 1))]; } pcl[0].isFirst = true; } }
void Update() { if (filling) { return; } //Debug.Log("PCL List length " + pclList.Count); for (int i = 0; i < pclList.Count; i++) { KPCL pcl = pclList[i]; int numPoints = pcl.points.Length; for (int j = 0; j < numPoints; j++) { Vector3 tPoint = transform.TransformPoint(new Vector3(pcl.points[j].x, pcl.points[j].y, pcl.points[j].z)); Debug.DrawLine(tPoint, tPoint + Vector3.forward * .01f, Color.yellow); } } }