protected virtual void recoverObjectData() { // Instantiating the Container and the lists that come with it if (!recovered) { recovered = true; recoveredContainer = HandSerializer.ReadFromBinaryFile <FrameContainer>(@"C:\Users\Brian\Desktop\test.bin"); recoveredFrames = recoveredContainer.playbackFrames; recoveredOffsets = recoveredContainer.playbackOffsets; recoveredTimeStamps = recoveredContainer.playbackTimestamps; recoveredInterpolationTimes = recoveredContainer.playbackInterpolationTimes; Debug.Log("hey!"); } // Setting the values each time... Hopefully this works? if (whichFrame < 300) { Debug.Log("Playing back frame " + whichFrame); whichFrame++; } if (whichFrame == 300) { Debug.Log("Finished Playback!"); } }
protected virtual void FixedUpdate() { if (_frameOptimization == FrameOptimizationMode.ReuseUpdateForPhysics) { DispatchFixedFrameEvent(_transformedUpdateFrame); return; } if (_useInterpolation) { long timestamp; switch (_frameOptimization) { case FrameOptimizationMode.None: // I think that this is the one that actually matters. (aka is getting used) // By default we use Time.fixedTime to ensure that our hands are on the same // timeline as Update. We add an extrapolation value to help compensate // for latency. float extrapolatedTime = Time.fixedTime + CalculatePhysicsExtrapolation(); timestamp = (long)(extrapolatedTime * S_TO_NS) + _unityToLeapOffset; break; case FrameOptimizationMode.ReusePhysicsForUpdate: // If we are re-using physics frames for update, we don't even want to care // about Time.fixedTime, just grab the most recent interpolated timestamp // like we are in Update. timestamp = CalculateInterpolationTime() + (ExtrapolationAmount * 1000); break; default: throw new System.InvalidOperationException( "Unexpected frame optimization mode: " + _frameOptimization); } if (capturing) { _leapController.GetInterpolatedFrame(_untransformedFixedFrame, timestamp); //BRIAN CHECK THIS OUT if (amountCaptured < 300) { capturedObjectStamps.Add(timestamp); Frame clonedFrame = ObjectCopier.Clone(_untransformedFixedFrame); capturedObjects.Add(clonedFrame); } else { if (allCaptured && !allObjectCaptured) { objectContainer.playbackFrames = capturedObjects; objectContainer.playbackTimestamps = capturedObjectStamps; HandSerializer.WriteToBinaryFile(@"C:\Users\Brian\Desktop\move.bin", testContainer); Debug.Log("All Physics Data Captured!"); allObjectCaptured = true; } } } else { if (!objectRecovered) { objectRecovered = true; recoveredObjectContainer = HandSerializer.ReadFromBinaryFile <FrameContainer>(@"C:\Users\Brian\Desktop\move.bin"); recoveredObjectFrames = recoveredObjectContainer.playbackFrames; recoveredObjectStamps = recoveredObjectContainer.playbackTimestamps; } else { _untransformedFixedFrame = recoveredObjectFrames[whichFrame]; timestamp = recoveredObjectStamps[whichFrame]; _leapController.GetInterpolatedFrame(_untransformedFixedFrame, timestamp); } } } else { _leapController.Frame(_untransformedFixedFrame); } if (_untransformedFixedFrame != null) { transformFrame(_untransformedFixedFrame, _transformedFixedFrame); DispatchFixedFrameEvent(_transformedFixedFrame); } }