Exemple #1
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();
    }
Exemple #2
0
 internal void NotifyReachable(bool canReach)
 {
     if (canReach)
     {
         _skeleton.BlendToAnimation();
     }
     else
     {
         _skeleton.BlendToSkeleton();
     }
 }
Exemple #3
0
    private void Release()
    {
        grabber.FixedJoint.connectedBody = null;
        grabber.StrongGrip.connectedBody = null;
        grabber.WeakGrip.connectedBody   = null;
        ConnectedObject.GetComponent <Rigidbody>().velocity        = position.GetVelocity(Hand) + transform.parent.GetComponent <Rigidbody>().velocity;
        ConnectedObject.GetComponent <Rigidbody>().angularVelocity = position.GetAngularVelocity(Hand) + transform.parent.GetComponent <Rigidbody>().angularVelocity;
        ConnectedObject.GetComponent <Rigidbody>().useGravity      = true;
        if (!ConnectedObject.GetComponent <Interactable>().SecondGripped)
        {
            ConnectedObject.GetComponent <Interactable>().gripped = false;

            ConnectedObject.GetComponent <Interactable>().GrippedBy = null;
        }
        else
        {
            ConnectedObject.GetComponent <Interactable>().SecondGripped = false;
        }

        ConnectedObject = null;
        if (OffsetObject.GetComponent <SteamVR_Skeleton_Poser>() && HandSkeleton)
        {
            HandSkeleton.transform.SetParent(transform, false);
            HandSkeleton.BlendToSkeleton();
        }
        OffsetObject.GetComponent <GrabPoint>().Gripped = false;
        OffsetObject = null;
    }
Exemple #4
0
    private void Release()
    {
        grabber.FixedJoint.connectedBody = null;//disconnect everything
        //grabber.StrongGrip.connectedBody = null;
        //grabber.WeakGrip.connectedBody = null;
        ConnectedObject.GetComponent <Rigidbody>().velocity        = position.GetVelocity(Hand);
        ConnectedObject.GetComponent <Rigidbody>().angularVelocity = position.GetAngularVelocity(Hand);//set the rotational velocitiy too
        ConnectedObject.GetComponent <Rigidbody>().useGravity      = true;
        ConnectedObject.GetComponent <Rigidbody>().mass            = 50;
        ConnectedObject.GetComponent <Block>().Dropped();
        if (!SecondGrip)//if we were the first to grab the object
        {
            ConnectedObject.GetComponent <Interactable>().gripped = false;
        }
        else//if we were  the second hand
        {
            ConnectedObject.GetComponent <Interactable>().SecondGripped = false;
            SecondGrip = false;
        }

        ConnectedObject = null;
        if (OffsetObject.GetComponent <SteamVR_Skeleton_Poser>() && HandSkeleton)//disconnect the hand if needed.
        {
            HandSkeleton.transform.SetParent(transform, false);
            HandSkeleton.BlendToSkeleton();
        }

        OffsetObject = null;
    }
 public void OffGripPose(SteamVR_Behaviour_Skeleton skeleton)
 {
     if (skeletonPoser != null)
     {
         if (skeleton != null)
         {
             Debug.Log("Off Pose");
             skeleton.BlendToSkeleton(releasePoseBlendTime);
         }
     }
 }
Exemple #6
0
 public void StopAnimation()
 {
     if (handSkeleton != null)
     {
         if (handSkeleton.isBlending == false)
         {
             handSkeleton.BlendToSkeleton();
         }
         if (CheckAnimatorInit())
         {
             handAnimator.SetInteger(handAnimatorStateId, 0);
         }
     }
 }
        void OnItemUnequipped(Inventory inventory, Item item, int slotIndex, bool quickEquipped)
        {
            if (slotIndex != myEquipIndex)
            {
                return;
            }

            if (quickEquipped)
            {
                if (item.itemBehavior.equipType != Inventory.EquipType.Static)
                {
                    Rigidbody rigidbody = item.rigidbody;
                    if (rigidbody != null)
                    {
                        Vector3 velocity;
                        Vector3 angularVelocity;

                        GetReleaseVelocities(rigidbody, out velocity, out angularVelocity);

                        rigidbody.velocity        = velocity;
                        rigidbody.angularVelocity = angularVelocity;
                    }
                }
            }

            VRItemAddon vr_item = item.GetComponent <VRItemAddon>();

            if (!vr_item)
            {
                Debug.LogError(item.name + " :: does not have a vr item component");
                return;
            }

            if (vr_item.hideHandOnAttach)
            {
                Show();
            }

            // if (vr_item.handAnimationOnPickup != 0)
            //     {

            //     StopAnimation();
            //     }

            if (vr_item.setRangeOfMotionOnPickup != SkeletalMotionRangeChange.None)
            {
                // Debug.LogError("range of motion unewiup");
                ResetTemporarySkeletonRangeOfMotion();
            }

            if (mainRenderModel != null)
            {
                // Debug.LogError("render mdel");
                mainRenderModel.ReturnHandToOrigin();
                // mainRenderModel.MatchHandToTransform(mainRenderModel.transform);
            }
            //move to vr interacable
            if (vr_item.usePose)
            // if (!string.IsNullOrEmpty(vr_item.poseToUse))//.skeletonPoser != null)
            {
                if (skeleton != null)
                {
                    // Debug.LogError("blend to skeleton");
                    skeleton.BlendToSkeleton(releasePoseBlendTime);
                }
            }

            if (vr_item.activateActionSetOnAttach != null)
            {
                // int otherHandEquipIndex = VRManager.Hand2Int(VRManager.OtherHand(handType));
                // int otherHandEquipIndex = 1-GetComponent<EquipPoint>().equipSlotOnBase;
                // if (inventory.otherInventory.equippedItem == null || inventory.otherInventory.equippedItem.item.GetComponent<VRItemAddon>().activateActionSetOnAttach != vr_item.activateActionSetOnAttach)
                if (inventory.equippedSlots[otherHandEquipIndex] == null || inventory.equippedSlots[otherHandEquipIndex].sceneItem.GetComponent <VRItemAddon>().activateActionSetOnAttach != vr_item.activateActionSetOnAttach)

                {
                    vr_item.activateActionSetOnAttach.Deactivate(handType);
                }
            }
        }