Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (RayFromCamera.ObjectLookAt() != null && teleport.CanTeleport)
        {
            //Debug.Log(Pose.GetLocalPosition(HandType).y + "  " + Pose.GetVelocity(HandType).y);
            GameObject obj = RayFromCamera.ObjectLookAt();
            //if (Pose.GetLocalPosition(HandType).y <= teleport.heightRequired &&
            //    (Pose.GetLastLocalPosition(HandType).y - Pose.GetLocalPosition(HandType).y) > 0 &&

            //    (Pose.GetLastVelocity(HandType).y - Pose.GetVelocity(HandType).y) > 0 &&
            //    Pose.GetVelocity(HandType).y <= teleport.speedRequired)

            //if((Pose.GetVelocity(HandType).y > 1 && Pose.GetLocalPosition(HandType).y > 0.1f) || Trigger.GetStateDown(SteamVR_Input_Sources.Any))



            if (Pose.GetLocalPosition(HandType).y <= teleport.heightRequired &&
                (Pose.GetLastLocalPosition(HandType).y - Pose.GetLocalPosition(HandType).y) > 0 &&
                (Pose.GetLastVelocity(HandType).y - Pose.GetVelocity(HandType).y) > 0 &&
                Pose.GetVelocity(HandType).y <= teleport.speedRequired)
            {
                teleport.Begin(obj);
                teleport.CanTeleport = false;
            }
        }

        //ShowTargetObject();
    }
Example #2
0
    public float GetSpinSpeed(HandSide hand)
    {
        if (!checkedCylinderRenderer && VRInputBridge.instance.aimScript_ref != null && VRInputBridge.instance.aimScript_ref.gun_script.HasGunComponent(GunAspect.REVOLVER_CYLINDER))
        {
            CylinderVisualComponent cylvis = VRInputBridge.instance.aimScript_ref.gun_script.GetComponent <CylinderVisualComponent>();
            if (cylvis != null)
            {
                if (cylvis.cylinder_assembly.Find("cylinder") != null)
                {
                    cylinderRenderer = cylvis.cylinder_assembly.Find("cylinder").GetComponent <Renderer>();
                }
                else
                {
                    cylinderRenderer = cylvis.cylinder_assembly.GetComponent <Renderer>();
                }
            }
            checkedCylinderRenderer = true;
        }
        if (cylinderRenderer != null)
        {
            switch (hand)
            {
            case HandSide.Right:
                if (cylinderRenderer.bounds.Contains(RHandSphere.transform.position))
                {
                    return(ControllerPose.GetVelocity(SteamVR_Input_Sources.RightHand).y);
                }
                else
                {
                    return(0f);
                }

            case HandSide.Left:
                if (cylinderRenderer.bounds.Contains(LHandSphere.transform.position))
                {
                    return(-ControllerPose.GetVelocity(SteamVR_Input_Sources.LeftHand).y);
                }
                else
                {
                    return(0f);
                }

            default:
                return(ControllerPose.GetVelocity(SteamVR_Input_Sources.RightHand).y);
            }
        }
        else
        {
            return(0f);
        }
    }
Example #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;
    }
Example #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;
    }
Example #5
0
        void OnTriggerStay(Collider col)
        {
            Debug.Log(velo.GetVelocity(SteamVR_Input_Sources.RightHand));
            GameObject grabObject = col.gameObject;

            print(colController.GetComponent <Rigidbody>().velocity);
            if (col.gameObject.CompareTag("Pickup") && grabAction.GetState(SteamVR_Input_Sources.Any))
            {
                grabObject.transform.SetParent(gameObject.transform);
                grabObject.GetComponent <Rigidbody> ().isKinematic = true;
            }
            else if (col.gameObject.CompareTag("Pickup") && grabAction.GetState(SteamVR_Input_Sources.Any) == false)
            {
                grabObject.transform.SetParent(GameObject.Find("Interactable").transform);
                grabObject.GetComponent <Rigidbody> ().isKinematic = false;
                grabObject.GetComponent <Rigidbody> ().velocity    = velo.GetVelocity(SteamVR_Input_Sources.RightHand);
            }
        }
    /// <summary>
    /// Checks the Tracker-Status and Updates the Position, Rotation and Velocity.
    /// </summary>
    protected override void UpdateTracker()
    {
        // Setting 'trackingOK' to false (In case we have an Error and return before the end of the method).
        trackingOK = false;
        // Check if OpenVR-System is found correctly.
        if (OpenVR.System == null)
        {
            Debug.LogError("<b>DHUI</b> | DroneTracking_Vive | OpenVR-System was not found.");
            return;
        }
        // If we didn't set the Action Pose.
        if (_VRTrackerActionPose == null)
        {
            // Check if there is an Active Action called "VRTracker".
            SteamVR_Action_Pose ap = SteamVR_Input.GetAction <SteamVR_Action_Pose>("VRTracker");
            if (ap.GetActive(SteamVR_Input_Sources.Any))
            {
                _VRTrackerActionPose = ap;
                droneTrackerIndex    = _VRTrackerActionPose.GetDeviceIndex(SteamVR_Input_Sources.Any);
            }
            else
            {
                Debug.LogError("<b>DHUI</b> | DroneTracking_Vive | No Active VR-Tracker was found.");
                return;
            }
        }

        // Copy Position and Rotation to the 'trackedTransform' and save the Velocity.
        // If 'trackTransformAsLocal' is true: Copy the real tracked pose to 'trackedTransform' as localPosition & localRotation
        if (trackTransformAsLocal)
        {
            trackedTransform.localPosition = _VRTrackerActionPose.GetLocalPosition(SteamVR_Input_Sources.Any) - trackerToDroneOffset_Position;
            trackedTransform.localRotation = _VRTrackerActionPose.GetLocalRotation(SteamVR_Input_Sources.Any) * Quaternion.Euler(trackerToDroneOffset_Rotation);
        }
        // If 'trackTransformAsLocal' is false (= default): Copy the real tracked pose to 'trackedTransform' as (global) position & rotation
        else
        {
            trackedTransform.position = _VRTrackerActionPose.GetLocalPosition(SteamVR_Input_Sources.Any) - trackerToDroneOffset_Position;
            trackedTransform.rotation = _VRTrackerActionPose.GetLocalRotation(SteamVR_Input_Sources.Any) * Quaternion.Euler(trackerToDroneOffset_Rotation);
        }

        velocity = _VRTrackerActionPose.GetVelocity(SteamVR_Input_Sources.Any);

        // Calculate the current pose for our device. [See https://github.com/ValveSoftware/openvr/wiki/IVRSystem::GetDeviceToAbsoluteTrackingPose]
        TrackedDevicePose_t[] trackedDevicePoses = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount];
        OpenVR.System.GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin.TrackingUniverseStanding, 0.0f, trackedDevicePoses);
        TrackedDevicePose_t droneTrackedDevicePose = trackedDevicePoses[droneTrackerIndex];

        // If the 'TrackedDevicePose' of the drone is valid, connected and running ok, we can set the 'trackingOK' to true.
        if (droneTrackedDevicePose.bPoseIsValid && droneTrackedDevicePose.bDeviceIsConnected && droneTrackedDevicePose.eTrackingResult == ETrackingResult.Running_OK)
        {
            trackingOK = true;
        }
    }
Example #7
0
    // このコンポーネントを付けたオブジェクトのCollider.IsTriggerをONにすること!
    void OnTriggerEnter(Collider other)
    {
        var meshCut = other.gameObject.GetComponent <MeshCut>();

        if (meshCut == null)
        {
            return;
        }

        if (pose.GetVelocity(HandType).magnitude <= 1)
        {
            other.GetComponent <Rigidbody>().velocity = pose.GetVelocity(HandType) * 10;
            return;
        }
        var cutPlane = new Plane(Vector3.Cross(transform.forward.normalized, prePos - transform.position).normalized, transform.position);

        meshCut.Cut(cutPlane, pose.GetVelocity(SteamVR_Input_Sources.RightHand));

        Vibration.Execute(0, time, herz, power, HandType);
    }
    private void OnDrawGizmos()
    {
        SteamVR_Action_Pose pose = SteamVR_Actions.default_Pose;
        Vector3             v    = pose.GetVelocity(SteamVR_Input_Sources.RightHand);
        Vector3             a    = pose.GetAngularVelocity(SteamVR_Input_Sources.RightHand);

        Debug.Log("V " + v.ToString("F4"));
        Debug.Log("A " + a.ToString("F4"));
        if (v.magnitude >= vThresh)
        {
            Gizmos.color = Color.cyan;
            Gizmos.DrawCube(GameObject.Find("Camera").transform.position + (GameObject.Find("Camera").transform.rotation *Vector3.forward).normalized * 2, new Vector3(0.1f, 0.1f, 0.1f));
        }
    }
Example #9
0
    private void Update()
    {
        tmp = righthand.transform.position;
        var WastAngle = waist.transform.rotation.eulerAngles;

        tmp2 = waist.transform.position;
        tmp3 = WastAngle;
        tmp4 = lefthand.transform.position;
        tmp5 = head.transform.position;

        if (ControllerInput.l == false)
        {
            if (actionToHaptic.GetStateDown(SteamVR_Input_Sources.LeftHand))
            {
                haptic.Execute(0, 0.1f, 60, 1, SteamVR_Input_Sources.LeftHand);
            }
            else if (actionToHaptic.GetStateDown(SteamVR_Input_Sources.RightHand))
            {
                haptic.Execute(0, 0.1f, 60, 1, SteamVR_Input_Sources.RightHand);
            }
            if (actionToHaptic2.GetStateDown(SteamVR_Input_Sources.Any))
            {
                audioSource.PlayOneShot(sound1);
                WaistRotationCheck();
            }

            if (actionToHaptic2.GetState(SteamVR_Input_Sources.RightHand))
            {
                BgmChange(i);
                w = actionToHaptic3.GetVelocity(SteamVR_Input_Sources.RightHand).magnitude;
                x = actionToHaptic3.GetVelocity(SteamVR_Input_Sources.LeftFoot).magnitude;
                y = actionToHaptic3.GetVelocity(SteamVR_Input_Sources.RightFoot).magnitude;

                Debug.Log(w);
            }

            else if (actionToHaptic2.GetState(SteamVR_Input_Sources.LeftHand))
            {
                CameraChange(b);
                v = actionToHaptic3.GetVelocity(SteamVR_Input_Sources.LeftHand).magnitude;
                x = actionToHaptic3.GetVelocity(SteamVR_Input_Sources.LeftFoot).magnitude;
                y = actionToHaptic3.GetVelocity(SteamVR_Input_Sources.RightFoot).magnitude;
                Debug.Log(v);
            }
            else
            {
                w = 0f;
                v = 0f;
                x = 0f;
                y = 0f;
            }
        }
    }
Example #10
0
        void DoGetVelocity()
        {
            switch (velocityType)
            {
            case setVelocityType.getVelocity:
                velocity = poseAction.GetVelocity(device);
                break;

            case setVelocityType.getLastStateVelocity:
                velocity = poseAction.GetLastVelocity(device);
                break;
            }


            vector.Value = velocity;
            x.Value      = velocity.x;
            y.Value      = velocity.y;
            z.Value      = velocity.z;
        }
Example #11
0
 public Vector3 GetControllerVel(HandSide hand)
 {
     return(pose.GetVelocity(hand == HandSide.Left ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand));
 }