Ejemplo n.º 1
0
        public virtual void FixedUpdateBones(RealHand targetHand, VCHand vcHand, int f)
        {
            RealFinger finger = targetHand.fingers[f];

            Vector3 displacement = bones [bones.Length - 1].position - finger.bones [bones.Length - 1].position;
            Vector3 force        = posSD.GetForce(displacement, boneBodys [bones.Length - 1].velocity);

            CapsuleCollider boneCol = boneCols [bones.Length - 1];
            Vector3         I       = CapsuleI(boneCol.radius, boneCol.height, posSD.m);

            Quaternion targetRot = finger.bones[bones.Length - 1].rotation;
            Quaternion boneRot   = bones[bones.Length - 1].rotation;
            Vector3    torque    = rotSD.GetTorque(boneRot, targetRot, boneBodys[bones.Length - 1].angularVelocity, I);

            MoveBones(vcHand, finger, force, torque);
        }
Ejemplo n.º 2
0
        //位置がずれる、なぜ....
        public override void FixedUpdateBones(RealHand targetHand, VCHand vcHand, int f)
        {
            RealFinger finger = targetHand.fingers[f];

            Vector3 targetLocalPos = finger.bones [bones.Length - 1].position - targetHand.palm.position;
            Vector3 localPos       = bones [bones.Length - 1].position - targetHand.palm.position;
            Vector3 localVelocity  = boneBodys [bones.Length - 1].velocity - vcHand.palmBody.velocity;
            Vector3 force          = posSD.GetForce(localPos - targetLocalPos, localVelocity);

            CapsuleCollider boneCol              = boneCols [bones.Length - 1];
            Vector3         I                    = CapsuleI(boneCol.radius, boneCol.height, posSD.m);
            Quaternion      targetLocalRot       = finger.bones [bones.Length - 1].rotation * Quaternion.Inverse(targetHand.palm.rotation);
            Quaternion      boneLocalRot         = bones[bones.Length - 1].rotation * Quaternion.Inverse(targetHand.palm.rotation);
            Vector3         localAngularVelocity = boneBodys [bones.Length - 1].angularVelocity - vcHand.palmBody.angularVelocity;
            Vector3         torque               = rotSD.GetTorque(boneLocalRot, targetLocalRot, localAngularVelocity, I);

            MoveBones(vcHand, finger, force, torque);
        }