Exemple #1
0
        void UpdatePickedColor(PickedColorCallback cb)
        {
            var headPosition  = Camera.main.transform.position;
            var gazeDirection = Camera.main.transform.forward;

            RaycastHit hit;

            if (!Physics.Raycast(headPosition, gazeDirection, out hit))
            {
                return;
            }
            if (hit.transform.gameObject != rendererComponent.gameObject)
            {
                return;
            }

            Texture2D texture = rendererComponent.material.mainTexture as Texture2D;
            Vector2   pixelUV = hit.textureCoord;

            pixelUV.x *= texture.width;
            pixelUV.y *= texture.height;

            Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y);

            cb.Invoke(col);
            SendMessageUpwards("OnColorCommand", col);
        }
Exemple #2
0
        void UpdatePickedColor(PickedColorCallback cb)
        {
            RaycastHit hit = GazeManager.Instance.HitInfo;

            if (hit.transform.gameObject != rendererComponent.gameObject)
            {
                return;
            }

            Texture2D texture = rendererComponent.material.mainTexture as Texture2D;
            Vector2   pixelUV = hit.textureCoord;

            pixelUV.x *= texture.width;
            pixelUV.y *= texture.height;

            GazedColor = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y);
            cb.Invoke(GazedColor);
        }
Exemple #3
0
        private void UpdatePickedColor(PickedColorCallback cb)
        {
            GameObject hitObject = GazeManager.Instance.HitObject;

            if (hitObject != rendererComponent.gameObject)
            {
                return;
            }

            //TODO: Fix by adding RaycastHit properties to FocusDetails.
            //Texture2D texture = rendererComponent.material.mainTexture as Texture2D;

            //Vector2 pixelUV = hit.textureCoord;
            //pixelUV.x *= texture.width;
            //pixelUV.y *= texture.height;

            //Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y);
            //cb.Invoke(col);
        }
        void UpdatePickedColor(PickedColorCallback cb)
        {
            RaycastHit hit = GazeManager.Instance.HitInfo;

            if (hit.transform != null && hit.transform.gameObject != rendererComponent.gameObject)
            {
                return;
            }

            voice.Play();

            Vector2 pixelUV = hit.textureCoord;

            pixelUV.x *= texture.width;
            pixelUV.y *= texture.height;

            Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y);

            cb.Invoke(col);
        }
    void UpdatePickedColor(PickedColorCallback cb)
    {
        // if not hit, return
        RaycastHit hit = GazeManager.Instance.HitInfo;

        if (hit.transform.gameObject != rendererComponent.gameObject)
        {
            return;
        }

        // get color from texture pixel and callback
        Texture2D texture = rendererComponent.material.mainTexture as Texture2D;
        Vector2   pixelUV = hit.textureCoord;

        pixelUV.x *= texture.width;
        pixelUV.y *= texture.height;
        Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y);

        cb.Invoke(col);
    }