// Use this for initialization void Start() { //Application.targetFrameRate = 60; NetworkDataProvider = Resources.FindObjectsOfTypeAll <LeapStreamingProvider>()[0]; LeapDataProvider = Resources.FindObjectsOfTypeAll <LeapServiceProvider>()[0]; switch (FrameEncodingType) { case FrameEncodingEnum.VectorHand: playerState = new VectorFrameEncoding(); NetworkDataProvider.lerpState = new VectorFrameEncoding(); NetworkDataProvider.prevState = new VectorFrameEncoding(); NetworkDataProvider.currentState = new VectorFrameEncoding(); break; case FrameEncodingEnum.CurlHand: playerState = new CurlFrameEncoding(); NetworkDataProvider.lerpState = new CurlFrameEncoding(); NetworkDataProvider.prevState = new CurlFrameEncoding(); NetworkDataProvider.currentState = new CurlFrameEncoding(); break; default: playerState = new VectorFrameEncoding(); NetworkDataProvider.lerpState = new VectorFrameEncoding(); NetworkDataProvider.prevState = new VectorFrameEncoding(); NetworkDataProvider.currentState = new VectorFrameEncoding(); break; } playerState.fillEncoding(handData); }
public override void Start() { base.Start(); rootDirectory = Application.dataPath + "/../SavedRecordings/"; switch (FrameEncodingType) { case FrameEncodingEnum.VectorHand: playerState = new VectorFrameEncoding(); beginInterpolate = new VectorFrameEncoding(); endInterpolate = new VectorFrameEncoding(); frameSize = 170; break; case FrameEncodingEnum.CurlHand: playerState = new CurlFrameEncoding(); beginInterpolate = new CurlFrameEncoding(); endInterpolate = new CurlFrameEncoding(); frameSize = 32; break; default: playerState = new VectorFrameEncoding(); beginInterpolate = new VectorFrameEncoding(); endInterpolate = new VectorFrameEncoding(); frameSize = 170; break; } GetFilesInDirectory(rootDirectory); }
public override void lerp(FrameEncoding a, FrameEncoding b, float alpha) { VectorFrameEncoding start = a as VectorFrameEncoding; VectorFrameEncoding finish = b as VectorFrameEncoding; if (a != null && b != null) { if (!(start.LPos == Vector3.zero || finish.LPos == Vector3.zero)) { LPos = Vector3.LerpUnclamped(start.LPos, finish.LPos, alpha); } else { LPos = Vector3.zero; } if (!(start.RPos == Vector3.zero || finish.RPos == Vector3.zero)) { RPos = Vector3.LerpUnclamped(start.RPos, finish.RPos, alpha); } else { RPos = Vector3.zero; } LRot = Quaternion.SlerpUnclamped(start.LRot, finish.LRot, alpha); RRot = Quaternion.SlerpUnclamped(start.RRot, finish.RRot, alpha); for (int i = 0; i < LBones.Length; i++) { LBones[i] = (byte)((float)start.LBones[i] + alpha * ((float)finish.LBones[i] - (float)start.LBones[i])); RBones[i] = (byte)((float)start.RBones[i] + alpha * ((float)finish.RBones[i] - (float)start.RBones[i])); } } }
public void fillCurrentFrame(FrameEncoding state) { frameID++; //Fill the Bone Lists, Finger Lists, and Hand Objects state.DecodeFrame(frameID, transform, leftbones, rightbones, fingers, LeftHand, RightHand); VisibleHands = 0; if (state.LPos != Vector3.zero) { VisibleHands++; } if (state.RPos != Vector3.zero) { VisibleHands++; } //Use different lists depending on the number of hands (zero-allocation trick) if (VisibleHands == 1) { onehandlist[0] = (LeftHand.PalmPosition == Vector.Zero) ? RightHand : LeftHand; currentFrame.Hands = onehandlist; } else if (VisibleHands == 2) { twohandlist[0] = LeftHand; twohandlist[1] = RightHand; currentFrame.Hands = twohandlist; } else { currentFrame.Hands = nohandlist; } prevVisibleHands = VisibleHands; }
// Use this for initialization void Start() { //Application.targetFrameRate = 60; if (isLocalPlayer) { switch (frameEncodingType) { case FrameEncodingEnum.VectorHand: playerState = new VectorFrameEncoding(); break; case FrameEncodingEnum.CurlHand: playerState = new CurlFrameEncoding(); break; default: playerState = new VectorFrameEncoding(); break; } //LeapDataProvider = HandController.gameObject.AddComponent<LeapServiceProvider>(); leapDataProvider = handController.gameObject.AddComponent <LeapXRServiceProvider>(); //ENABLE THESE AGAIN ONCE THE SERVICE HAS THESE EXPOSED SOMEHOW //LeapDataProvider._temporalWarping = HandController.parent.GetComponent<LeapVRTemporalWarping>(); //LeapDataProvider._temporalWarping.provider = LeapDataProvider; //LeapDataProvider._isHeadMounted = true; //LeapDataProvider.UpdateHandInPrecull = true; } else { networkDataProvider = handController.gameObject.AddComponent <LeapStreamingProvider>(); //Destroy(handController.parent.GetComponent<LeapXRTemporalWarping>()); switch (frameEncodingType) { case FrameEncodingEnum.VectorHand: playerState = new VectorFrameEncoding(); networkDataProvider.lerpState = new VectorFrameEncoding(); networkDataProvider.prevState = new VectorFrameEncoding(); networkDataProvider.currentState = new VectorFrameEncoding(); break; case FrameEncodingEnum.CurlHand: playerState = new CurlFrameEncoding(); networkDataProvider.lerpState = new CurlFrameEncoding(); networkDataProvider.prevState = new CurlFrameEncoding(); networkDataProvider.currentState = new CurlFrameEncoding(); break; default: playerState = new VectorFrameEncoding(); networkDataProvider.lerpState = new VectorFrameEncoding(); networkDataProvider.prevState = new VectorFrameEncoding(); networkDataProvider.currentState = new VectorFrameEncoding(); break; } } //handController.gameObject.AddComponent<LeapHandController>(); playerState.fillEncoding(null); }
public abstract void lerp(FrameEncoding a, FrameEncoding b, float alpha);
public virtual void AddFrameState(FrameEncoding state) { currentState = state; }
public override void AddFrameState(FrameEncoding state) { sampleInterval = Mathf.Clamp(Mathf.Lerp(sampleInterval, Time.realtimeSinceStartup - lastTimeFrameAdded, 0.1f), 0f, 0.5f); lastTimeFrameAdded = Time.realtimeSinceStartup; stateBuffer.Enqueue(state.data); }