Esempio n. 1
0
    private void AddMarker(TuioObject tobj)
    {
        // TODO: This is not called if reacitvision is already running, and marker is on table
        int symbolID = tobj.getSymbolID();

        //if a marker ID is being recognized which is not being used be the program, cancel call and...
        //...prevents loopBar Markers to be added to lists
        if (markers.ContainsKey(symbolID) &&
            symbolID != m_settings.startLoopBarMarkerID && symbolID != m_settings.endLoopBarMarkerID)
        {
            GameObject currentMarker = markers[symbolID];
            currentMarker.GetComponent <FiducialController>().SetLastTimeAdded(Time.time);
            Debug.Log("Marker " + symbolID + " has been added to the grid.");

            //gets current color and adds marker to the according List
            ColorAccToPosition m_colorAccToPosition = currentMarker.GetComponent <ColorAccToPosition>();
            //updates sprite color - going too fast for loop in ColoAccToPosition script
            m_colorAccToPosition.CheckColor();
            Color m_color = currentMarker.GetComponent <SpriteRenderer>().color;

            if (m_color == red)
            {
                redMarkers.Add(currentMarker);
            }
            else if (m_color == green)
            {
                greenMarkers.Add(currentMarker);
            }
            else if (m_color == blue)
            {
                blueMarkers.Add(currentMarker);
            }
        }
    }
Esempio n. 2
0
    //keeps color allocation of markers up to date
    private void UpdateMarker(TuioObject tobj)
    {
        int symbolID = tobj.getSymbolID();

        //checks if fiducial library recognized marker which is not being used in this program and...
        //... prevents loopBar Markers to be added to lists
        if (markers.ContainsKey(symbolID) &&
            symbolID != m_settings.startLoopBarMarkerID && symbolID != m_settings.endLoopBarMarkerID)
        {
            GameObject currentMarker = markers[symbolID];

            //checks if marker if snapped, if so --> no further changements made (color change etc.)
            if (!currentMarker.GetComponent <FiducialController>().IsSnapped())
            {
                //gets current color, adds marker to the according List and removes from other lists (if containing)
                ColorAccToPosition m_colorAccToPosition = currentMarker.GetComponent <ColorAccToPosition>();
                //updates sprite color - going too fast for loop in ColoAccToPosition script
                m_colorAccToPosition.CheckColor();
                Color m_color = currentMarker.GetComponent <SpriteRenderer>().color;

                if (m_color == red && !redMarkers.Contains(currentMarker))
                {
                    redMarkers.Add(currentMarker);

                    if (blueMarkers.Contains(currentMarker))
                    {
                        blueMarkers.Remove(currentMarker);
                        Debug.Log("Marker " + symbolID + " switched colors from blue to red.");
                    }
                    else if (greenMarkers.Contains(currentMarker))
                    {
                        greenMarkers.Remove(currentMarker);
                        Debug.Log("Marker " + symbolID + " switched colors from green to red.");
                    }
                }
                else if (m_color == green && !greenMarkers.Contains(currentMarker))
                {
                    greenMarkers.Add(currentMarker);

                    if (blueMarkers.Contains(currentMarker))
                    {
                        blueMarkers.Remove(currentMarker);
                        Debug.Log("Marker " + symbolID + " switched colors blue to green.");
                    }
                    else if (redMarkers.Contains(currentMarker))
                    {
                        redMarkers.Remove(currentMarker);
                        Debug.Log("Marker " + symbolID + " switched colors red to green.");
                    }
                }
                else if (m_color == blue && !blueMarkers.Contains(currentMarker))
                {
                    blueMarkers.Add(currentMarker);

                    if (greenMarkers.Contains(currentMarker))
                    {
                        greenMarkers.Remove(currentMarker);
                        Debug.Log("Marker " + symbolID + " switched colors green to blue.");
                    }
                    else if (redMarkers.Contains(currentMarker))
                    {
                        redMarkers.Remove(currentMarker);
                        Debug.Log("Marker " + symbolID + " switched colors red to blue.");
                    }
                }
            }
        }
    }