コード例 #1
0
        // ReSharper disable once ParameterHidesMember
        private void CalibrateLeg(VRIK avatar, Transform lastFootBone)
        {
            // adjust tracker position to last transform position
            var target = TargetObject.transform;

            target.position = new Vector3(target.position.x, lastFootBone.position.y - avatar.references.root.position.y, target.position.z);

            // matches the tracker rotation and last transform rotation
            target.rotation = lastFootBone.rotation;

            // align the target forward axis with the tracker forward axis. the other axis remain unchanged.
            var forwardOfTracker = GetNearestAxis(avatar.references.root.forward, transform);
            var toForwardVector  = transform.rotation * forwardOfTracker;

            var forwardOfTransform = GetNearestAxis(avatar.references.root.forward, lastFootBone);
            var fromForwardVector  = lastFootBone.rotation * forwardOfTransform;

            // remove upwards/downwards vector
            toForwardVector.y = fromForwardVector.y;

            // rotate transform
            var angle = Vector3.Angle(lastFootBone.rotation * fromForwardVector, target.rotation * toForwardVector);
            var axis  = -Vector3.Cross(toForwardVector, fromForwardVector);

            target.rotation = Quaternion.AngleAxis(angle, axis) * target.rotation;
        }
コード例 #2
0
ファイル: BvhRecorder.cs プロジェクト: MetaGenAI/MetaGenNeos
 public void StartRecordingAvatars(Dictionary <RefID, Slot> avatar_roots, string override_filename = null)
 {
     foreach (var item in avatar_roots)
     {
         RefID user_id  = item.Key;
         Slot  rootSlot = item.Value;
         VRIK  comp     = rootSlot.GetComponentInChildren <VRIK>();
         if (comp != null)
         {
             IKSolverVR solver = (IKSolverVR)comp.Solver;
             boness[user_id] = solver.BoneReferences;
             string filename = "";
             if (override_filename != null)
             {
                 filename = saving_folder + "/" + override_filename + "_mocap.bvh";
             }
             else
             {
                 filename = saving_folder + "/" + user_id.ToString() + "_mocap.bvh";
             }
             fileWriters[user_id] = new System.IO.StreamWriter(filename);
             filenames[user_id]   = filename;
             BvhHeaderWrite(fileWriters[user_id], boness[user_id]);
         }
     }
     isRecording = true;
 }
コード例 #3
0
        private void Start()
        {
            _vrikManager  = GetComponentInChildren <VRIKManager>();
            _dynamicBones = GetComponentsInChildren <BeatSaberDynamicBone::DynamicBone>();

            _vrik = _ikHelper.InitializeVRIK(_vrikManager, transform);

            _fixTransforms      = _vrikManager.fixTransforms;
            _vrik.fixTransforms = false; // FixTransforms is manually called in Update

            foreach (TwistRelaxer twistRelaxer in _twistRelaxers)
            {
                twistRelaxer.ik      = _vrik;
                twistRelaxer.enabled = true;
            }

            if (_vrikManager.solver_spine_maintainPelvisPosition > 0 && !_input.allowMaintainPelvisPosition)
            {
                _logger.Warning("solver.spine.maintainPelvisPosition > 0 is not recommended because it can cause strange pelvis rotation issues. To allow maintainPelvisPosition > 0, please set allowMaintainPelvisPosition to true for your avatar in the configuration file.");
                _vrik.solver.spine.maintainPelvisPosition = 0;
            }

            _input.inputChanged += OnInputChanged;

            UpdateSolverTargets();
            SetLocomotionEnabled(_avatar.isLocomotionEnabled);
        }
コード例 #4
0
    public void ApplyPose(bool leftHand, string poseName)
    {
        if (_vrIk == null)
        {
            _vrIk = GetComponent <VRIK>();
        }
        if (_vrIk == null)
        {
            Debug.LogError("This script requires a VRIK component on the same object", gameObject);
            return;
        }
        Transform pose       = GetPoseByName(poseName);
        Transform targetHand = leftHand ? _vrIk.references.leftHand : _vrIk.references.rightHand;
        HandPoser handPoser  = targetHand.GetComponent <HandPoser>();

        if (handPoser == null)
        {
            handPoser = targetHand.gameObject.AddComponent <HandPoser>();
        }
        else
        {
            handPoser.weight = 1f;
        }
        handPoser.poseRoot = pose;
    }
コード例 #5
0
 private void SetVRIK(GameObject model)
 {
     vrik = model.AddComponent<VRIK>();
     vrik.solver.IKPositionWeight = 0f;
     vrik.solver.leftArm.stretchCurve = new AnimationCurve();
     vrik.solver.rightArm.stretchCurve = new AnimationCurve();
     vrik.UpdateSolverExternal();
 }
コード例 #6
0
    void Start()
    {
        vrmLookAtHead = GetComponent <VRMLookAtHead>();
        vrIK          = gameObject.AddComponent <VRIK>();

        _SetupVRIK();
        _SetupLockAtHead();
    }
コード例 #7
0
        void Start()
        {
            ik      = GetComponent <VRIK>();
            Targets = GetComponent <HVRIKTargets>();

            ik.solver.SetToReferences(ik.references);
            ik.solver.Initiate(ik.transform);
        }
コード例 #8
0
 private static void VrikInitPatch(VRCVrIkController __instance, VRCPlayer?__2)
 {
     if (__2 != null && __2.prop_Player_0?.prop_APIUser_0?.id == APIUser.CurrentUser?.id)
     {
         FullBodyHandling.LastCalibrationWasInCustomIk = false;
         LastInitializedIk = __instance.field_Private_VRIK_0;
     }
 }
コード例 #9
0
        private void _SetupDummyVRIK(Animator animator)
        {
            //膝のボーンの曲がる方向で膝の向きが決まってしまうため、強制的に膝のボーンを少し前に曲げる
            var leftOffset  = Vector3.zero;
            var rightOffset = Vector3.zero;

            if (this.dummyAnimator != null)
            {
                leftOffset  = _FixKneeBone(this.dummyAnimator.GetBoneTransform(HumanBodyBones.LeftUpperLeg), this.dummyAnimator.GetBoneTransform(HumanBodyBones.LeftLowerLeg), this.dummyAnimator.GetBoneTransform(HumanBodyBones.LeftFoot));
                rightOffset = _FixKneeBone(this.dummyAnimator.GetBoneTransform(HumanBodyBones.RightUpperLeg), this.dummyAnimator.GetBoneTransform(HumanBodyBones.RightLowerLeg), this.dummyAnimator.GetBoneTransform(HumanBodyBones.RightFoot));
                _FixPelvisBone(this.dummyAnimator.GetBoneTransform(HumanBodyBones.Spine), this.dummyAnimator.GetBoneTransform(HumanBodyBones.Hips));
            }

            dummyVrik = animator.GetComponent <VRIK> ();
            if (dummyVrik == null)
            {
                dummyVrik = animator.gameObject.AddComponent <VRIK> ();
            }
            dummyVrik.solver.IKPositionWeight      = 0f;
            dummyVrik.solver.leftArm.stretchCurve  = new AnimationCurve();
            dummyVrik.solver.rightArm.stretchCurve = new AnimationCurve();
            dummyVrik.UpdateSolverExternal();

            //膝のボーンの曲がる方向で膝の向きが決まってしまうため、強制的に膝のボーンを少し前に曲げる
            //if (animator != null)
            //{
            //    unfixKneeBone(leftOffset, animator.GetBoneTransform(HumanBodyBones.LeftLowerLeg), animator.GetBoneTransform(HumanBodyBones.LeftFoot));
            //    unfixKneeBone(rightOffset, animator.GetBoneTransform(HumanBodyBones.RightLowerLeg), animator.GetBoneTransform(HumanBodyBones.RightFoot));
            //}
            //if (animator != null)
            //{
            //    var leftWrist = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm).gameObject;
            //    var rightWrist = animator.GetBoneTransform(HumanBodyBones.RightLowerArm).gameObject;
            //    var leftRelaxer = leftWrist.AddComponent<TwistRelaxer>();
            //    var rightRelaxer = rightWrist.AddComponent<TwistRelaxer>();
            //    leftRelaxer.ik = vrik;
            //    rightRelaxer.ik = vrik;
            //}

            if (dummyAnimator != null)
            {
                dummyAnimator.updateMode = AnimatorUpdateMode.AnimatePhysics;
                dummyAnimator.GetBoneTransform(HumanBodyBones.LeftLowerArm).eulerAngles  = new Vector3(LeftLowerArmAngle, 0, 0);
                dummyAnimator.GetBoneTransform(HumanBodyBones.RightLowerArm).eulerAngles = new Vector3(RightLowerArmAngle, 0, 0);
                dummyAnimator.GetBoneTransform(HumanBodyBones.LeftUpperArm).eulerAngles  = new Vector3(LeftUpperArmAngle, 0, 0);
                dummyAnimator.GetBoneTransform(HumanBodyBones.RightUpperArm).eulerAngles = new Vector3(RightUpperArmAngle, 0, 0);
                _refs.wristRotationFix.SetVRIK(dummyVrik);
            }

#if false
            // 背骨の位置確認用
            AddPointGizmo(animator.GetBoneTransform(HumanBodyBones.Chest));
            AddPointGizmo(animator.GetBoneTransform(HumanBodyBones.Hips));
            AddPointGizmo(animator.GetBoneTransform(HumanBodyBones.Spine));
            AddPointGizmo(animator.GetBoneTransform(HumanBodyBones.Neck));
            AddPointGizmo(animator.GetBoneTransform(HumanBodyBones.Head));
#endif
        }
コード例 #10
0
ファイル: VRC_NpcInternal.cs プロジェクト: Smoothstep/VRChat
    // Token: 0x06005A83 RID: 23171 RVA: 0x001F860C File Offset: 0x001F6A0C
    private void SetAvatarPose(RuntimeAnimatorController rac)
    {
        Animator             componentInChildren  = base.GetComponentInChildren <Animator>();
        VRC_AvatarDescriptor componentInChildren2 = base.GetComponentInChildren <VRC_AvatarDescriptor>();

        if (rac != null)
        {
            componentInChildren.runtimeAnimatorController = rac;
        }
        else if (componentInChildren2 == null)
        {
            componentInChildren.runtimeAnimatorController = this.avatarSwitcher.animatorControllerMale;
        }
        else if (componentInChildren2.Animations == VRC_AvatarDescriptor.AnimationSet.Female)
        {
            componentInChildren.runtimeAnimatorController = this.avatarSwitcher.animatorControllerFemale;
        }
        else
        {
            componentInChildren.runtimeAnimatorController = this.avatarSwitcher.animatorControllerMale;
        }
        int layerIndex  = componentInChildren.GetLayerIndex("Idle Layer");
        int layerIndex2 = componentInChildren.GetLayerIndex("Locomotion Layer");
        int layerIndex3 = componentInChildren.GetLayerIndex("HandLeft");
        int layerIndex4 = componentInChildren.GetLayerIndex("HandRight");

        if (layerIndex >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex, 1f);
        }
        if (layerIndex2 >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex2, 0f);
        }
        if (layerIndex3 >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex3, 0f);
        }
        if (layerIndex4 >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex4, 0f);
        }
        componentInChildren.SetFloat("HeightScale", 1f);
        componentInChildren.SetFloat("HeightScaleNOMOVE", 1f);
        VRIK component = componentInChildren.GetComponent <VRIK>();

        if (component != null)
        {
            component.enabled = false;
        }
        global::LimbIK component2 = componentInChildren.GetComponent <global::LimbIK>();

        if (component2 != null)
        {
            component2.enabled = false;
        }
    }
コード例 #11
0
        private static void ApplyVrIkSettings(VRIK ik)
        {
            var ikSolverVr   = ik.solver;
            var shoulderMode = IkTweaksSettings.ShoulderMode;

            ikSolverVr.leftArm.shoulderRotationMode  = shoulderMode;
            ikSolverVr.rightArm.shoulderRotationMode = shoulderMode;
            ikSolverVr.plantFeet = IkTweaksSettings.PlantFeet;
        }
コード例 #12
0
        public VRIK InitializeVRIK(VRIKManager vrikManager, Transform root)
        {
            VRIK vrik = vrikManager.gameObject.AddComponent <VRIK>();

            CreateTargetsIfMissing(vrikManager, root);
            CopyManagerFieldsToVRIK(vrikManager, vrik);

            return(vrik);
        }
コード例 #13
0
    void Awake()
    {
        animator = transform.root.GetComponentInChildren <Animator>();
        if (animator == null || !animator.isHuman)
        {
            Debug.LogWarning("CharacterController needs a Humanoid Animator to auto-detect biped references. Please assign references manually.");
        }

        ik = gameObject.transform.GetComponent <VRIK>();
    }
コード例 #14
0
 private void maybeAddVrik()
 {
     if (vrik != null)
     {
         return;
     }
     vrik = VrikCreator.initialize(gameObject, leftHand.transform,
                                   rightHand.transform, camera.transform);
     VrikCreator.resetVrikHandTransform(gameObject.GetComponent <Player>());
 }
コード例 #15
0
    void Start()
    {
        //Rigidbodyを取得
        rb = GetComponent <Rigidbody>();
        //ユニティちゃんのAnimatorにアクセスする
        animator = GetComponent <Animator>();

        vrik = GetComponent <VRIK>();

        //ユニティちゃんの現在より少し前の位置を保存
        playerPos = transform.position;
    }
コード例 #16
0
        /// <summary>
        /// Gets the offset between the head target and the actual head bone. Avoids issues when using
        /// the Head transform for calculations.
        /// </summary>
        private Vector3 GetHeadTargetOffset()
        {
            Transform headReference = null;
            Transform headTarget    = null;

            #pragma warning disable 618
            VRIK              vrik              = gameObject.GetComponentInChildren <VRIK>();
            IKManager         ikManager         = gameObject.GetComponentInChildren <IKManager>();
            IKManagerAdvanced ikManagerAdvanced = gameObject.GetComponentInChildren <IKManagerAdvanced>();
            #pragma warning restore 618

            VRIKManager vrikManager = gameObject.GetComponentInChildren <VRIKManager>();

            if (vrikManager)
            {
                if (!vrikManager.references_head)
                {
                    vrikManager.AutoDetectReferences();
                }

                headReference = vrikManager.references_head;
                headTarget    = vrikManager.solver_spine_headTarget;
            }
            else if (vrik)
            {
                vrik.AutoDetectReferences();
                headReference = vrik.references.head;

                if (ikManagerAdvanced)
                {
                    headTarget = ikManagerAdvanced.HeadTarget;
                }
                else if (ikManager)
                {
                    headTarget = ikManager.HeadTarget;
                }
            }

            if (!headReference)
            {
                Plugin.logger.Warn("Could not find head reference; height adjust may be broken");
                return(Vector3.zero);
            }

            if (!headTarget)
            {
                Plugin.logger.Warn("Could not find head target; height adjust may be broken");
                return(Vector3.zero);
            }

            return(headTarget.position - headReference.position);
        }
コード例 #17
0
        protected override GameObject TargetObject => transform.GetChild(1).gameObject; // transform.GetChild(0).gameObject;

        public void Calibrate(VRIK avatar, Vector3 viewPosition)
        {
            if (InputSource != SteamVR_Input_Sources.Head)
            {
                Calibrate(avatar);
                return;
            }

            var target = TargetObject.transform;
            var diff   = viewPosition - (avatar.references.head.position - avatar.references.root.position);

            target.localPosition = -diff;
            target.rotation      = transform.rotation;
        }
コード例 #18
0
    void Awake()
    {
        vrik         = GetComponent <VRIK>();
        initialScale = transform.localScale;

        initialLoco = new IKSolverVR.Locomotion();
        var vrikLoco = vrik.solver.locomotion;

        initialLoco.footDistance  = vrikLoco.footDistance;
        initialLoco.stepThreshold = vrikLoco.stepThreshold;
        initialLoco.maxVelocity   = vrikLoco.maxVelocity;
        initialLoco.stepHeight    = new AnimationCurve(vrikLoco.stepHeight.keys);
        initialLoco.heelHeight    = new AnimationCurve(vrikLoco.heelHeight.keys);
    }
コード例 #19
0
        private void Start()
        {
            window = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();

            VMCEvents.OnModelLoaded += (GameObject CurrentModel) =>
            {
                if (CurrentModel != null)
                {
                    this.CurrentModel = CurrentModel;
                    vrik = CurrentModel.GetComponent <VRIK>();
                }
            };

            KeyboardAction.KeyDownEvent += (object sender, KeyboardEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    if (e.KeyName == "左Shift")
                    {
                        isLeftShiftKeyDown = true;
                    }
                    if (e.KeyName == "右Shift")
                    {
                        isRightShiftKeyDown = true;
                    }
                    if (e.KeyName == "P")
                    {
                        Import(isLeftShiftKeyDown || isRightShiftKeyDown);
                    }
                }
            };

            KeyboardAction.KeyUpEvent += (object sender, KeyboardEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    if (e.KeyName == "左Shift")
                    {
                        isLeftShiftKeyDown = false;
                    }
                    if (e.KeyName == "右Shift")
                    {
                        isRightShiftKeyDown = false;
                    }
                }
            };

            RootObject = new GameObject("TrackerImporter").transform;
        }
コード例 #20
0
ファイル: VrIkHandling.cs プロジェクト: knah/VRCMods
 private static void VrikInitPatch(VRCVrIkController __instance, Animator animator, VRCPlayer?__2)
 {
     if (__2 != null && __2.prop_Player_0?.prop_APIUser_0?.id == APIUser.CurrentUser?.id)
     {
         ourLastIkController  = __instance.field_Private_IkController_0;
         ourLastInitializedIk = __instance.field_Private_VRIK_0;
         ourCachedSolver      = new CachedSolver(ourLastInitializedIk.solver);
         var handler = new HumanPoseHandler(animator.avatar, animator.transform);
         var hips    = animator.GetBoneTransform(HumanBodyBones.Hips);
         ourAnimationsHandler = new AnimationsHandler(handler, hips, in ourCachedSolver);
         ourCustomSpineSolver = new CustomSpineSolver(in ourCachedSolver);
         ourWallFreezeFixer   = new WallFreezeFixer(__instance);
         HandOffsetsManager?.Dispose();
         HandOffsetsManager = new HandOffsetsManager(__instance);
     }
 }
コード例 #21
0
ファイル: HandPoserWindow.cs プロジェクト: srcnalt/InteraktVR
        //	Resets hands to saved default position and pose
        private void ResetHands(VRIK vrIK)
        {
            if (vrIK == null || _handPoseController == null)
            {
                return;
            }

            if (vrIK.references.leftHand != null && _handPoseController.defaultLeftPose != null)
            {
                AssignPose(vrIK.references.leftHand, _handPoseController.defaultLeftPose, true);
            }
            if (vrIK.references.rightHand != null && _handPoseController.defaultRightPose != null)
            {
                AssignPose(vrIK.references.rightHand, _handPoseController.defaultRightPose, true);
            }
        }
コード例 #22
0
    public float UpperArmFixWeight = 0.2f; //0.5では強すぎて肩がねじれる場合がある

    public void SetVRIK(VRIK setIK)
    {
        if (ik != null)
        {
            ik.GetIKSolver().OnPostUpdate -= OnPostUpdate;
        }
        ik = setIK;

        LeftElbowFixItem     = new FixItem(ik.references.leftUpperArm, ik.references.leftForearm, ik.references.leftHand, () => ElbowFixWeight);
        LeftUpperArmFixItem  = new FixItem(ik.references.leftShoulder, ik.references.leftUpperArm, ik.references.leftForearm, () => UpperArmFixWeight);
        RightElbowFixItem    = new FixItem(ik.references.rightUpperArm, ik.references.rightForearm, ik.references.rightHand, () => ElbowFixWeight);
        RightUpperArmFixItem = new FixItem(ik.references.rightShoulder, ik.references.rightUpperArm, ik.references.rightForearm, () => UpperArmFixWeight);

        if (ik != null)
        {
            ik.GetIKSolver().OnPostUpdate += OnPostUpdate;
        }
    }
コード例 #23
0
    public void ClearPose(bool leftHand)
    {
        if (_vrIk == null)
        {
            _vrIk = GetComponent <VRIK>();
        }
        if (_vrIk == null)
        {
            Debug.LogError("This script requires a VRIK component on the same object", gameObject);
            return;
        }
        Transform targetHand = leftHand ? _vrIk.references.leftHand : _vrIk.references.rightHand;
        HandPoser handPoser  = targetHand.GetComponent <HandPoser>();

        if (handPoser != null)
        {
            handPoser.weight = 0f;
        }
    }
コード例 #24
0
    void SetupVRIK(VRIK vrik)
    {
        vrik.AutoDetectReferences();

        vrik.solver.leftLeg.positionWeight  = 0.99f;
        vrik.solver.leftLeg.rotationWeight  = 0.99f;
        vrik.solver.rightLeg.positionWeight = 0.99f;
        vrik.solver.rightLeg.rotationWeight = 0.99f;

        vrik.solver.leftLeg.swivelOffset  = -35;
        vrik.solver.rightLeg.swivelOffset = 35;

        vrik.solver.leftArm.swivelOffset  = 23;
        vrik.solver.rightArm.swivelOffset = -23;

        vrik.solver.spine.pelvisPositionWeight = 0.99f;
        vrik.solver.spine.pelvisRotationWeight = 0.99f;

        vrik.solver.locomotion.weight = 0;
    }
コード例 #25
0
        /// <summary>
        /// IK設定
        /// </summary>
        private void SetIK()
        {
            _vrik = GetComponent <VRIK>();

            if (_vrik == null)
            {
                return;
            }

            var defaultFoot = _vrik.solver.locomotion.footDistance;
            var defaultStep = _vrik.solver.locomotion.stepThreshold;

            // 描画スケールが変更されたら股幅などを変更する
            _stageScaler.StageScale
            .SubscribeWithState2(defaultFoot, defaultStep, (x, defaultFootDistance, defaultStepThreshold) =>
            {
                _vrik.solver.locomotion.footDistance  = defaultFootDistance * x;
                _vrik.solver.locomotion.stepThreshold = defaultStepThreshold * x;
            });
        }
コード例 #26
0
ファイル: Player.cs プロジェクト: imding/VRTKtest
    void Update()   //这个是刷新的意思   以帧为单位的大概每刷新一次1/20秒
    {
        if (photonView.IsMine == false && PhotonNetwork.IsConnected == true)
        {
            return;
        }

        float movex = 0;   //这个代表的是玩家在x轴上的移动

        float movez = 0;   //这个代表的是玩家在z轴上的移动



        // if (Input.GetKey(KeyCode.W))   //这个意思是"当按下W键时"
        // {
        //     movez += m_speed * Time.deltaTime;   //物体获得在z轴方向上的增量   也就是向前
        // }

        // if (Input.GetKey(KeyCode.S))   //按下S键时
        // {
        //     movez -= m_speed * Time.deltaTime;   //后
        // }

        // if (Input.GetKey(KeyCode.A))   //A键
        // {
        //     movex -= m_speed * Time.deltaTime;    //左
        // }

        // if (Input.GetKey(KeyCode.D))   //D键
        // {
        //     movex += m_speed * Time.deltaTime;   //右
        // }

        this.transform.position = CameraRig.position;   //这句代码是把得到的偏移量通过translate(平移函数)给玩家  从而使得玩家的位置得到改变

        VRIK vrik = this.GetComponent <VRIK>();

        vrik.solver.spine.headTarget = GameObject.FindWithTag("Neck").transform;
        vrik.solver.leftArm.target   = GameObject.FindWithTag("LH").transform;
        vrik.solver.rightArm.target  = GameObject.FindWithTag("RH").transform;
    }
コード例 #27
0
    protected virtual void Awake()
    {
        if (vrIK == null)
        {
            vrIK = gameObject.transform.root.GetComponent <VRIK>();
        }
        if (vrIK == null)
        {
            Debug.LogError("FinalIKOrionLeapHandController:: no FullBodyBipedIK found on GameObject or any of its parent transforms. ");
        }

        if (leftHand == null && avatarLeftHand != null)
        {
            leftHand = avatarLeftHand.GetComponent <RiggedHand>();
        }
        if (rightHand == null && avatarRightHand != null)
        {
            rightHand = avatarRightHand.GetComponent <RiggedHand>();
        }
        if (leftTransform == null && avatarLeftHand != null)
        {
            leftTransform = avatarLeftHand.GetComponent <UpdateDuplicatedTransformRecursive>();
        }
        if (rightTransform == null && avatarRightHand != null)
        {
            rightTransform = avatarRightHand.GetComponent <UpdateDuplicatedTransformRecursive>();
        }

        if (leftHand == null)
        {
            Debug.LogError("IKOrionLeapHandController::Awake::No Rigged Hand set for left hand parameter. You have to set this in the inspector.");
        }
        if (rightHand == null)
        {
            Debug.LogError("IKOrionLeapHandController::Awake::No Rigged Hand set for right hand parameter. You have to set this in the inspector.");
        }

        // Physic Handは使用しないのでDisableにする
        physicsEnabled = false;
    }
コード例 #28
0
        void SetupTarget()
        {
            if (m_target != null)
            {
                m_target.Source     = m_source;
                m_target.SourceType = UniHumanoid.HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer;

                m_blendShape = m_target.GetComponent <VRMBlendShapeProxy>();

                m_firstPerson = m_target.GetComponent <VRMFirstPerson>();

                var animator = m_target.GetComponent <Animator>();
                if (animator != null)
                {
                    animator.runtimeAnimatorController = m_animationController;
                    VRIK m_vrik = m_target.gameObject.AddComponent <VRIK>();
                    m_vrik.AutoDetectReferences();
                    m_vrik.solver.spine.headTarget      = m_headTarget;
                    m_vrik.solver.leftArm.target        = m_leftHandTarget;
                    m_vrik.solver.rightArm.target       = m_rightHandTarget;
                    m_vrik.solver.leftArm.stretchCurve  = new AnimationCurve();
                    m_vrik.solver.rightArm.stretchCurve = new AnimationCurve();
                    IKSolverVR.Locomotion m_vrikLoco = m_vrik.solver.locomotion;
                    m_vrikLoco.footDistance  = 0.1f;
                    m_vrikLoco.stepThreshold = 0.2f;

                    VRIKCalibrator.Calibrate(m_vrik, null, m_headTarget, null, m_leftHandTarget, m_rightHandTarget, null, null);

                    m_firstPerson.Setup();

                    _handPoseController.SetAnimaor(animator);
                    if (m_faceCamera != null)
                    {
                        m_faceCamera.Target = animator.GetBoneTransform(HumanBodyBones.Head);
                    }
                }
            }
        }
コード例 #29
0
        private void Import(bool createObject)
        {
            if (vrik == null && CurrentModel != null)
            {
                vrik = CurrentModel.GetComponent <VRIK>();
                Debug.Log("ExternalSender: VRIK Updated");
            }
            if (vrik == null)
            {
                return;
            }
            var path     = Application.dataPath + "/../SavedTrackerPositions/";
            var filename = WindowsDialogs.OpenFileDialog("Import tracker positions", ".json");

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }
            var json    = System.IO.File.ReadAllText(filename);
            var alldata = sh_akira.Json.Serializer.Deserialize <AllTrackerPositions>(json);

            foreach (Transform child in RootObject)
            {
                Destroy(child.gameObject);
            }

            var Trackers = alldata.Trackers;

            AddIfNotNull(Trackers, createObject, "Head", ref vrik.solver.spine.headTarget);
            AddIfNotNull(Trackers, createObject, "Pelvis", ref vrik.solver.spine.pelvisTarget);
            AddIfNotNull(Trackers, createObject, "LeftArm", ref vrik.solver.leftArm.target);
            AddIfNotNull(Trackers, createObject, "RightArm", ref vrik.solver.rightArm.target);
            AddIfNotNull(Trackers, createObject, "LeftLeg", ref vrik.solver.leftLeg.target);
            AddIfNotNull(Trackers, createObject, "RightLeg", ref vrik.solver.rightLeg.target);

            alldata.RootTransform.ToLocalTransform(vrik.references.root);
            alldata.VrikSolverData.ApplyTo(vrik.solver);
        }
コード例 #30
0
        IEnumerator CheckIKTargets(VRIK ik, IKManager ikman, GameObject avatar)
        {
            yield return(0);

            while (ik != null && ikman != null)
            {
                if (ik.solver.spine.headTarget == null ||
                    ik.solver.rightArm.target == null ||
                    ik.solver.leftArm.target == null)
                {
                    avatar.transform.parent = space ?? transform;
                    Plugin.Log("vrik values were null!");
                    ik.solver.spine.headTarget = head;
                    //ikman.RightHandTarget = rightHand;
                    ik.solver.rightArm.target = rightHand;
                    //ikman.LeftHandTarget = leftHand;
                    ik.solver.leftArm.target = leftHand;
                    Plugin.Log("vrik values have been set!");
                }
                yield return(new WaitForSecondsRealtime(1));
            }
            Plugin.Log("vrik or ikman was null, quitting!");
        }