Ejemplo n.º 1
0
 private void SetRootPose(Pose rootPose, bool applyOffset)
 {
     if (applyOffset)
     {
         rootPose = PoseUtils.Multiply(rootPose, controllerOffset.AsPose);
     }
     _trackedPose = rootPose;
     this.transform.SetPose(rootPose, Space.World);
 }
Ejemplo n.º 2
0
        private Pose OffsetedGripPose()
        {
            Pose trackingOffset = new Pose(Vector3.zero, Quaternion.Euler(0f, 180f, 0f));
            Pose gripOffset     = this.transform.RelativeOffset(this.gripPoint);
            Pose hand           = PoseUtils.Multiply(trackedHandOffset.Offset, trackingOffset);
            Pose translateGrip  = PoseUtils.Multiply(hand, gripOffset);

            return(translateGrip);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Moves the hand at a given pose 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. If null, the Hand Anchor coordinates are used</param>
        public void LerpGripOffset(Pose pose, float weight, Transform relativeTo = null)
        {
            Pose gripOffset = this.gripPoint.RelativeOffset(this.transform);
            Pose basic      = TrackedGripPose;
            Pose target     = (relativeTo ?? this.handAnchor).GlobalPose(pose);
            Pose result     = PoseUtils.Lerp(basic, target, weight);

            result = PoseUtils.Multiply(result, gripOffset);
            this.transform.SetPose(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Moves the hand at a given pose 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(Pose pose, float weight, Transform relativeTo)
        {
            Pose fromGrip   = this.gripPoint.GetPose();
            Pose toGrip     = (relativeTo ?? this.transform).GlobalPose(pose);
            Pose targetGrip = PoseUtils.Lerp(fromGrip, toGrip, weight);

            Pose inverseGrip = this.gripPoint.RelativeOffset(this.transform);
            Pose targetPose  = PoseUtils.Multiply(targetGrip, inverseGrip);

            this.transform.SetPose(targetPose);
        }