Exemplo n.º 1
0
            // ArucoObjectController methods

            /// <summary>
            /// Activate the tracker associated with the <paramref name="arucoObject"/> and configure its gameObject.
            /// </summary>
            /// <param name="arucoObject">The added ArUco object.</param>
            protected virtual void ArucoObjectsController_ArucoObjectAdded(ArucoObject arucoObject)
            {
                if (arucoObject.GetType() != typeof(ArucoMarker))
                {
                    ArucoObjectTracker tracker = null;
                    if (!additionalTrackers.TryGetValue(arucoObject.GetType(), out tracker))
                    {
                        throw new System.ArgumentException("No tracker found for the type '" + arucoObject.GetType() + "'.", "arucoObject");
                    }
                    else if (!tracker.IsActivated)
                    {
                        tracker.Activate(this);
                    }
                }
            }
Exemplo n.º 2
0
            // ArucoObjectController methods

            /// <summary>
            /// Suscribe to the property events of an ArUco object, and hide its gameObject since it has not been detected yet.
            /// </summary>
            /// <param name="arucoObject">The new ArUco object to suscribe.</param>
            protected virtual void ArucoObjectController_ArucoObjectAdded(ArucoObject arucoObject)
            {
                ArucoObjectTracker tracker = null;

                if (arucoObject.GetType() != typeof(ArucoMarker) && !additionalTrackers.TryGetValue(arucoObject.GetType(), out tracker))
                {
                    Debug.LogError("No tracker found for the type '" + arucoObject.GetType() + "'. Removing the object '" + arucoObject.gameObject.name +
                                   "' from the tracking list.");
                    Remove(arucoObject);
                    return;
                }

                if (tracker != null && !tracker.IsActivated)
                {
                    tracker.Activate(this);
                }

                arucoObject.gameObject.SetActive(false);
            }
Exemplo n.º 3
0
            // ArucoObjectController methods

            /// <summary>
            /// Activate the tracker associated with the <paramref name="arucoObject"/> and configure its gameObject.
            /// </summary>
            /// <param name="arucoObject">The added ArUco object.</param>
            protected virtual void ArucoObjectsController_ArucoObjectAdded(ArucoObject arucoObject)
            {
                if (arucoObject.GetType() == typeof(ArucoMarker))
                {
                    return;
                }

                // Activate the tracker if necessary
                ArucoObjectTracker tracker = null;

                if (!additionalTrackers.TryGetValue(arucoObject.GetType(), out tracker))
                {
                    throw new System.ArgumentException("No tracker found for the type '" + arucoObject.GetType() + "'.", "arucoObject");
                }
                else if (!tracker.IsActivated)
                {
                    tracker.Activate(this);
                }

                // Configure the game object
                AdjustGameObjectScale(arucoObject);
                arucoObject.gameObject.SetActive(false);
            }
Exemplo n.º 4
0
            /// <summary>
            /// Deactivate the tracker associated with the <paramref name="arucoObject"/> if it was the last one of this type.
            /// </summary>
            /// <param name="arucoObject">The removed</param>
            protected virtual void ArucoObjectsController_ArucoObjectRemoved(ArucoObject arucoObject)
            {
                ArucoObjectTracker tracker = null;

                if (arucoObject.GetType() == typeof(ArucoMarker) || !additionalTrackers.TryGetValue(arucoObject.GetType(), out tracker))
                {
                    return;
                }

                if (tracker.IsActivated)
                {
                    bool deactivateTracker = true;

                    // Try to find at leat one object of the same type as arucoObject
                    foreach (var arucoObjectDictionary in ArucoObjects)
                    {
                        foreach (var arucoObject2 in arucoObjectDictionary.Value)
                        {
                            if (arucoObject2.GetType() == arucoObject.GetType())
                            {
                                deactivateTracker = false;
                                break;
                            }
                        }
                        if (!deactivateTracker)
                        {
                            break;
                        }
                    }

                    if (deactivateTracker)
                    {
                        tracker.Deactivate();
                    }
                }
            }