private void InitialisePlayback(KinectFramesStore firstChunk, FileSystem.FileInfo fileInfo)
        {
            // Store the first chunk and ensure that the frame iterator is at the first position
            currentChunk = firstChunk;
            currentChunk.Reset();

            // Initialise an empty downsampled mesh as a 2D plane with the correct height and width
            // attributes that match the recording images
            InitialiseMeshData(fileInfo.MeshWidth, fileInfo.MeshHeight);

            // Align the centre of the mesh to its parent container origin, which by default is world
            // space
            AlignMeshToWorldOrigin(fileInfo.MeshWidth, fileInfo.MeshHeight, fileInfo.DepthScale,
                                   fileInfo.MinReliableDistance, fileInfo.MaxReliableDistance);

            // Load in the first frame to the mesh by moving the iterator up and then reading
            // the current frame value
            currentChunk.MoveNext();
            RefreshMeshData(fileInfo.MeshWidth, fileInfo.MeshHeight, currentChunk.Current);

            // Finally, initialise the timer between frames
            frameTimeDelta = 0.0f;
        }
        private void CheckForMeshUpdate()
        {
            // If on the last frame, simply return out
            if (LastFrame)
            {
                return;
            }

            // Otherwise, start by adding the time from the last frame onto
            // the timer variable
            frameTimeDelta += Time.deltaTime;

            if (!lastChunk && nextChunk == null)
            {
                // If the last chunk flag is false and the next chunk is null,
                // get a new one from the playback manager
                nextChunk = PlaybackManager.GetNextChunk();

                if (nextChunk == null)
                {
                    // If it is still null, there are no more chunks left, so set
                    // the last chunk flag
                    if (!lastChunk)
                    {
                        lastChunk = true;
                    }
                }
            }

            // If the current chunk has a next frame, this check will automatically move
            // up the iterator position, so store a reference to this next frame
            KinectFramesStore.KinectFrame nextFrame;
            if (currentChunk.MoveNext())
            {
                nextFrame = currentChunk.Current;
            }
            else
            {
                // Otherwise, the chunk is at its last frame, so first check if this is
                // the last chunk
                if (lastChunk)
                {
                    // If it is, flip the last frame flag and return.
                    LastFrame = true;
                    return;
                }
                else
                {
                    // Otherwise, a next chunk is available, so switch this out for the
                    // current chunk and dereference the next chunk pointer
                    currentChunk = new KinectFramesStore(nextChunk);
                    nextChunk    = null;

                    // Then, ensure that the iterator component it is at the first position,
                    // move the pointer up by one and store a local reference to the next frame
                    currentChunk.Reset();
                    currentChunk.MoveNext();
                    nextFrame = currentChunk.Current;
                }
            }

            // If the timer count is greater than or equal to the time between this frame and
            // the next, load in the next frame's data to the mesh and reset the frame timer
            if (frameTimeDelta >= nextFrame.FrameDeltaTime)
            {
                RefreshMeshData(PlaybackManager.FileInfoOpen.MeshWidth, PlaybackManager.FileInfoOpen.MeshHeight, nextFrame);
                frameTimeDelta = 0.0f;
            }
            else
            {
                // Otherwise, the frame can not be loaded yet, so move the iterator pointer
                // position back by one so that the next update will carry out the check on
                // the same frame
                currentChunk.MovePrev();
            }
        }