Exemplo n.º 1
0
    public ArmBasics(InstantVR ivr, BodySide bodySide_in, BodyMovementsBasics bodyMovements_in)
    {
        this.ivr = ivr;
        animator = ivr.GetComponentInChildren<Animator>();

        this.bodyMovements = bodyMovements_in;
        this.bodySide = bodySide_in;

        if (bodySide_in == BodySide.Left) {
            upperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.LeftHand);

            if (bodyMovements.fromNormLeftHand == Quaternion.identity) {
                bodyMovements.fromNormLeftUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                bodyMovements.fromNormLeftForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                bodyMovements.fromNormLeftHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
            if (fromNormHand == Quaternion.identity) {
                fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);

            if (bodyMovements.fromNormRightHand == Quaternion.identity) {
                bodyMovements.fromNormRightUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                bodyMovements.fromNormRightForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                bodyMovements.fromNormRightHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
            if (fromNormHand == Quaternion.identity) {
                fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
        }

        float upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
        float forearmLength = Vector3.Distance(forearm.position, hand.position);
        length = upperArmLength + forearmLength;

        upperArmStartPosition = upperArm.position;
    }
 public static string GenBonePx(this string str, BodySide sd) => (sd.IsLeft() ? 'l' : 'r') + str.Substring(1);
Exemplo n.º 3
0
 IHandAni IHandAni.Set(IComplexHuman human, BodySide side, double seconds)
 {
     return(Set(human, side, seconds));
 }
Exemplo n.º 4
0
 public ArmMovements(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements) {
     Initialize(ivr, bodySide, bodyMovements);
 }
Exemplo n.º 5
0
        public Arm(Transform upperArm_in, Transform forearm_in, Transform hand_in, Transform characterTransform, BodySide side)
        {
            upperArm = upperArm_in;
            forearm  = forearm_in;
            hand     = hand_in;
            Quaternion rotation;

            fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
            fromNormForearm  = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
            fromNormHand     = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;

            if (side == BodySide.Left)
            {
                fromNormUpperArm *= Quaternion.Euler(180, 0, 0);
                fromNormForearm  *= Quaternion.Euler(180, 0, 0);
                fromNormHand     *= Quaternion.Euler(180, 0, 0);
            }

            GameObject upperArmStartGO = new GameObject("Upper_Start");

            upperArmStart          = upperArmStartGO.transform;
            upperArmStart.position = upperArm.position;
            upperArmStart.parent   = characterTransform;

            upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
            forearmLength  = Vector3.Distance(forearm.position, hand.position);
            length         = Vector3.Distance(upperArm.position, hand.position);

            upperArmLength2 = upperArmLength * upperArmLength;
            forearmLength2  = forearmLength * forearmLength;
        }
 /// <summary>
 /// Gets the joint of given joint type and joint side.
 /// </summary>
 /// <param name="jointType">The type of the joint </param>
 /// <param name="jointSide">The side on wich the joint should be located</param>
 /// <param name="transforms">The bones to search among</param>
 /// <returns>Null if no match, otherwise the first hit</returns>
 public static Transform[] GetTypeAndSide(JointObject jointType, BodySide jointSide, Transform[] transforms)
 {
     return GetJointsOfSide(jointSide, GetBonesOfType(jointType, transforms));
 }
 /// <summary>
 /// Returns a tranform from a given JointType
 /// </summary>
 /// <param name="transforms">The transform to be searched</param>
 /// <param name="jointType">The type of the joint to be returned</param>
 /// <param name="jointSide">The side of which the joint is located</param>
 /// <param name="namings">The Names of the joints</param>
 /// <returns>The transform of the first result</returns>
 public static Transform GetBone(Transform[] transforms, JointObject jointType, BodySide jointSide = BodySide.Center, params string[][] namings)
 {
     return GetMatch(GetTypeAndSide(jointType, jointSide, transforms), namings);
 }
Exemplo n.º 8
0
 public HumLegChain GetLeg(BodySide side) => side == BodySide.Left ? LegL : LegR;
 public static string ToLetter(this BodySide side)
 {
     return(side == BodySide.Right ? "R" : "L");
 }
 public static BodySide Flip(this BodySide side)
 {
     return(side == BodySide.Right ? BodySide.Left : BodySide.Right);
 }
Exemplo n.º 11
0
 public HandSupineMessage(BodySide side, MessageType type)
 {
     this.Side = side;
     this.Type = type;
 }
Exemplo n.º 12
0
 public BeforeCreatingPlayerHand(BodySide side)
 {
     Side = side;
 }
Exemplo n.º 13
0
 public HapticPulse(BodySide side, double amplitude = 0.5, double duration = 1.0)
 {
     Side      = side;
     Amplitude = amplitude;
     Duration  = duration;
 }
Exemplo n.º 14
0
 public PlayerHandInputInitialized(Transform hand, BodySide side)
 {
     Hand = hand;
     Side = side;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Returns only the joints with the specified Side.
 /// </summary>
 /// <param name="jointSide">The side of the joint</param>
 /// <param name="joints">The Transforms where to search</param>
 /// <returns>A list of matching Transforms</returns>
 public static Transform[] GetJointsOfSide(BodySide jointSide, Transform[] joints)
 {
     return(joints.Where(j => (j != null && GetSideOfJointName(j.name) == jointSide)).ToArray());
 }
Exemplo n.º 16
0
 public IHumArmChain GetArm(BodySide side) => side == BodySide.Left ? ArmL : ArmR;
 public static bool IsLeft(this BodySide side) => side == BodySide.Left;
        public Arm(Transform upperArm_in, Transform forearm_in, Transform hand_in, Transform characterTransform, BodySide side)
        {
            upperArm = upperArm_in;
            forearm = forearm_in;
            hand = hand_in;
            Quaternion rotation;

            fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
            fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
            fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;

            if (side == BodySide.Left)
            {
               fromNormUpperArm *= Quaternion.Euler(180, 0, 0);
               fromNormForearm *= Quaternion.Euler(180, 0, 0);
               fromNormHand *= Quaternion.Euler(180, 0, 0);
            }

            GameObject upperArmStartGO = new GameObject("Upper_Start");
            upperArmStart = upperArmStartGO.transform;
            upperArmStart.position = upperArm.position;
            upperArmStart.parent = characterTransform;

            upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
            forearmLength = Vector3.Distance(forearm.position, hand.position);
            length = Vector3.Distance(upperArm.position, hand.position);

            upperArmLength2 = upperArmLength * upperArmLength;
            forearmLength2 = forearmLength * forearmLength;
        }
 public static bool IsRight(this BodySide side) => side == BodySide.Right;
 /// <summary>
 /// Returns only the joints with the specified Side.
 /// </summary>
 /// <param name="jointSide">The side of the joint</param>
 /// <param name="joints">The Transforms where to search</param>
 /// <returns>A list of matching Transforms</returns>
 public static Transform[] GetJointsOfSide(BodySide jointSide, Transform[] joints)
 {
     return joints.Where(j => (j != null && GetSideOfJointName(j.name) == jointSide)).ToArray();
 }
 public static Vector3 ToNormal(this BodySide side)
 => side == BodySide.Left
         ? v3.lt
         : side == BodySide.Right
             ? v3.rt
             : v3.zero;
Exemplo n.º 22
0
        public HumBreastGroup(
            string persona,
            BodySide side,
            IComplexHuman human,
            Transform pectoral,
            HumBoneHandler nipple,
            BreastConfigSource configSource)
        {
            _persona           = persona;
            _side              = side;
            _human             = human;
            _pectoral          = pectoral;
            _nipple            = nipple;
            Part               = side == BodySide.LT ? BodyPart.BreastL : BodyPart.BreastR;
            _iniBreastLocFw    = _pectoral.forward.AsLocalDir(_pectoral.parent);
            _iniBreastLocUp    = _pectoral.up.AsLocalDir(_pectoral.parent);
            _iniWorldUpAsLocal = v3.up.AsLocalDir(_pectoral.parent);
            if (_nipple != null)
            {
                _iniNippleLocPos = _nipple.position.AsLocalPoint(_pectoral.parent);
            }
            _iniBreastLocPos = _pectoral.localPosition;

            var softBodyConfig = configSource?.GetConfig() ??
                                 new SoftBodyConfig
            {
                MaxStretch        = 0.10,
                MaxSqueeze        = 0.05,
                MaxDegrees        = 30,
                RelTargetAt       = 0.26,
                Stiffness         = 0.01,
                Mass              = 0.20,
                Damping           = 0.10,
                Gravity           = 0.05,
                RelDownResistance = 0.70
            };

            softBodyConfig.Bone = _pectoral;

//            var softBodyConfig = new SoftBodyConfig
//            {
//                Bone = _pectoral,
//                MaxStretch = 0.10,
//                MaxSqueeze = 0.05,
//                MaxDegrees = 25,
//                RelTargetAt = 0.26,
//                Stiffness = 0.05,
//                Mass = 0.50,
//                Damping = 0.50,
//                Gravity = 0.05,
//                RelDownResistance = 0.80
//            };

            fire(new RegisterSoftBodyConfig(human, side, Part, softBodyConfig));

            _jiggle = new SoftBodyJiggleAgent(softBodyConfig);

            subscribe <CancelInertia>(human, e =>
            {
                _jiggle.Pendulum.CancelInertia();
            }, this);
        }
 public static T MapRightLeft <T>(this BodySide side, T right, T left) => side == BodySide.Right ? right : left;
Exemplo n.º 24
0
 public ArmMovements(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements)
 {
     Initialize(ivr, bodySide, bodyMovements);
 }
 public static ControllerSide ToController(this BodySide side)
 {
     return(side == BodySide.Right ? ControllerSide.Right : ControllerSide.Left);
 }
Exemplo n.º 26
0
    public void Initialize(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements) {
        this.ivr = ivr;

        this.bodySide = bodySide;
        animator = ivr.GetComponentInChildren<Animator>();

        if (bodySide == BodySide.Left) {
            upperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.LeftHand);
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);
        }

        upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
        forearmLength = Vector3.Distance(forearm.position, hand.position);
        length = upperArmLength + forearmLength;
        if (length == 0)
            Debug.LogError("Avatar arm positions are incorrect. Please restore avatar in T-pose.");

        upperArmLength2 = upperArmLength * upperArmLength;
        forearmLength2 = forearmLength * forearmLength;

        upperArmStartPosition = upperArm.position;
    }
Exemplo n.º 27
0
 /// <summary>
 /// Gets the joint of given joint type and joint side.
 /// </summary>
 /// <param name="jointType">The type of the joint </param>
 /// <param name="jointSide">The side on wich the joint should be located</param>
 /// <param name="transforms">The bones to search among</param>
 /// <returns>Null if no match, otherwise the first hit</returns>
 public static Transform[] GetTypeAndSide(JointObject jointType, BodySide jointSide, Transform[] transforms)
 {
     return(GetJointsOfSide(jointSide, GetBonesOfType(jointType, transforms)));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Returns a tranform from a given JointType
 /// </summary>
 /// <param name="transforms">The transform to be searched</param>
 /// <param name="jointType">The type of the joint to be returned</param>
 /// <param name="jointSide">The side of which the joint is located</param>
 /// <param name="namings">The Names of the joints</param>
 /// <returns>The transform of the first result</returns>
 public static Transform GetBone(Transform[] transforms, JointObject jointType, BodySide jointSide = BodySide.Center, params string[][] namings)
 {
     return(GetMatch(GetTypeAndSide(jointType, jointSide, transforms), namings));
 }
Exemplo n.º 29
0
 public static string MHBonePx(this string str, BodySide sd) => str.Substring(0, str.Length - 2) + (sd.IsLeft() ? "_L" : "_R");