コード例 #1
0
    //HELPER METHOD

    private MyTrackableObject ContainedInDict(string objName)
    {
        MyTrackableObject obj;

        if (!myTrackedObjectsDict.ContainsKey(objName))
        {
            obj = new MyTrackableObject(objName, (int)objectStates.visible);
            myTrackedObjectsDict.Add(objName, obj);
        }
        else
        {
            obj = myTrackedObjectsDict[objName];
        }

        return(obj);
    }
コード例 #2
0
    // UPDATE - CALLED ONCE PER FRAME

    void Update()
    {
        if (ProcessingBool)
        {
            // RANDOM "ATTENTION" - TO BE REPLACED WITH WATSON

            //counter++;

            //if (counter >= 1000)
            //{
            //    counter = 0;

            //    System.Random r = new System.Random();

            //    if (r.Next(0, 2) == 0)
            //    { attentionObject = (string)activeObjectsList[0]; }
            //    else
            //    { attentionObject = (string)activeObjectsList[1]; }
            //}

            activeObjectString.text = attentionObject;

            // RANDOM END

            IEnumerable <TrackableBehaviour> activeTrackables = trackerManager.GetActiveTrackableBehaviours();

            foreach (var obj in myTrackedObjectsDict)
            {
                //if (obj.Value.State == (int)objectStates.attention)
                //{
                //    // REQUESTED - YELLOW

                //    obj.Value.State = (int)objectStates.active;

                //    if (obj.Key == "Scalpel")
                //    {
                //        scalpelString.color = Color.yellow;
                //    }
                //    else if (obj.Key == "Tweezers")
                //    {
                //        tweezersString.color = Color.yellow;
                //    }
                //    else if (obj.Key == "Scissors")
                //    {
                //        scissorsString.color = Color.yellow;
                //    }
                //}
                //else
                //{
                //UNSURE - ORNAGE

                obj.Value.State = (int)objectStates.unsure;

                if (obj.Key == "Scalpel")
                {
                    scalpelString.color = new Color(255, 165, 0);
                }
                else if (obj.Key == "Tweezers")
                {
                    tweezersString.color = new Color(255, 165, 0);
                }
                else if (obj.Key == "Scissors")
                {
                    scissorsString.color = new Color(255, 165, 0);
                }
                //}
            }

            // Iterate through the list of active trackables
            foreach (TrackableBehaviour tracked in activeTrackables)
            {
                //TRACKED - RESET TO GRAY

                if (tracked.TrackableName == "Scalpel")
                {
                    mTrackedObject       = ContainedInDict("Scalpel");
                    mTrackedObject.State = (int)objectStates.visible;
                    scalpelString.color  = Color.gray;
                }
                else if (tracked.TrackableName == "Tweezers")
                {
                    mTrackedObject       = ContainedInDict("Tweezers");
                    mTrackedObject.State = (int)objectStates.visible;
                    tweezersString.color = Color.gray;
                }
                else if (tracked.TrackableName == "Scissors")
                {
                    mTrackedObject       = ContainedInDict("Scissors");
                    mTrackedObject.State = (int)objectStates.visible;
                    scissorsString.color = Color.gray;
                }

                //ATTENTION - GREEN

                if (tracked.TrackableName == "Scalpel" && (attentionObject == "scalpel" || attentionObject == "Scalpel"))
                {
                    mTrackedObject.State = (int)objectStates.attention;
                    scalpelString.color  = Color.green;
                }
                else if (tracked.TrackableName == "Tweezers" && (attentionObject == "tweezers" || attentionObject == "Tweezers"))
                {
                    mTrackedObject.State = (int)objectStates.attention;
                    tweezersString.color = Color.green;
                }
                else if (tracked.TrackableName == "Scissors" && (attentionObject == "scissor" || attentionObject == "Scissor" || attentionObject == "scissors" || attentionObject == "Scissors"))
                {
                    mTrackedObject.State = (int)objectStates.attention;
                    scissorsString.color = Color.green;
                }
            }
        }
    }