Example #1
0
    public Dictionary <string, BoneTransformData> ReadPose(OVRHandPoserHand hand, Transform overrideTransformRoot = null, Dictionary <string, BoneTransformData> currDictionary = null)
    {
        Dictionary <string, BoneTransformData> outDictionary = (currDictionary != null ? currDictionary : new Dictionary <string, BoneTransformData>());
        Transform transformRoot = (overrideTransformRoot ? overrideTransformRoot : hand.previewInWorld.transform);

        for (int i = 0; i < transformRoot.childCount; i++)
        {
            //go into child and add to my point
            BoneTransformData newBoneTransform      = new BoneTransformData();
            Transform         existingBoneTransform = transformRoot.GetChild(i);
            newBoneTransform.Rotation = existingBoneTransform.localRotation;
            newBoneTransform.Position = existingBoneTransform.localPosition;
            newBoneTransform.Scale    = existingBoneTransform.localScale;

            if (!outDictionary.ContainsKey(existingBoneTransform.name))
            {
                outDictionary.Add(existingBoneTransform.name, newBoneTransform);
            }

            ReadPose(hand, transformRoot.GetChild(i), outDictionary);
        }
        ;

        return(outDictionary);
    }
Example #2
0
 private void LoadPose(OVRHandPoserHand hand)
 {
     if (hand.previewInWorld != null)
     {
         poser.SetPose(hand.previewInWorld.transform, (hand.isLeftHand ? poser.currentPose.BoneDataLeft : poser.currentPose.BoneDataRight));
     }
 }
Example #3
0
    private void TryDiscoverHandPreviews(OVRHandPoserHand hand)
    {
        GameObject discovered = poser.transform.Find("OVRPoserTemplate_" + (hand.isLeftHand ? "LEFT" : "RIGHT"))?.gameObject;

        if (discovered != null)
        {
            hand.previewInWorld = discovered;
        }
    }
Example #4
0
    void Awake()
    {
        if (leftHand == null)
        {
            leftHand = new OVRHandPoserHand(true);
        }
        if (rightHand == null)
        {
            rightHand = new OVRHandPoserHand(false);
        }

        //Destroy any development objects.
        if (leftHand.previewAsset != null)
        {
            Destroy(leftHand.previewAsset);
        }

        if (rightHand.previewAsset != null)
        {
            Destroy(rightHand.previewAsset);
        }
    }
Example #5
0
    private void SetPreviewActive(OVRHandPoserHand hand, bool active)
    {
        //Try discover previews by name.

        if (active)
        {
            if (hand.previewInWorld == null)
            {
                Transform grabHandle = poser.GetComponent <Grabbable>().GrabPoints[0];

                Transform grabPoint = hand.previewAsset.transform.FindChildRecursive("gripTrans");

                hand.previewInWorld = Instantiate(hand.previewAsset, hand.previewAsset.transform.position, hand.previewAsset.transform.rotation, poser.transform);

                if (hand.isLeftHand)
                {
                    hand.previewInWorld.transform.position = grabHandle.transform.position - (poser.ModelManager.LeftGrabber.transform.position - poser.ModelManager.LeftHand.transform.position);
                }
                else
                {
                    hand.previewInWorld.transform.position = grabHandle.transform.position - (poser.ModelManager.RightGrabber.transform.position - poser.ModelManager.RightHand.transform.position);
                }
                //Euler angles is done off of approximation.
                //hand.previewInWorld.transform.localEulerAngles = grabHandle.transform.forward + hand.previewAsset.transform.localEulerAngles;
                LoadPose(hand);
            }
        }
        else
        {
            if (hand.previewInWorld != null)
            {
                DestroyImmediate(hand.previewInWorld);
            }
        }

        rightPreview = (hand.isLeftHand ? rightPreview : active);
        leftPreview  = (hand.isLeftHand == false ? leftPreview : active);
    }