Пример #1
0
    // only do this on 'focus'
    void ResetClipPlays()
    {
        DebugVR.vrPrint("ResetClipPlays called");

        // Reset all 'unfocused' clip plays
        for (int i = 0; i < am.unfocusClips.Length; i++)
        {
            // reset the 'hasPlayedThisSession' Boolean
            am.unfocusClips [i].GetComponent <AudioMessage> ().hasPlayedThisSession = false;
        }
    }
Пример #2
0
    public static int RaycastNonAlloc(
        Vector3 origin,
        Vector3 direction,
        RaycastHit[] results,
        float maxDistance,
        int layerMask = -1,
        QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal
        )
    {
        int hits = Physics.RaycastNonAlloc(origin, direction, results, maxDistance, layerMask, queryTriggerInteraction);

        DebugVR.DrawRaycastHits(hits, results, CAST_HIT_COLOR, CAST_HIT_DURATION);

        return(hits);
    }
Пример #3
0
    public static bool Raycast(
        Vector3 origin,
        Vector3 direction,
        out RaycastHit hitInfo,
        float maxDistance,
        int layerMask = -1,
        QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal
        )
    {
        bool hit = Physics.Raycast(origin, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);

        DebugVR.DrawArrow(origin, origin + (direction * maxDistance), RAYCAST_COLOR, CAST_DURATION);

        if (hit)
        {
            DebugVR.DrawRaycastHit(hitInfo, CAST_HIT_COLOR, CAST_HIT_DURATION);
        }

        return(hit);
    }
Пример #4
0
    /// <summary>
    /// Wrapper for Physics.SphereCast to automatically display the cast volume and hits for debugging
    /// </summary>
    public static bool SphereCast(
        Vector3 origin,
        float radius,
        Vector3 direction,
        out RaycastHit hitInfo,
        float maxDistance,
        int layerMask = -1,
        QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal
        )
    {
        bool hit = Physics.SphereCast(origin, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);

        DebugVR.DrawSphereCast(origin, radius, direction, maxDistance, SPHERECAST_COLOR, CAST_DURATION);

        if (hit)
        {
            DebugVR.DrawRaycastHit(hitInfo, CAST_HIT_COLOR, CAST_HIT_DURATION);
        }

        return(hit);
    }
Пример #5
0
    bool CheckGaze()
    {
        // Do a raycast into the world based on the user's
        // head position and orientation.
        var headPosition  = Camera.main.transform.position;
        var gazeDirection = Camera.main.transform.forward;

        RaycastHit hitInfo;

        if (Physics.Raycast(headPosition, gazeDirection, out hitInfo) && hitInfo.collider.gameObject.CompareTag("FocusZone"))
        {
            // If the raycast hit a hologram...
            // Display the cursor mesh.
            // meshRenderer.enabled = true;
            // print ("HIT");



            // TODO: Debug
            string collidedName = hitInfo.collider.gameObject.tag;
            DebugVR.vrPrintReplace("You're focused on " + collidedName);

            // TODO: This is a debug
            rend.material.SetColor("_Color", onColor);
            return(true);

            // Move the cursor to the point where the raycast hit.
            // this.transform.position = hitInfo.point;

            // Rotate the cursor to hug the surface of the hologram.
            // this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
        }
        else
        {
            DebugVR.vrPrintReplace("You're not focused!");
            rend.material.SetColor("_Color", offColor);
            return(false);
        }
    }