/// <summary> /// Gets the current represented hand pose oriented in relation to a given object. /// </summary> /// <param name="relativeTo">The object from which to obtain the pose. Typically an object that is going to be grabbed.</param> /// <param name="includeBones">True for including all the bones data in the result (default False)</param> /// <returns>A new HandPose</returns> public HandPose TrackedPose(Transform relativeTo, bool includeBones = false) { HandPose pose = new HandPose(); pose.relativeGrip = relativeTo.RelativeOffset(TrackedGripPose); pose.handeness = this.handeness; if (includeBones) { foreach (var bone in BonesCache) { BoneMap boneMap = bone.Value; Quaternion rotation = boneMap.TrackedRotation; pose.Bones.Add(new BonePose() { boneID = boneMap.id, rotation = rotation }); } } return(pose); }
/// <summary> /// Moves the hand positing/rotation towards the given Grip pose using interpolation. /// The target pose is specified in local units from a reference transform. /// </summary> /// <param name="pose">The relative target position for the grip point of the hand</param> /// <param name="weight">Interpolation factor, 0 for not changing the hand, 1 for fully alligning the grip point with the given pose.</param> /// <param name="relativeTo">The reference transform in which the pose is provided.</param> public void LerpGripOffset(HandPose pose, float weight, Transform relativeTo) { LerpGripOffset(pose.relativeGrip, weight, relativeTo); }
/// <summary> /// Moves the hand and its bones towards a given pose and bones using interpolation. /// The target pose is specified in local units from a reference transform. /// </summary> /// <param name="pose">The target position/rotation of the hand and its bones to move to</param> /// <param name="relativeTo">The relative transform from which the pose is given. Typically an object that is going to be grabbed.</param> /// <param name="bonesWeight">Interpolation factor for the bones. 0 for staying with the current values, 1 for fully overriding with the new ones.</param> /// <param name="positionWeight">Interpolation factor of the bone position/rotation. 0 for staying at the current pose, 1 for fully overriding with the provided one.</param> public void LerpToPose(HandPose pose, Transform relativeTo, float bonesWeight = 1f, float positionWeight = 1f) { LerpBones(pose.Bones, bonesWeight); LerpGripOffset(pose, positionWeight, relativeTo); }