private unsafe void OnFrameSet(FrameSet frames) { var points = pointCloud.Calclate(frames.DepthFrame); var pointCount = points.Size; var color = frames.ColorFrame; pointCloud.MapTo(color); if (buffers == null) { image = new byte[color.Stride * color.Height]; var meshCount = 1; while (pointCount / meshCount > 65536) { meshCount *= 2; } pointCount /= meshCount; buffers = new Buffer[meshCount]; for (int i = 0; i < meshCount; ++i) { buffers[i].vertices = new Vector3[pointCount]; buffers[i].texcoords = new Vector2[pointCount]; } } else { pointCount /= buffers.Length; } color.CopyTo(image); Vector3 *vs = (Vector3 *)points.Vertices; Vector2 *ts = (Vector2 *)points.TextureCoordinates; for (int i = 0; i < buffers.Length; ++i) { fixed(Vector3 *vd = &buffers[i].vertices[0]) fixed(Vector2 * td = &buffers[i].texcoords[0]) { NativeCopyMemory(vd, vs, (uint)(sizeof(Vector3) * pointCount)); NativeCopyMemory(td, ts, (uint)(sizeof(Vector2) * pointCount)); vs += pointCount; ts += pointCount; } } f.Set(); }