Exemplo n.º 1
0
    private Transform FindTarget(VRMHumanoidDescription humanoidDesc, HumanBodyBones bone)
    {
        var boneName = humanoidDesc.Description.human.First((_bone) => {
            return(_bone.humanBone == bone);
        }).boneName;

        return(FindDescendantsRecursively(transform, boneName));
    }
Exemplo n.º 2
0
    private void PrepareHandJoints(VRMHumanoidDescription humanoidDesc)
    {
        leftIndex1 = FindTarget(humanoidDesc, HumanBodyBones.LeftIndexProximal);
        leftIndex2 = FindTarget(humanoidDesc, HumanBodyBones.LeftIndexIntermediate);
        leftIndex3 = FindTarget(humanoidDesc, HumanBodyBones.LeftIndexDistal);

        leftMiddle1 = FindTarget(humanoidDesc, HumanBodyBones.LeftMiddleProximal);
        leftMiddle2 = FindTarget(humanoidDesc, HumanBodyBones.LeftMiddleIntermediate);
        leftMiddle3 = FindTarget(humanoidDesc, HumanBodyBones.LeftMiddleDistal);

        leftRing1 = FindTarget(humanoidDesc, HumanBodyBones.LeftRingProximal);
        leftRing2 = FindTarget(humanoidDesc, HumanBodyBones.LeftRingIntermediate);
        leftRing3 = FindTarget(humanoidDesc, HumanBodyBones.LeftRingDistal);

        leftLittle1 = FindTarget(humanoidDesc, HumanBodyBones.LeftLittleProximal);
        leftLittle2 = FindTarget(humanoidDesc, HumanBodyBones.LeftLittleIntermediate);
        leftLittle3 = FindTarget(humanoidDesc, HumanBodyBones.LeftLittleDistal);

        leftThumb1 = FindTarget(humanoidDesc, HumanBodyBones.LeftThumbProximal);
        leftThumb2 = FindTarget(humanoidDesc, HumanBodyBones.LeftThumbIntermediate);
        leftThumb3 = FindTarget(humanoidDesc, HumanBodyBones.LeftThumbDistal);

        rightIndex1 = FindTarget(humanoidDesc, HumanBodyBones.RightIndexProximal);
        rightIndex2 = FindTarget(humanoidDesc, HumanBodyBones.RightIndexIntermediate);
        rightIndex3 = FindTarget(humanoidDesc, HumanBodyBones.RightIndexDistal);

        rightMiddle1 = FindTarget(humanoidDesc, HumanBodyBones.RightMiddleProximal);
        rightMiddle2 = FindTarget(humanoidDesc, HumanBodyBones.RightMiddleIntermediate);
        rightMiddle3 = FindTarget(humanoidDesc, HumanBodyBones.RightMiddleDistal);

        rightRing1 = FindTarget(humanoidDesc, HumanBodyBones.RightRingProximal);
        rightRing2 = FindTarget(humanoidDesc, HumanBodyBones.RightRingIntermediate);
        rightRing3 = FindTarget(humanoidDesc, HumanBodyBones.RightRingDistal);

        rightLittle1 = FindTarget(humanoidDesc, HumanBodyBones.RightLittleProximal);
        rightLittle2 = FindTarget(humanoidDesc, HumanBodyBones.RightLittleIntermediate);
        rightLittle3 = FindTarget(humanoidDesc, HumanBodyBones.RightLittleDistal);

        rightThumb1 = FindTarget(humanoidDesc, HumanBodyBones.RightThumbProximal);
        rightThumb2 = FindTarget(humanoidDesc, HumanBodyBones.RightThumbIntermediate);
        rightThumb3 = FindTarget(humanoidDesc, HumanBodyBones.RightThumbDistal);
    }
Exemplo n.º 3
0
    void SetupTargets(VRMHumanoidDescription humanoidDesc, VRIK vrik)
    {
        var boneLimits = humanoidDesc.Description.human;
        var solver     = vrik.solver;

        {
            var bodyPart = HumanBodyBones.Head;
            var head     = FindTarget(boneLimits, bodyPart);
            var leftEye  = FindTarget(boneLimits, HumanBodyBones.LeftEye);
            if (head != null)
            {
                var cube = AddTargetCube(head);
                cube.transform.position = new Vector3(
                    cube.transform.position.x,
                    leftEye.transform.position.y,
                    cube.transform.position.z
                    );
                cube.name = string.Format("{0}_target", bodyPart);
                solver.spine.headTarget = cube.transform;
            }
            else
            {
                Debug.LogFormat("{0} is not found.", bodyPart);
            }
        }

        {
            var bodyPart = HumanBodyBones.LeftHand;
            var bone     = FindTarget(boneLimits, bodyPart);
            if (bone != null)
            {
                var cube = AddTargetCube(bone);
                cube.name             = string.Format("{0}_target", bodyPart);
                solver.leftArm.target = cube.transform;
            }
            else
            {
                Debug.LogFormat("{0} is not found.", bodyPart);
            }
        }

        {
            var bodyPart = HumanBodyBones.RightHand;
            var bone     = FindTarget(boneLimits, bodyPart);
            if (bone != null)
            {
                var cube = AddTargetCube(bone);
                cube.name = string.Format("{0}_target", bodyPart);
                solver.rightArm.target = cube.transform;
            }
            else
            {
                Debug.LogFormat("{0} is not found.", bodyPart);
            }
        }

        {
            var bodyPart = HumanBodyBones.LeftFoot;
            var foot     = FindTarget(boneLimits, bodyPart);
            var toe      = FindTarget(boneLimits, HumanBodyBones.LeftToes);
            if (foot != null)
            {
                var cube = AddTargetCube(foot);
                cube.name = string.Format("{0}_target", bodyPart);
                cube.transform.position = new Vector3(
                    cube.transform.position.x,
                    cube.transform.position.y,
                    toe.transform.position.z
                    );
                solver.leftLeg.target = cube.transform;
            }
            else
            {
                Debug.LogFormat("{0} is not found.", bodyPart);
            }
        }

        {
            var bodyPart = HumanBodyBones.RightFoot;
            var foot     = FindTarget(boneLimits, bodyPart);
            var toe      = FindTarget(boneLimits, HumanBodyBones.RightToes);
            if (foot != null)
            {
                var cube = AddTargetCube(foot);
                cube.name = string.Format("{0}_target", bodyPart);
                cube.transform.position = new Vector3(
                    cube.transform.position.x,
                    cube.transform.position.y,
                    toe.transform.position.z
                    );
                solver.rightLeg.target = cube.transform;
            }
            else
            {
                Debug.LogFormat("{0} is not found.", bodyPart);
            }
        }

        {
            var bodyPart = HumanBodyBones.Hips;
            var body     = FindTarget(boneLimits, bodyPart);
            if (body != null)
            {
                var cube = AddTargetCube(body);
                cube.name = string.Format("{0}_target", bodyPart);
                solver.spine.pelvisTarget = cube.transform;
            }
            else
            {
                Debug.LogFormat("{0} is not found.", bodyPart);
            }
        }
    }