private void GrabAttemp(Grabbable grabbable, float amount)
        {
            snapBack = false;
            if (grabbable == null)
            {
                currentGhost = null;
                this.puppet.SetDefaultPose();
                return;
            }
            SnappableObject snappable = grabbable.Snappable;

            if (snappable != null)
            {
                HandSnapPose userPose = this.puppet.CurrentPoseTracked(snappable.transform);

                HandGhost ghost = snappable.FindNearsetGhost(userPose, out float score, out var bestPlace);
                if (ghost != null)
                {
                    currentGhost = ghost;
                    poseInVolume = currentGhost.AdjustPlace(bestPlace);
                    offsetAmount = grabbingAmount = amount;
                }
                else
                {
                    currentGhost = null;
                    offsetAmount = grabbingAmount = 0f;
                }
            }
        }
Exemple #2
0
        public void CreateDuplicate()
        {
            HandGhost ghost = Instantiate(this, this.transform.parent);

            ghost.SetPoseVolume(this._snapPoseVolume, this.transform);
            ghost.transform.SetPositionAndRotation(this.transform.position, this.transform.rotation);
        }
        private HandGhost AddPose(VolumetricPose poseVolume)
        {
            HandGhost ghost = Instantiate(handProvider.GetHand(poseVolume.pose.handeness), this.transform);

            ghost.SetPoseVolume(poseVolume, this.transform);
            this.ghosts.Add(ghost);

            return(ghost);
        }
        public HandGhost AddPose(HandPuppet puppet)
        {
            HandSnapPose pose  = puppet.CurrentPoseVisual(this.transform);
            HandGhost    ghost = Instantiate(handProvider.GetHand(pose.handeness), this.transform);

            ghost.SetPose(pose, this.transform);
            this.ghosts.Add(ghost);
            return(ghost);
        }
        public HandGhost FindNearsetGhost(HandSnapPose userPose, out float score, out (Vector3, Quaternion) bestPlace)
        {
            float     maxScore     = 0f;
            HandGhost nearestGhost = null;

            bestPlace = (Vector3.zero, Quaternion.identity);
            foreach (var ghost in this.ghosts)
            {
                float poseScore = ghost.CalculateBestPlace(userPose, out var place);
                if (poseScore > maxScore)
                {
                    nearestGhost = ghost;
                    maxScore     = poseScore;
                    bestPlace    = place;
                }
            }
            score = maxScore;
            return(nearestGhost);
        }
        private void GrabStarted(Grabbable grabbable)
        {
            SnappableObject snappable = grabbable.Snappable;

            if (snappable != null)
            {
                HandSnapPose userPose = this.puppet.CurrentPoseTracked(snappable.transform);
                HandGhost    ghost    = snappable.FindNearsetGhost(userPose, out float score, out var bestPlace);

                if (ghost != null)
                {
                    currentGhost   = ghost;
                    poseInVolume   = currentGhost.AdjustPlace(bestPlace);
                    grabbingAmount = 1f;
                    offsetAmount   = 1f;
                    grabStartTime  = Time.timeSinceLevelLoad;
                    snapBack       = grabbable.CanMove && snappable.HandSnapBacks;
                    this.puppet.TransitionToPose(poseInVolume, currentGhost.RelativeTo, grabbingAmount, 1f);
                }
            }
        }
        private void HighlightNearestPose()
        {
            var grabbable = grabber.FindClosestGrabbable().Item1;

            if (grabbable != null && grabbable.Snappable != null)
            {
                HandSnapPose userPose = this.puppetHand.CurrentPoseTracked(grabbable.Snappable.transform);
                HandGhost    ghost    = grabbable.Snappable.FindNearsetGhost(userPose, out float score, out var bestPose);
                if (ghost != previousGhost)
                {
                    previousGhost?.Highlight(false);
                    previousGhost = ghost;
                }
                ghost?.Highlight(score);
            }
            else if (previousGhost != null)
            {
                previousGhost.Highlight(false);
                previousGhost = null;
            }
        }
 private void GrabEnded(Grabbable obj)
 {
     currentGhost = null;
     snapBack     = false;
 }