/// <summary>Updates the material based on the reticle properties.</summary>
    public void UpdateDiameters()
    {
        ReticleDistanceInMeters =
            Mathf.Clamp(ReticleDistanceInMeters, RETICLE_DISTANCE_MIN, maxReticleDistance);

        if (ReticleInnerAngle < RETICLE_MIN_INNER_ANGLE)
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
        }

        if (ReticleOuterAngle < RETICLE_MIN_OUTER_ANGLE)
        {
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;
        }

        float inner_half_angle_radians = Mathf.Deg2Rad * ReticleInnerAngle * 0.5f;
        float outer_half_angle_radians = Mathf.Deg2Rad * ReticleOuterAngle * 0.5f;

        float inner_diameter = 2.0f * Mathf.Tan(inner_half_angle_radians);
        float outer_diameter = 2.0f * Mathf.Tan(outer_half_angle_radians);

        ReticleInnerDiameter =
            Mathf.Lerp(ReticleInnerDiameter, inner_diameter, Time.unscaledDeltaTime * reticleGrowthSpeed);
        ReticleOuterDiameter =
            Mathf.Lerp(ReticleOuterDiameter, outer_diameter, Time.unscaledDeltaTime * reticleGrowthSpeed);

        MaterialComp.SetFloat("_InnerDiameter", ReticleInnerDiameter * ReticleDistanceInMeters);
        MaterialComp.SetFloat("_OuterDiameter", ReticleOuterDiameter * ReticleDistanceInMeters);
        MaterialComp.SetFloat("_DistanceInMeters", ReticleDistanceInMeters);
    }
Exemple #2
0
    public override void OnPointerHover(RaycastResult raycastResultResult, bool isInteractive)
    {
        SetPointerTarget(raycastResultResult.worldPosition, isInteractive);
        // TD: Just to be safe.
        if (gazedAt != null && gazeStartTime > 0f)
        {
            // TD: Indicate amount of time passed (shape would be better but this is simple)
            MaterialComp.SetColor("_Color",
                                  Color.HSVToRGB(0, ((Time.time - gazeStartTime) / clickTime), 1));

            // TD: Check if enough time has passed to act as click.
            // Check if the object is a gaze timer one,
            // and make sure event can only fire once.
            if (Time.time - gazeStartTime > clickTime &&
                ExecuteEvents.CanHandleEvent <ITimedInputHandler> (gazedAt))
            {
                ExecuteEvents.Execute(gazedAt, null,
                                      (ITimedInputHandler handler, BaseEventData data) => handler.HandleTimedInput());

                ResetGazeTimer();
            }

//			// Another version, simpler but not scalable
//			if (Time.time - gazeStartTime > clickTime &&
//				gazedAt.GetComponent<TimedInputObject>()) {
//
//				gazedAt.GetComponent<TimedInputObject>().HandleTimedInput();
//
//				ResetGazeTimer();
//			}
        }
    }
 public override void OnPointerExit(GameObject previousObject)
 {
     ReticleDistanceInMeters = RETICLE_DISTANCE_MAX;
     ReticleInnerAngle       = RETICLE_MIN_INNER_ANGLE;
     ReticleOuterAngle       = RETICLE_MIN_OUTER_ANGLE;
     MaterialComp.SetColor("_Color", inactiveColor);
 }
    private bool SetPointerTarget(Vector3 target, bool interactive)
    {
        if (base.PointerTransform == null)
        {
            Debug.LogWarning("Cannot operate on a null pointer transform");
            return(false);
        }

        Vector3 targetLocalPosition = base.PointerTransform.InverseTransformPoint(target);

        ReticleDistanceInMeters =
            Mathf.Clamp(targetLocalPosition.z, RETICLE_DISTANCE_MIN, RETICLE_DISTANCE_MAX);
        if (interactive)
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE + RETICLE_GROWTH_ANGLE;
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE + RETICLE_GROWTH_ANGLE;
            MaterialComp.SetColor("_Color", activeColor);
        }
        else
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;
            MaterialComp.SetColor("_Color", inactiveColor);
        }
        return(true);
    }
    //disable되는순간 초점을 원래크기로 초기화한다
    private void OnDisable()
    {
        ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
        ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;

        float inner_half_angle_radians = Mathf.Deg2Rad * ReticleInnerAngle * 0.5f;
        float outer_half_angle_radians = Mathf.Deg2Rad * ReticleOuterAngle * 0.5f;

        float inner_diameter = 2.0f * Mathf.Tan(inner_half_angle_radians);
        float outer_diameter = 2.0f * Mathf.Tan(outer_half_angle_radians);

        ReticleInnerDiameter = inner_diameter;
        ReticleOuterDiameter = outer_diameter;

        MaterialComp.SetFloat("_InnerDiameter", ReticleInnerDiameter * ReticleDistanceInMeters);
        MaterialComp.SetFloat("_OuterDiameter", ReticleOuterDiameter * ReticleDistanceInMeters);
        MaterialComp.SetFloat("_DistanceInMeters", ReticleDistanceInMeters);
    }
Exemple #6
0
    public void UpdateDiameters()
    {
        if (ReticleInnerAngle < RETICLE_MIN_INNER_ANGLE)
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
        }

        if (ReticleOuterAngle < RETICLE_MIN_OUTER_ANGLE)
        {
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;
        }

        ReticleInnerDiameter =
            Mathf.Lerp(ReticleInnerDiameter, ReticleInnerAngle, Time.unscaledDeltaTime * reticleGrowthSpeed);
        ReticleOuterDiameter =
            Mathf.Lerp(ReticleOuterDiameter, ReticleOuterAngle, Time.unscaledDeltaTime * reticleGrowthSpeed);

        MaterialComp.SetFloat("_InnerDiameter", ReticleInnerDiameter);
        MaterialComp.SetFloat("_OuterDiameter", ReticleOuterDiameter);
    }
    public void UpdateDiameters()
    {
        ReticleDistanceInMeters =
            Mathf.Clamp(ReticleDistanceInMeters, RETICLE_DISTANCE_MIN, maxReticleDistance);

        if (ReticleInnerAngle < RETICLE_MIN_INNER_ANGLE)
        {
            ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
        }

        if (ReticleOuterAngle < RETICLE_MIN_OUTER_ANGLE)
        {
            ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;
        }

        if (ReticleInnerAngle > RETICLE_MAX_INNER_ANGLE)
        {
            ReticleInnerAngle = RETICLE_MAX_INNER_ANGLE;
        }

        if (ReticleOuterAngle > RETICLE_MAX_OUTER_ANGLE)
        {
            ReticleOuterAngle = RETICLE_MAX_OUTER_ANGLE;
        }

        float inner_half_angle_radians = Mathf.Deg2Rad * ReticleInnerAngle * 0.5f;
        float outer_half_angle_radians = Mathf.Deg2Rad * ReticleOuterAngle * 0.5f;

        float inner_diameter = 2.0f * Mathf.Tan(inner_half_angle_radians);
        float outer_diameter = 2.0f * Mathf.Tan(outer_half_angle_radians);

        // Grow fast, shrink slow
        if (ReticleInnerDiameter < inner_diameter)
        {
            reticleGrowthSpeed = 100f;
        }
        else
        {
            reticleGrowthSpeed = 0.5f;
        }

        if (CurrentRaycastResult.gameObject != null)
        {
            if (CurrentRaycastResult.gameObject.tag == "board")
            {
                CurrentRaycastResult.gameObject.SendMessage("FocusPoint", CurrentRaycastResult.worldPosition);
            }

            if (ReticleOuterDiameter < 0.02 && CurrentRaycastResult.gameObject != null)
            {
                Target targ = CurrentRaycastResult.gameObject.GetComponent <Target>();
                if (targ != null)
                {
                    CurrentRaycastResult.gameObject.GetComponent <Target>().OnGazeLock();
                }
            }
        }

        ReticleInnerDiameter =
            Mathf.Lerp(ReticleInnerDiameter, inner_diameter, Time.deltaTime * reticleGrowthSpeed);
        ReticleOuterDiameter =
            Mathf.Lerp(ReticleOuterDiameter, outer_diameter, Time.deltaTime * reticleGrowthSpeed);

        MaterialComp.SetFloat("_InnerDiameter", ReticleInnerDiameter * ReticleDistanceInMeters);
        MaterialComp.SetFloat("_OuterDiameter", ReticleOuterDiameter * ReticleDistanceInMeters);
        MaterialComp.SetFloat("_DistanceInMeters", ReticleDistanceInMeters);
    }
Exemple #8
0
 void ResetGazeTimer()
 {
     MaterialComp.SetColor("_Color", Color.white);
     gazeStartTime = -1f;
     gazedAt       = null;
 }