Beispiel #1
0
 public void SetupInstance()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Beispiel #2
0
    // Token: 0x06004F00 RID: 20224 RVA: 0x001A8CC8 File Offset: 0x001A70C8
    private void Update()
    {
        PoseRecorder componentInParent = base.GetComponentInParent <PoseRecorder>();

        if (componentInParent != null && componentInParent.enabled && !this._culled)
        {
            componentInParent.DoAdjustment(Time.time);
        }
        SyncPhysics componentInParent2 = base.GetComponentInParent <SyncPhysics>();

        if (componentInParent2 != null && componentInParent2.enabled)
        {
            componentInParent2.DoPositionSync((double)Time.time, (double)Time.deltaTime);
        }
        if (!this._inited)
        {
            return;
        }
        if (this._useVrcTrackedIk)
        {
            this.vrcTrackedIk.isCulled = this._culled;
        }
        if (this._culled)
        {
            return;
        }
        if (!this._reportedUSpeakMoveError && !this._completedUSpeakMove && this._uspeakT != null && Networking.IsObjectReady(this._uspeakT.gameObject))
        {
            USpeakPhotonSender3D component = this._uspeakT.GetComponent <USpeakPhotonSender3D>();
            if (this._cammountT != null && component != null && component.IsInitialized)
            {
                if (this._useLimbIK || this._useVrcTrackedIk)
                {
                    if (this._uspeakT.parent != this.HeadEffector.transform)
                    {
                        this._uspeakT.parent = this.HeadEffector.transform;
                        this._emojiT.parent  = this.HeadEffector.transform;
                        Debug.Log("IK[" + this._player.name + "]: USpeak moved to head effector.");
                    }
                }
                else if (this._uspeakT.parent != this._cammountT)
                {
                    this._uspeakT.parent = this._cammountT;
                    this._emojiT.parent  = this._cammountT;
                    Debug.Log("IK[" + this._player.name + "]: USpeak moved to camera mount.");
                }
                this._uspeakT.localPosition = this._uspeakLocalPos;
                this._uspeakT.localRotation = this._uspeakLocalRot;
                this._emojiT.localPosition  = this._emojiLocalPos;
                this._emojiT.localRotation  = this._emojiLocalRot;
                this._completedUSpeakMove   = true;
            }
            if (VRC.Network.IsNetworkSettled)
            {
                this._elapsedUSpeakTimeToMove += Time.deltaTime;
                if (this._elapsedUSpeakTimeToMove > 10f)
                {
                    Debug.LogError("IK[" + this._player.name + "]: USpeak move took too long. aborting.");
                    this._reportedUSpeakMoveError = true;
                }
            }
        }
        if (this._modelAnimator != null && this._modelAnimator.isHuman)
        {
            float num  = 2f;
            float num2 = 1.5f;
            float num3 = 2f;
            float num4 = 2f;
            float num5 = 2f;
            float num6 = 10f;
            float num7 = 5f;
            bool  flag = false;
            if (this.isLocalPlayer)
            {
                float num8 = VRCTrackingManager.GetPlayerUprightAmount();
                if (this._locoLayer >= 0)
                {
                    if (this._useLimbIK)
                    {
                        num8 = 1f;
                    }
                    if (this.motion.IsImmobilized)
                    {
                        this.SetFloatParameter(this._modelAnimator, "HeightScale", 1f);
                    }
                    else
                    {
                        this.SetFloatParameter(this._modelAnimator, "HeightScale", num8);
                    }
                }
                this.motion.StandingHeight = num8;
                this.UpdateTracking();
                if (this.motion.isLocomoting)
                {
                    if (!this._wasLoco)
                    {
                        this._wasLoco = true;
                        flag          = true;
                    }
                    if (this._player.GetVRMode() && this._useVrcTrackedIk && !this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.headPosWeight = 1f;
                        this.headRotWeight = 1f;
                    }
                    else
                    {
                        this.headRotWeight = 0f;
                        this.headPosWeight = 0f;
                    }
                    this.lowerBodyWeight = 0f;
                    this._locoWeight     = 1f;
                }
                else
                {
                    if (this._wasLoco)
                    {
                        this._wasLoco = false;
                        flag          = true;
                    }
                    this.lowerBodyWeight = 1f;
                    this._locoWeight     = 0f;
                }
                if (this._locoLayer >= 0)
                {
                    float num9 = this.GetLayerWeight(this._modelAnimator, this._locoLayer);
                    if (this.motion.IsImmobilized)
                    {
                        num9 = this._locoWeight;
                    }
                    else
                    {
                        num9 = Mathf.MoveTowards(num9, this._locoWeight, Time.deltaTime * num2);
                    }
                    this.SetLayerWeight(this._modelAnimator, this._locoLayer, num9);
                }
                if (this._useLimbIK)
                {
                    this.limbik.LeftPosWeight  = Mathf.MoveTowards(this.limbik.LeftPosWeight, this.leftWeight, Time.deltaTime * num);
                    this.limbik.RightPosWeight = Mathf.MoveTowards(this.limbik.RightPosWeight, this.rightWeight, Time.deltaTime * num);
                    this.limbik.HeadPosWeight  = Mathf.MoveTowards(this.limbik.HeadPosWeight, this.headPosWeight, Time.deltaTime * num3);
                    this.limbik.LeftRotWeight  = this.limbik.LeftPosWeight;
                    this.limbik.RightRotWeight = this.limbik.RightPosWeight;
                    this.limbik.HeadRotWeight  = this.limbik.HeadPosWeight;
                }
                if (this._useVrcTrackedIk)
                {
                    if (flag)
                    {
                        this.vrcTrackedIk.LocomotionChange(this._wasLoco);
                    }
                    if (this.motion.IsImmobilized)
                    {
                        this.vrcTrackedIk.LeftHandWeight  = this.leftWeight;
                        this.vrcTrackedIk.RightHandWeight = this.rightWeight;
                        this.vrcTrackedIk.HeadPosWeight   = this.headPosWeight;
                        this.vrcTrackedIk.HeadRotWeight   = this.headRotWeight;
                        this.vrcTrackedIk.LowerBodyWeight = this.lowerBodyWeight;
                    }
                    else
                    {
                        this.vrcTrackedIk.LeftHandWeight  = Mathf.MoveTowards(this.vrcTrackedIk.LeftHandWeight, this.leftWeight, Time.deltaTime * num);
                        this.vrcTrackedIk.RightHandWeight = Mathf.MoveTowards(this.vrcTrackedIk.RightHandWeight, this.rightWeight, Time.deltaTime * num);
                        this.vrcTrackedIk.HeadRotWeight   = Mathf.MoveTowards(this.vrcTrackedIk.HeadRotWeight, this.headRotWeight, Time.deltaTime * num3);
                        if (this.vrcTrackedIk.hasLowerBodyTracking)
                        {
                            this.vrcTrackedIk.LowerBodyWeight = this.lowerBodyWeight;
                            this.vrcTrackedIk.HeadPosWeight   = this.headPosWeight;
                        }
                        else
                        {
                            if (this.headPosWeight == 1f)
                            {
                                this.vrcTrackedIk.HeadPosWeight = this.headPosWeight;
                            }
                            else
                            {
                                this.vrcTrackedIk.HeadPosWeight = Mathf.MoveTowards(this.vrcTrackedIk.HeadPosWeight, this.headPosWeight, Time.deltaTime * num3);
                            }
                            this.vrcTrackedIk.LowerBodyWeight = Mathf.MoveTowards(this.vrcTrackedIk.LowerBodyWeight, this.lowerBodyWeight, Time.deltaTime * num4);
                        }
                    }
                }
                if (this._useVrcTrackedIk)
                {
                    if (this.motion.IsImmobilized)
                    {
                        this.vrcTrackedIk.SolverWeight = this.solverWeight;
                    }
                    else if (this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num7);
                    }
                    else
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num5);
                    }
                }
            }
            else
            {
                float standingHeight = this.motion.StandingHeight;
                if (this._locoLayer >= 0)
                {
                    this.SetFloatParameter(this._modelAnimator, "HeightScale", standingHeight);
                }
                if (this.motion.isLocomoting)
                {
                    if (!this._wasLoco)
                    {
                        this._wasLoco    = true;
                        flag             = true;
                        this._locoWeight = 1f;
                    }
                    if (!this._player.GetVRMode() || !this._useVrcTrackedIk || this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.headPosWeight = 0f;
                    }
                    this.lowerBodyWeight = 0f;
                }
                else if (this._wasLoco)
                {
                    this._wasLoco    = false;
                    flag             = true;
                    this._locoWeight = 0f;
                }
                Vector3 position  = this._modelAnimator.GetBoneTransform(HumanBodyBones.Head).position;
                Vector3 position2 = this.LeftEffector.transform.position;
                Vector3 position3 = this.RightEffector.transform.position;
                if (this._locoLayer >= 0)
                {
                    float num10 = this.GetLayerWeight(this._modelAnimator, this._locoLayer);
                    num10 = Mathf.MoveTowards(num10, this._locoWeight, Time.deltaTime * num2);
                    this.SetLayerWeight(this._modelAnimator, this._locoLayer, num10);
                }
                if (this._useLimbIK)
                {
                    this.limbik.LeftPosWeight  = Mathf.Min(this.leftWeight, 1f);
                    this.limbik.LeftRotWeight  = Mathf.Min(this.leftWeight, 1f);
                    this.limbik.RightPosWeight = Mathf.Min(this.rightWeight, 1f);
                    this.limbik.RightRotWeight = Mathf.Min(this.rightWeight, 1f);
                    this.limbik.HeadPosWeight  = Mathf.Min(this.headPosWeight, 1f);
                    this.limbik.HeadRotWeight  = Mathf.Min(this.headRotWeight, 1f);
                }
                if (this._useVrcTrackedIk)
                {
                    if (flag)
                    {
                        this.vrcTrackedIk.LocomotionChange(this._wasLoco);
                    }
                    this.vrcTrackedIk.LeftHandWeight  = Mathf.MoveTowards(this.vrcTrackedIk.LeftHandWeight, this.leftWeight, Time.deltaTime * num);
                    this.vrcTrackedIk.RightHandWeight = Mathf.MoveTowards(this.vrcTrackedIk.RightHandWeight, this.rightWeight, Time.deltaTime * num);
                    this.vrcTrackedIk.HeadRotWeight   = Mathf.MoveTowards(this.vrcTrackedIk.HeadRotWeight, this.headRotWeight, Time.deltaTime * num3);
                    if (this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.vrcTrackedIk.LowerBodyWeight = this.lowerBodyWeight;
                        this.vrcTrackedIk.HeadPosWeight   = this.headPosWeight;
                    }
                    else
                    {
                        this.vrcTrackedIk.LowerBodyWeight = Mathf.MoveTowards(this.vrcTrackedIk.LowerBodyWeight, this.lowerBodyWeight, Time.deltaTime * num4);
                        this.vrcTrackedIk.HeadPosWeight   = Mathf.MoveTowards(this.vrcTrackedIk.HeadPosWeight, this.headPosWeight, Time.deltaTime * num3);
                    }
                    if (this.motion.IsImmobilized)
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num6);
                    }
                    else if (this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num7);
                    }
                    else
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num5);
                    }
                }
                this.leftWeight      = Mathf.Max(this.leftWeight - Time.deltaTime, 0f);
                this.rightWeight     = Mathf.Max(this.rightWeight - Time.deltaTime, 0f);
                this.headPosWeight   = Mathf.Max(this.headPosWeight - Time.deltaTime, 0f);
                this.headRotWeight   = Mathf.Max(this.headRotWeight - Time.deltaTime, 0f);
                this.lowerBodyWeight = Mathf.Max(this.lowerBodyWeight - Time.deltaTime, 0f);
            }
            if (flag)
            {
                this.motion.Reset();
                if (this._useVrcTrackedIk)
                {
                    this.vrcTrackedIk.Reset(false);
                }
            }
        }
    }
Beispiel #3
0
    // Token: 0x06004F57 RID: 20311 RVA: 0x001AD0AC File Offset: 0x001AB4AC
    public void DoAdjustment(float now)
    {
        if (base.isMine || this.animator == null)
        {
            return;
        }
        IList <PoseRecorder.PoseEvent> eventList = this.eventHistory;

        if (PoseRecorder.f__mg0 == null)
        {
            PoseRecorder.f__mg0 = new TweenFunctions.TweenFunction <PoseRecorder.PoseEvent>(PoseRecorder.LinearTweenFunction);
        }
        PoseRecorder.PoseEvent poseEvent = TweenFunctions.Tween <PoseRecorder.PoseEvent>(eventList, PoseRecorder.f__mg0, (double)now - VRC.Network.SimulationDelay(base.Owner), this.ExpectedInterval, -1);
        if (poseEvent == null || poseEvent.Contains(PoseRecorder.PoseContents.Nothing))
        {
            return;
        }
        if (poseEvent.Contains(PoseRecorder.PoseContents.BaseSkeleton))
        {
            this.animator.enabled = false;
            for (int i = 0; i < 19; i++)
            {
                Quaternion localRotation = this.bones[i].localRotation;
                PoseRecorder.MaybeSetRotation(this.bones[i].localRotation, poseEvent.boneRotations[i], ref localRotation);
                this.bones[i].localRotation = localRotation;
            }
        }
        if (this.ik != null)
        {
            if (poseEvent.Contains(PoseRecorder.PoseContents.HandEffectorPositionOrientationL))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHandEffectorLeft), new PoseRecorder.SetEffector(this.ik.SetRemoteHandEffectorLeft), poseEvent.leftHandPosition, poseEvent.leftHandRotation);
            }
            else
            {
                this.ik.ClearRemoteHandEffectorLeft();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.HandEffectorPositionOrientationR))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHandEffectorRight), new PoseRecorder.SetEffector(this.ik.SetRemoteHandEffectorRight), poseEvent.rightHandPosition, poseEvent.rightHandRotation);
            }
            else
            {
                this.ik.ClearRemoteHandEffectorRight();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.HeadEffectorPositionOrientation))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHeadEffector), new PoseRecorder.SetEffector(this.ik.SetRemoteHeadEffector), poseEvent.headPosition, poseEvent.headRotation);
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.HipEffectorPositionOrientation))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHipEffector), new PoseRecorder.SetEffector(this.ik.SetRemoteHipEffector), poseEvent.hipPosition, poseEvent.hipRotation);
            }
            else
            {
                this.ik.ClearRemoteHipEffector();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.FootEffectorPositionOrientationL))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetFootEffectorLeft), new PoseRecorder.SetEffector(this.ik.SetRemoteFootEffectorLeft), poseEvent.leftFootPosition, poseEvent.leftFootRotation);
            }
            else
            {
                this.ik.ClearRemoteFootEffectorLeft();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.FootEffectorPositionOrientationR))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetFootEffectorRight), new PoseRecorder.SetEffector(this.ik.SetRemoteFootEffectorRight), poseEvent.rightFootPosition, poseEvent.rightFootRotation);
            }
            else
            {
                this.ik.ClearRemoteFootEffectorRight();
            }
        }
        if (poseEvent.Contains(PoseRecorder.PoseContents.HandGesture))
        {
            if (this.handgest != null)
            {
                this.handgest.SetRemoteHandGestures((int)poseEvent.handGestureLeft, (int)poseEvent.handGestureRight);
            }
        }
        else if (this.handgest != null)
        {
            this.handgest.ClearRemoteHandGestures();
        }
        if (this.offset != null && poseEvent.Contains(PoseRecorder.PoseContents.RootOffset))
        {
            this.offset.localPosition = Vector3.zero;
        }
        if (this.animator != null && poseEvent.Contains(PoseRecorder.PoseContents.BaseSkeleton))
        {
            this.animator.enabled = true;
        }
        if (base.Owner.playerNet.WasRecentlyDiscontinuous)
        {
            this.ik.Reset(true);
        }
    }
Beispiel #4
0
    // Token: 0x06004F53 RID: 20307 RVA: 0x001ACCEC File Offset: 0x001AB0EC
    private static PoseRecorder.PoseEvent LinearTweenFunction(IList <PoseRecorder.PoseEvent> l, int idx, double delta)
    {
        PoseRecorder.PoseEvent poseEvent  = l[idx];
        PoseRecorder.PoseEvent poseEvent2 = l[TweenFunctions.FindNextIndex <PoseRecorder.PoseEvent>(l, idx)];
        float t = (float)delta;

        PoseRecorder.PoseEvent poseEvent3 = new PoseRecorder.PoseEvent
        {
            poseContents = (poseEvent.poseContents & poseEvent2.poseContents),
            timeReceived = (poseEvent2.timeReceived - poseEvent.timeReceived) * delta + poseEvent.timeReceived
        };
        if (poseEvent2.Contains(PoseRecorder.PoseContents.HandGesture))
        {
            poseEvent3.handGestureLeft  = poseEvent2.handGestureLeft;
            poseEvent3.handGestureRight = poseEvent2.handGestureRight;
            poseEvent3.poseContents    |= 16;
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.Nothing))
        {
            return(poseEvent3);
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.RootOffset))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.rootOffset, Vector3.Lerp(poseEvent.rootOffset, poseEvent2.rootOffset, t), ref poseEvent3.rootOffset);
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.BaseSkeleton))
        {
            poseEvent3.boneRotations = new Quaternion[19];
            for (int i = 0; i < 19; i++)
            {
                poseEvent3.boneRotations[i] = Quaternion.Slerp(poseEvent.boneRotations[i], poseEvent2.boneRotations[i], t).Normalize();
            }
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.HandEffectorPositionOrientationL))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.leftHandPosition, Vector3.Lerp(poseEvent.leftHandPosition, poseEvent2.leftHandPosition, t), ref poseEvent3.leftHandPosition);
            poseEvent3.leftHandRotation = Quaternion.Slerp(poseEvent.leftHandRotation, poseEvent2.leftHandRotation, t).Normalize();
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.HandEffectorPositionOrientationR))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.rightHandPosition, Vector3.Lerp(poseEvent.rightHandPosition, poseEvent2.rightHandPosition, t), ref poseEvent3.rightHandPosition);
            poseEvent3.rightHandRotation = Quaternion.Slerp(poseEvent.rightHandRotation, poseEvent2.rightHandRotation, t).Normalize();
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.HeadEffectorPositionOrientation))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.headPosition, Vector3.Lerp(poseEvent.headPosition, poseEvent2.headPosition, t), ref poseEvent3.headPosition);
            poseEvent3.headRotation = Quaternion.Slerp(poseEvent.headRotation, poseEvent2.headRotation, t).Normalize();
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.HipEffectorPositionOrientation))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.hipPosition, Vector3.Lerp(poseEvent.hipPosition, poseEvent2.hipPosition, t), ref poseEvent3.hipPosition);
            poseEvent3.hipRotation = Quaternion.Slerp(poseEvent.hipRotation, poseEvent2.hipRotation, t).Normalize();
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.FootEffectorPositionOrientationL))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.leftFootPosition, Vector3.Lerp(poseEvent.leftFootPosition, poseEvent2.leftFootPosition, t), ref poseEvent3.leftFootPosition);
            poseEvent3.leftFootRotation = Quaternion.Slerp(poseEvent.leftFootRotation, poseEvent2.leftFootRotation, t).Normalize();
        }
        if (poseEvent3.Contains(PoseRecorder.PoseContents.FootEffectorPositionOrientationR))
        {
            PoseRecorder.MaybeSetPosition(poseEvent.rightFootPosition, Vector3.Lerp(poseEvent.rightFootPosition, poseEvent2.rightFootPosition, t), ref poseEvent3.rightFootPosition);
            poseEvent3.rightFootRotation = Quaternion.Slerp(poseEvent.rightFootRotation, poseEvent2.rightFootRotation, t).Normalize();
        }
        return(poseEvent3);
    }