예제 #1
0
        protected void Awake()
        {
            renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded);

            if (handPrefab != null)
            {
                handInstance = GameObject.Instantiate(handPrefab);
                handInstance.transform.parent        = this.transform;
                handInstance.transform.localPosition = Vector3.zero;
                handInstance.transform.localRotation = Quaternion.identity;
                handInstance.transform.localScale    = handPrefab.transform.localScale;
                handSkeleton            = handInstance.GetComponent <SteamVR_Behaviour_Skeleton>();
                handSkeleton.updatePose = false;

                handRenderers = handInstance.GetComponentsInChildren <Renderer>();
                if (displayHandByDefault == false)
                {
                    SetHandVisibility(false);
                }

                handAnimator = handInstance.GetComponentInChildren <Animator>();
            }

            if (controllerPrefab != null)
            {
                controllerInstance = GameObject.Instantiate(controllerPrefab);
                controllerInstance.transform.parent        = this.transform;
                controllerInstance.transform.localPosition = Vector3.zero;
                controllerInstance.transform.localRotation = Quaternion.identity;
                controllerInstance.transform.localScale    = controllerPrefab.transform.localScale;
                controllerRenderModel = controllerInstance.GetComponent <SteamVR_RenderModel>();
            }
        }
예제 #2
0
    //protected SteamVR_Events.Action renderModelLoadedAction;

    //protected void Awake()
    //{
    //    renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded);
    //}

    //private void OnRenderModelLoaded(SteamVR_RenderModel loadedRenderModel, bool success)
    //{
    //    print(1);
    //}

    void Start()
    {
        if (!PivotPoser)
        {
            PivotPoser = new GameObject().transform;
        }
        PivotPoser.hideFlags = HideFlags.HideInHierarchy;
        if (!ToolTransform)
        {
            ToolTransform = new GameObject().transform;
        }
        ToolTransform.hideFlags = HideFlags.HideInHierarchy;

        if (GetComponent <SteamVR_Behaviour_Pose>())
        {
            handType = GetComponent <SteamVR_Behaviour_Pose>().inputSource;
        }
        else
        {
            Debug.LogError("no SteamVR_Behaviour_Pose on this object");
        }
        if (GetComponentInChildren <SteamVR_Behaviour_Skeleton>())
        {
            skeleton = GetComponentInChildren <SteamVR_Behaviour_Skeleton>();
        }
        if (GetComponentInChildren <SteamVR_RenderModel>())
        {
            RenderModel = GetComponentInChildren <SteamVR_RenderModel>();
            StartCoroutine(HideControllerCoroutine());
        }
        skeleton.BlendToSkeleton();
    }
예제 #3
0
    private void Awake()
    {
        handSkeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
        inputSource  = handSkeleton.inputSource;

        toolCount   = System.Enum.GetValues(typeof(ClayVRTool)).Length;
        toolSprites = new SpriteRenderer[toolCount];
        float toolAngle = 0;

        for (int toolIndex = 0; toolIndex < toolCount; ++toolIndex)
        {
            float  toolSelectionDelta = Mathf.PI * 2f / toolCount;
            string toolName           = ((ClayVRTool)toolIndex).ToString();

            Sprite     sprite     = Resources.Load <Sprite>(ICON_PATH_PREFIX + toolName);
            GameObject toolObject = new GameObject(toolName);
            toolObject.transform.SetParent(toolContainer.transform);
            toolObject.transform.localScale    = Vector3.one * DESELECTED_TOOL_SCALE;
            toolObject.transform.localPosition = new Vector3(Mathf.Sin(toolAngle) * TOOL_SELECTOR_SIZE, Mathf.Cos(toolAngle) * TOOL_SELECTOR_SIZE, 0);
            toolObject.transform.localRotation = Quaternion.identity;
            SpriteRenderer spriteRenderer = toolObject.AddComponent <SpriteRenderer>();
            spriteRenderer.sprite  = sprite;
            spriteRenderer.color   = DESELECTED_TOOL_COLOR;
            toolSprites[toolIndex] = spriteRenderer;

            toolAngle += toolSelectionDelta;
        }

        colorPicker.SetActive(false);
        colorPickerMaterial = colorPicker.GetComponent <MeshRenderer>().material;

        ChangeTool(ClayVRTool.MOVE);
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (interactable.gripped)
        {
            if (grabbingHand == null)
            {
                if (interactable.Hand == SteamVR_Input_Sources.LeftHand)
                {
                    grabbingHand = GameObject.Find("Controller (left)");
                }
                else
                {
                    grabbingHand = GameObject.Find("Controller (right)");
                }
            }

            SteamVR_Behaviour_Skeleton skeleton = grabbingHand.GetComponent <GripController>().HandSkeleton;
            if (skeleton != null)
            {
                if ((skeleton.indexCurl <= openFingerAmount && skeleton.pinkyCurl <= openPinkyAmount && skeleton.thumbCurl <= openFingerAmount) && (skeleton.ringCurl >= closedFingerAmount && skeleton.middleCurl >= closedFingerAmount))
                {
                    StartCoroutine(WebShootSignRecognized(true));
                }
                else
                {
                    StartCoroutine(WebShootSignRecognized(false));
                }
            }
        }
    }
예제 #5
0
        protected void InitializeHand()
        {
            if (handPrefab != null)
            {
                handInstance = GameObject.Instantiate(handPrefab);
                handInstance.transform.parent        = this.transform;
                handInstance.transform.localPosition = Vector3.zero;
                handInstance.transform.localRotation = Quaternion.identity;
                handInstance.transform.localScale    = handPrefab.transform.localScale;
                handInstance.layer      = this.gameObject.layer;
                handSkeleton            = handInstance.GetComponent <SteamVR_Behaviour_Skeleton>();
                handSkeleton.origin     = Player.instance.trackingOriginTransform;
                handSkeleton.updatePose = false;
                handSkeleton.skeletonAction.onActiveChange += OnSkeletonActiveChange;

                handRenderers = handInstance.GetComponentsInChildren <Renderer>();
                if (displayHandByDefault == false)
                {
                    SetHandVisibility(false);
                }

                handAnimator = handInstance.GetComponentInChildren <Animator>();

                if (handSkeleton.skeletonAction.activeBinding == false)
                {
                    Debug.LogWarning("Skeleton action: " + handSkeleton.skeletonAction.GetPath() + " is not bound. Your controller may not support SteamVR Skeleton Input.");
                    DestroyHand();
                }
            }
        }
예제 #6
0
 private void Awake()
 {
     m_Pose     = GetComponent <SteamVR_Behaviour_Pose>();
     m_Skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
     m_Joint    = GetComponent <FixedJoint>();
     //bomb = GameObject.Find("Bomb").GetComponent<Bomb>();
 }
예제 #7
0
        private void SetUpModel()
        {
            var handObject = Instantiate(handPrefab);

            handObject.SetActive(false);
            var hand = handObject.transform;

            var renderers = handObject.GetComponentsInChildren <SkinnedMeshRenderer>(true);

            _handRenderer  = renderers.Where(r => r.transform.name.Contains("Hand")).FirstOrDefault();
            _gloveRenderer = renderers.Where(r => r.transform.name.Contains("Glove")).FirstOrDefault();

            SetUpShaders(_handRenderer, "Outer Wilds/Character/Skin", "Outer Wilds/Character/Skin");
            SetUpShaders(_gloveRenderer, "Outer Wilds/Character/Clothes");

            _handRenderer.gameObject.AddComponent <ConditionalDisableRenderer>().getShouldRender  += ShouldRenderHands;
            _gloveRenderer.gameObject.AddComponent <ConditionalDisableRenderer>().getShouldRender += ShouldRenderGloves;

            SetUpModel(hand);
            _skeleton = SetUpSkeleton(handObject, hand);

            Palm = handObject.transform.Find("skeletal_hand/Root/wrist_r/HoldPoint");

            handObject.SetActive(true);
        }
예제 #8
0
 private void Awake()
 {
     pose               = GetComponent <SteamVR_Behaviour_Pose>();
     joint              = GetComponent <FixedJoint>();
     skeleton           = GetComponentInChildren <SteamVR_Behaviour_Skeleton>();
     handRenderer       = skeleton.GetComponentInChildren <Animator>().GetComponentInChildren <SkinnedMeshRenderer>();
     controllerRenderer = GetComponentInChildren <SteamVR_RenderModel>();
 }
예제 #9
0
 public void OnGripPose(SteamVR_Behaviour_Skeleton skeleton)
 {
     if (skeletonPoser != null && skeleton != null)
     {
         Debug.Log("On Pose");
         skeleton.BlendToPoser(skeletonPoser, blendToPoseTime);
     }
 }
예제 #10
0
            public void UpdateAdditiveAnimation(SteamVR_Action_Skeleton skeletonAction, HandType inputSource)
            {
                SteamVR_Skeleton_PoseSnapshot snapshot = GetHandSnapshot(inputSource);
                SteamVR_Skeleton_Pose_Hand    poseHand = pose.GetHand(inputSource);

                //setup mirrored pose buffers
                if (additivePositionBuffer == null)
                {
                    additivePositionBuffer = new Vector3[skeletonAction.boneCount];
                }
                if (additiveRotationBuffer == null)
                {
                    additiveRotationBuffer = new Quaternion[skeletonAction.boneCount];
                }


                for (int boneIndex = 0; boneIndex < snapshotL.bonePositions.Length; boneIndex++)
                {
                    // if ((boneIndex == 1) || (boneIndex == 0))
                    //     continue;

                    int fingerIndex = SteamVR_Skeleton_JointIndexes.GetFingerForBone(boneIndex);
                    SteamVR_Skeleton_FingerExtensionTypes extensionType = poseHand.GetMovementTypeForBone(boneIndex);

                    //do target pose mirroring on left hand
                    if (inputSource == HandType.LeftHand)
                    {
                        SteamVR_Behaviour_Skeleton.MirrorBonePosition(ref skeletonAction.bonePositions[boneIndex], ref additivePositionBuffer[boneIndex], boneIndex);
                        SteamVR_Behaviour_Skeleton.MirrorBoneRotation(ref skeletonAction.boneRotations[boneIndex], ref additiveRotationBuffer[boneIndex], boneIndex);
                    }
                    else
                    {
                        additivePositionBuffer[boneIndex] = skeletonAction.bonePositions[boneIndex];
                        additiveRotationBuffer[boneIndex] = skeletonAction.boneRotations[boneIndex];
                    }



                    if (extensionType == SteamVR_Skeleton_FingerExtensionTypes.Free)
                    {
                        snapshot.bonePositions[boneIndex] = additivePositionBuffer[boneIndex];
                        snapshot.boneRotations[boneIndex] = additiveRotationBuffer[boneIndex];
                    }
                    else if (extensionType == SteamVR_Skeleton_FingerExtensionTypes.Extend)
                    {
                        // lerp to open pose by fingercurl
                        snapshot.bonePositions[boneIndex] = Vector3.Lerp(poseHand.bonePositions[boneIndex], additivePositionBuffer[boneIndex], 1 - skeletonAction.fingerCurls[fingerIndex]);
                        snapshot.boneRotations[boneIndex] = Quaternion.Lerp(poseHand.boneRotations[boneIndex], additiveRotationBuffer[boneIndex], 1 - skeletonAction.fingerCurls[fingerIndex]);
                    }
                    else if (extensionType == SteamVR_Skeleton_FingerExtensionTypes.Contract)
                    {
                        // lerp to closed pose by fingercurl
                        snapshot.bonePositions[boneIndex] = Vector3.Lerp(poseHand.bonePositions[boneIndex], additivePositionBuffer[boneIndex], skeletonAction.fingerCurls[fingerIndex]);
                        snapshot.boneRotations[boneIndex] = Quaternion.Lerp(poseHand.boneRotations[boneIndex], additiveRotationBuffer[boneIndex], skeletonAction.fingerCurls[fingerIndex]);
                    }
                }
            }
예제 #11
0
        Vector3 ProcessPos(int boneIndex, Vector3 pos)
        {
            if (hand.skeleton.mirroring != SteamVR_Behaviour_Skeleton.MirrorType.None)
            {
                return(SteamVR_Behaviour_Skeleton.MirrorPosition(boneIndex, pos));
            }

            return(pos);
        }
예제 #12
0
        Quaternion ProcessRot(int boneIndex, Quaternion rot)
        {
            if (hand.skeleton.mirroring != SteamVR_Behaviour_Skeleton.MirrorType.None)
            {
                return(SteamVR_Behaviour_Skeleton.MirrorRotation(boneIndex, rot));
            }

            return(rot);
        }
예제 #13
0
 protected virtual void DestroyHand()
 {
     if (handInstance != null)
     {
         Destroy(handInstance);
         handRenderers = null;
         handInstance  = null;
         handSkeleton  = null;
         handAnimator  = null;
     }
 }
예제 #14
0
 public void OffGripPose(SteamVR_Behaviour_Skeleton skeleton)
 {
     if (skeletonPoser != null)
     {
         if (skeleton != null)
         {
             Debug.Log("Off Pose");
             skeleton.BlendToSkeleton(releasePoseBlendTime);
         }
     }
 }
예제 #15
0
    // Initialization:
    void Start()
    {
        handAction = GameObject.Find("vr_glove_right_model_slim").GetComponent <SteamVR_Behaviour_Skeleton>();
        // Set the welcome message.
        HUDText      = GameObject.Find("HUDText").GetComponent <Text>();
        HUDText.text = "Welcome to MARUI Gesture Plug-in!\n"
                       + "This manager allows you to create and record gestures,\n"
                       + "and organize gesture files.\n"
                       + "Please use the Inspector for the XR rig.";

        me = GCHandle.Alloc(this);


        GameObject controller_oculus_left     = GameObject.Find("controller_oculus_left");
        GameObject controller_oculus_right    = GameObject.Find("controller_oculus_right");
        GameObject controller_vive_left       = GameObject.Find("controller_vive_left");
        GameObject controller_vive_right      = GameObject.Find("controller_vive_right");
        GameObject controller_microsoft_left  = GameObject.Find("controller_microsoft_left");
        GameObject controller_microsoft_right = GameObject.Find("controller_microsoft_right");
        GameObject controller_dummy_left      = GameObject.Find("controller_dummy_left");
        GameObject controller_dummy_right     = GameObject.Find("controller_dummy_right");

        handAction = GameObject.Find("vr_glove_right_model_slim").GetComponent <SteamVR_Behaviour_Skeleton>();

        controller_oculus_left.SetActive(false);
        controller_oculus_right.SetActive(false);
        controller_vive_left.SetActive(false);
        controller_vive_right.SetActive(false);
        controller_microsoft_left.SetActive(false);
        controller_microsoft_right.SetActive(false);
        controller_dummy_left.SetActive(false);
        controller_dummy_right.SetActive(false);

        if (XRDevice.model.Length >= 6 && XRDevice.model.Substring(0, 6) == "Oculus")
        {
            controller_oculus_left.SetActive(true);
            controller_oculus_right.SetActive(true);
        }
        else if (XRDevice.model.Length >= 4 && XRDevice.model.Substring(0, 4) == "Vive")
        {
            controller_vive_left.SetActive(true);
            controller_vive_right.SetActive(true);
        }
        else if (XRDevice.model.Length >= 4 && XRDevice.model.Substring(0, 4) == "DELL")
        {
            controller_microsoft_left.SetActive(true);
            controller_microsoft_right.SetActive(true);
        }
        else //
        {
            controller_dummy_left.SetActive(true);
            controller_dummy_right.SetActive(true);
        }
    }
예제 #16
0
 private void recognizePeaceSign(SteamVR_Behaviour_Skeleton skeleton)
 {
     if ((skeleton.indexCurl <= openFingerAmount && skeleton.middleCurl <= openFingerAmount) &&
         (skeleton.thumbCurl >= closedThumbAmount && skeleton.ringCurl >= closedFingerAmount && skeleton.pinkyCurl >= closedFingerAmount))
     {
         PeaceSignRecognized(true);
     }
     else
     {
         PeaceSignRecognized(false);
     }
 }
예제 #17
0
        // Use this for initialization
        void Start()
        {
            poses    = GetComponent <KnucklePoses>();
            skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
            hand     = skeleton.inputSource;
            GameObject _claws = Instantiate(clawPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.wrist), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.wrist));

            _claws.transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.wrist);
            if (hand == SteamVR_Input_Sources.LeftHand)
            {
                _claws.transform.localScale = new Vector3(1, 1, 1);
            }
            claws = _claws.GetComponent <KnuckleClawScaler>();
        }
예제 #18
0
        private bool recognizePlayerFist(TrackedHand hand)
        {
            if (hand == null)
            {
                return(false);
            }

            SteamVR_Behaviour_Skeleton skeleton = hand.getSkeleton();

            if (skeleton != null)
            {
                return(hand.recognizeFist());
            }

            return(abilityActivated);
        }
예제 #19
0
        protected virtual void DestroyHand()
        {
            if (handSkeleton != null)
            {
                handSkeleton.skeletonAction.onActiveChange -= OnSkeletonActiveChange;
            }

            if (handInstance != null)
            {
                Destroy(handInstance);
                handRenderers = null;
                handInstance  = null;
                handSkeleton  = null;
                handAnimator  = null;
            }
        }
예제 #20
0
        protected virtual void DestroyHand()
        {
            Debug.Log($"Destroying hand for {gameObject.name}");
            if (handSkeleton != null)
            {
                handSkeleton.skeletonAction.onActiveChange -= OnSkeletonActiveChange;
            }

            if (handInstance != null)
            {
                Destroy(handInstance);
                handRenderers = null;
                handInstance  = null;
                handSkeleton  = null;
                handAnimator  = null;
            }
        }
예제 #21
0
        protected void SaveHandData(SteamVR_Skeleton_Pose_Hand handData, SteamVR_Behaviour_Skeleton thisSkeleton)
        {
            // handData.position = thisSkeleton.transform.InverseTransformPoint(poser.transform.position);
            handData.position = thisSkeleton.transform.localPosition;
            handData.rotation = thisSkeleton.transform.localRotation;// Quaternion.Inverse(thisSkeleton.transform.localRotation);

            handData.bonePositions = new Vector3[SteamVR_Action_Skeleton.numBones];
            handData.boneRotations = new Quaternion[SteamVR_Action_Skeleton.numBones];

            for (int boneIndex = 0; boneIndex < SteamVR_Action_Skeleton.numBones; boneIndex++)
            {
                Transform bone = thisSkeleton.GetBone(boneIndex);
                handData.bonePositions[boneIndex] = bone.localPosition;
                handData.boneRotations[boneIndex] = bone.localRotation;
            }

            EditorUtility.SetDirty(activePose);
        }
예제 #22
0
        // Use this for initialization
        void Start()
        {
            actionSet.ActivateSecondary();
            poses    = GetComponent <KnucklePoses>();
            skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
            hand     = skeleton.inputSource;
            if (spiritGunPrefab != null)
            {
                GameObject spiritGun = Instantiate(spiritGunPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.indexTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.indexTip));
                spiritGunEffect = spiritGun.GetComponent <SpiritGunGlow>();
                spiritGunEffect.transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.indexTip);
            }
            if (shockPrefab != null)
            {
                shockObjects[0] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.indexTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.indexTip));
                shockObjects[0].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.indexTip);
                shockObjects[0].SetActive(false);

                shockObjects[1] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.middleTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.middleTip));
                shockObjects[1].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.middleTip);
                shockObjects[1].SetActive(false);

                shockObjects[2] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.ringTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.ringTip));
                shockObjects[2].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.ringTip);
                shockObjects[2].SetActive(false);

                shockObjects[3] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.pinkyTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.pinkyTip));
                shockObjects[3].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.pinkyTip);
                shockObjects[3].SetActive(false);

                shockObjects[4] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.thumbTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.thumbTip));
                shockObjects[4].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.thumbTip);
                shockObjects[4].SetActive(false);

                if (hand == SteamVR_Input_Sources.LeftHand)
                {
                    foreach (GameObject shockObject in shockObjects)
                    {
                        shockObject.transform.localScale = new Vector3(1, 1, 1);
                    }
                }
            }
        }
        protected void SaveHandData(SteamVR_Skeleton_Pose_Hand handData, SteamVR_Behaviour_Skeleton hand)
        {
            // handData.position = hand.transform.InverseTransformPoint(baker.transform.position);
            handData.position = hand.transform.localPosition;

            handData.rotation = hand.transform.localRotation;// Quaternion.Inverse(hand.transform.localRotation);

            handData.bonePositions = new Vector3[SteamVR_Action_Skeleton.numBones];
            handData.boneRotations = new Quaternion[SteamVR_Action_Skeleton.numBones];

            for (int i = 0; i < SteamVR_Action_Skeleton.numBones; i++)
            {
                Transform bone = hand.GetBone(i);
                handData.bonePositions[i] = bone.localPosition;
                handData.boneRotations[i] = bone.localRotation;
            }

            // EditorUtility.SetDirty(activePose);
        }
예제 #24
0
        protected void InitializeHand()
        {
            if (handPrefab != null)
            {
                handInstance = GameObject.Instantiate(handPrefab);
                handInstance.transform.parent        = this.transform;
                handInstance.transform.localPosition = Vector3.zero;
                handInstance.transform.localRotation = Quaternion.identity;
                handInstance.transform.localScale    = handPrefab.transform.localScale;
                handSkeleton            = handInstance.GetComponent <SteamVR_Behaviour_Skeleton>();
                handSkeleton.updatePose = false;

                handRenderers = handInstance.GetComponentsInChildren <Renderer>();
                if (displayHandByDefault == false)
                {
                    SetHandVisibility(false);
                }

                handAnimator = handInstance.GetComponentInChildren <Animator>();
            }
        }
예제 #25
0
        private void Update()
        {
            if (Player.instance == null)
            {
                return;
            }

            Transform cam       = Camera.main.transform;
            bool      lookingAt = (Vector3.Angle(cam.forward, transform.position - cam.position) < 90);

            if (lookingAt == false)
            {
                return;
            }

            for (int handIndex = 0; handIndex < Player.instance.hands.Length; handIndex++)
            {
                if (Player.instance.hands[handIndex] != null)
                {
                    SteamVR_Behaviour_Skeleton skeleton = Player.instance.hands[handIndex].skeleton;
                    if (skeleton != null)
                    {
                        //Debug.LogFormat("{0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}", skeleton.thumbCurl, skeleton.indexCurl, skeleton.middleCurl, skeleton.ringCurl, skeleton.pinkyCurl);

                        if ((skeleton.indexCurl <= openFingerAmount && skeleton.middleCurl <= openFingerAmount) &&
                            (skeleton.thumbCurl >= closedThumbAmount && skeleton.ringCurl >= closedFingerAmount && skeleton.pinkyCurl >= closedFingerAmount))
                        {
                            PeaceSignRecognized(true);
                        }
                        else
                        {
                            PeaceSignRecognized(false);
                        }
                    }
                }
            }
        }
예제 #26
0
 private void Awake()
 {
     m_Pose     = GetComponent <SteamVR_Behaviour_Pose>();
     m_Skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
 }
예제 #27
0
 // Use this for initialization
 void Start()
 {
     elapsed = 0.0f;
     parent  = GetComponent <SteamVR_Behaviour_Skeleton>();
 }
예제 #28
0
        protected void UpdatePreviewHand(ref GameObject preview, ref bool showPreview, string assetName, SteamVR_Skeleton_Pose_Hand handData, SteamVR_Skeleton_Pose sourcePose, bool forceUpdate)
        {
            if (showPreview)
            {
                if (forceUpdate && preview != null)
                {
                    DestroyImmediate(preview);
                }

                if (preview == null)
                {
                    GameObject prefabProperty = null;
                    string[]   defPaths       = AssetDatabase.FindAssets(string.Format("t:Prefab {0}", assetName));
                    if (defPaths != null && defPaths.Length > 0)
                    {
                        string guid = defPaths[0];
                        string path = AssetDatabase.GUIDToAssetPath(guid);
                        prefabProperty = AssetDatabase.LoadAssetAtPath <GameObject>(path);

                        if (prefabProperty == null)
                        {
                            Debug.LogError("[SteamVR] Could not load prefab: " + assetName + ". Found path: " + path);
                        }
                    }
                    else
                    {
                        Debug.LogError("[SteamVR] Could not load prefab: " + assetName);
                    }

                    preview = GameObject.Instantiate(prefabProperty);
                    preview.transform.localScale    = Vector3.one * poserScale;//.floatValue;
                    preview.transform.parent        = poser.transform;
                    preview.transform.localPosition = Vector3.zero;
                    preview.transform.localRotation = Quaternion.identity;

                    SteamVR_Behaviour_Skeleton previewSkeleton = null;

                    if (preview != null)
                    {
                        previewSkeleton = preview.GetComponent <SteamVR_Behaviour_Skeleton>();
                    }

                    if (previewSkeleton != null)
                    {
                        if (handData.bonePositions == null || handData.bonePositions.Length == 0)
                        {
                            SteamVR_Skeleton_Pose poseResource = (SteamVR_Skeleton_Pose)Resources.Load("ReferencePose_OpenHand");
                            DeepCopyPose(poseResource, sourcePose);
                            EditorUtility.SetDirty(sourcePose);
                        }

                        preview.transform.localPosition = Vector3.zero;
                        preview.transform.localRotation = Quaternion.identity;
                        preview.transform.parent        = null;
                        preview.transform.localScale    = Vector3.one * poserScale;//.floatValue;
                        preview.transform.parent        = poser.transform;

                        preview.transform.localRotation = handData.rotation;
                        preview.transform.localPosition = handData.position;


                        for (int boneIndex = 0; boneIndex < handData.bonePositions.Length; boneIndex++)
                        {
                            Transform bone = previewSkeleton.GetBone(boneIndex);
                            bone.localPosition = handData.bonePositions[boneIndex];
                            bone.localRotation = handData.boneRotations[boneIndex];
                        }
                    }
                    SceneView.RepaintAll();
                }
            }
            else
            {
                if (preview != null)
                {
                    DestroyImmediate(preview);
                    SceneView.RepaintAll();
                }
            }
        }
예제 #29
0
 // Start is called before the first frame update
 void Start()
 {
     parent = this.GetComponent <SteamVR_Behaviour_Skeleton>();
 }
예제 #30
0
 private void Start()
 {
     tr       = GetComponent <Transform>();
     skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
 }