public int SetProjectors(string triePath, ProjectionAndFixedPrefix[] pfps)
            {
                IEnumerable <ProjectionAndFixedPrefix> matchingProjections =
                    pfps.Where(pfp => triePath.StartsWith(pfp.FixedPrefix) || pfp.FixedPrefix == "");

                IEnumerable <ProjectionAndFixedPrefix> mightLandHere =
                    matchingProjections.Where(pfp => pfp.FixedPrefix == "" ||
                                              !_children.Keys.Any(c => pfp.FixedPrefix.StartsWith(triePath + c)));

                _projections = mightLandHere.Select(pfp => pfp.Projection).ToArray();
                _projectorToUseIfNoCharMatches = new SimpleProjector(_projections, name: $"trie[{triePath}]");

                int nodeCount = 1;

                foreach (var kvp in _children)
                {
                    nodeCount += kvp.Value.SetProjectors(triePath + kvp.Key, pfps);
                }
                return(nodeCount);
            }
Example #2
0
    void Update()
    {
        if (message == null)
        {
            return;
        }

        if (message.Reset)
        {
            Debug.Log(this.ToString() + ": reset");
            yawOffset += -transform.rotation.eulerAngles.y;
        }

        attitude = message.Attitude;
        //transform.localRotation = Quaternion.AngleAxis(yawOffset, Vector3.up) * new Quaternion(-attitude.x, -attitude.z, -attitude.y, attitude.w);
        _filteredRotation.Value = attitude;
        transform.localRotation = Quaternion.AngleAxis(yawOffset, Vector3.up) * new Quaternion(-_filteredRotation.Value.x, -_filteredRotation.Value.z, -_filteredRotation.Value.y, _filteredRotation.Value.w);

        Ray ray = new Ray(transform.position, transform.forward);

        Debug.DrawRay(transform.position, transform.forward);

        //Debug.DrawLine(transform.position, transform.position + transform.forward * 1000.0f, Color.cyan);

        /* cenas do daniel... se calhar é apra ir cos porcos */

        SimpleProjector sp           = GameObject.Find("Projector").GetComponent <SimpleProjector>();
        Transform       screenCenter = GameObject.Find("localScreenCenter").transform;

        Plane surface = new Plane(screenCenter.forward, screenCenter.position);

        float distance;

        if (surface.Raycast(ray, out distance))
        {
            Vector3 hitPoint = ray.GetPoint(distance);
            Vector3 pixel    = Camera.main.WorldToScreenPoint(hitPoint);

            ray = Camera.main.ScreenPointToRay(pixel);

            sp.pixel  = pixel;
            sp.didHit = true;
        }
        else
        {
            sp.didHit = false;
        }


        /* fim cenas do daniel */

        Vector3 hit = Vector3.zero;

        _checkerboard.IAmPointing(ray, clickEvent.raiseEvent(message.Click), out hit);

        if (clickEvent.raiseEvent(message.Click))
        {
            Debug.Log(this.ToString() + ": selection event.");
        }
        else
        {
        }
    }