Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
                }
            }
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
 private void GrabEnded(Grabbable obj)
 {
     currentGhost = null;
     snapBack     = false;
 }