Example #1
0
        private bool CreateObjectTargets()
        {
            int num = VuforiaWrapper.Instance.DataSetGetNumTrackableType((int)TypeMapping.GetTypeID(typeof(ObjectTarget)), this.mDataSetPtr);

            if (num <= 0)
            {
                return(false);
            }
            IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SimpleTargetData)) * num);

            if (VuforiaWrapper.Instance.DataSetGetTrackablesOfType((int)TypeMapping.GetTypeID(typeof(ObjectTarget)), intPtr, num, this.mDataSetPtr) == 0)
            {
                Debug.LogError("Could not create Object Targets");
                return(false);
            }
            for (int i = 0; i < num; i++)
            {
                SimpleTargetData simpleTargetData = (SimpleTargetData)Marshal.PtrToStructure(new IntPtr(intPtr.ToInt64() + (long)(i * Marshal.SizeOf(typeof(SimpleTargetData)))), typeof(SimpleTargetData));
                if (!this.mTrackablesDict.ContainsKey(simpleTargetData.id))
                {
                    StringBuilder stringBuilder = new StringBuilder(128);
                    VuforiaWrapper.Instance.DataSetGetTrackableName(this.mDataSetPtr, simpleTargetData.id, stringBuilder, 128);
                    ObjectTarget value = new ObjectTargetImpl(stringBuilder.ToString(), simpleTargetData.id, this);
                    this.mTrackablesDict[simpleTargetData.id] = value;
                }
            }
            Marshal.FreeHGlobal(intPtr);
            return(true);
        }
        public override T InitTracker <T>()
        {
            if (!VuforiaRuntimeUtilities.IsVuforiaEnabled())
            {
                return(default(T));
            }
            bool flag = true;

            if (VuforiaRuntimeUtilities.IsPlayMode() && (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker)))
            {
                flag = false;
            }
            if (flag && VuforiaWrapper.Instance.TrackerManagerInitTracker((int)TypeMapping.GetTypeID(typeof(T))) == 0)
            {
                Debug.LogError("Could not initialize the tracker.");
                return(default(T));
            }
            if (typeof(T) == typeof(ObjectTracker))
            {
                if (this.mObjectTracker == null)
                {
                    this.mObjectTracker = new ObjectTrackerImpl();
                }
                return(this.mObjectTracker as T);
            }
            if (typeof(T) == typeof(TextTracker))
            {
                if (this.mTextTracker == null)
                {
                    this.mTextTracker = new TextTrackerImpl();
                }
                return(this.mTextTracker as T);
            }
            if (typeof(T) == typeof(SmartTerrainTracker))
            {
                if (this.mSmartTerrainTracker == null)
                {
                    this.mSmartTerrainTracker = new SmartTerrainTrackerImpl();
                }
                return(this.mSmartTerrainTracker as T);
            }
            if (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker))
            {
                if (this.mDeviceTracker == null)
                {
                    if (VuforiaRuntimeUtilities.IsPlayMode())
                    {
                        this.mDeviceTracker = new RotationalPlayModeDeviceTrackerImpl();
                    }
                    else
                    {
                        this.mDeviceTracker = new RotationalDeviceTrackerImpl();
                    }
                }
                return(this.mDeviceTracker as T);
            }
            Debug.LogError("Could not initialize tracker. Unknown tracker type.");
            return(default(T));
        }
Example #3
0
 public override bool Start()
 {
     if (VuforiaWrapper.Instance.TrackerStart((int)TypeMapping.GetTypeID(typeof(ObjectTracker))) != 1)
     {
         this.IsActive = false;
         Debug.LogError("Could not start tracker.");
         return(false);
     }
     this.IsActive = true;
     return(true);
 }
 public override void Stop()
 {
     VuforiaWrapper.Instance.TrackerStop((int)TypeMapping.GetTypeID(typeof(SmartTerrainTracker)));
     this.IsActive = false;
     using (IEnumerator <ReconstructionAbstractBehaviour> enumerator = this.mSmartTerrainBuilder.GetReconstructions().GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             enumerator.Current.SetBehavioursToNotFound();
         }
     }
 }
Example #5
0
 public override bool Start()
 {
     if (VuforiaWrapper.Instance.TrackerStart((int)TypeMapping.GetTypeID(typeof(RotationalDeviceTracker))) != 1)
     {
         this.IsActive = false;
         Debug.LogError("Could not start tracker.");
         return(false);
     }
     this.RecenterPoseToCurrentAnchorPointPosition(true);
     VuforiaManager.Instance.WorldCenterMode = VuforiaARController.WorldCenterMode.DEVICE_TRACKING;
     this.IsActive = true;
     return(true);
 }
Example #6
0
        public override void Stop()
        {
            VuforiaWrapper.Instance.TrackerStop((int)TypeMapping.GetTypeID(typeof(ObjectTracker)));
            this.IsActive = false;
            StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager();

            using (List <DataSetImpl> .Enumerator enumerator = this.mActiveDataSets.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    foreach (Trackable current in enumerator.Current.GetTrackables())
                    {
                        stateManagerImpl.SetTrackableBehavioursForTrackableToNotFound(current);
                    }
                }
            }
        }
Example #7
0
        public override DataSetTrackableBehaviour CreateTrackable(TrackableSource trackableSource, GameObject gameObject)
        {
            TrackableSourceImpl trackableSourceImpl = (TrackableSourceImpl)trackableSource;
            StringBuilder       stringBuilder       = new StringBuilder(128);
            IntPtr           intPtr           = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SimpleTargetData)));
            int              num              = VuforiaWrapper.Instance.DataSetCreateTrackable(this.mDataSetPtr, trackableSourceImpl.TrackableSourcePtr, stringBuilder, 128, intPtr);
            SimpleTargetData simpleTargetData = (SimpleTargetData)Marshal.PtrToStructure(intPtr, typeof(SimpleTargetData));

            Marshal.FreeHGlobal(intPtr);
            if (num == (int)TypeMapping.GetTypeID(typeof(ImageTarget)))
            {
                ImageTarget imageTarget = new ImageTargetImpl(stringBuilder.ToString(), simpleTargetData.id, ImageTargetType.USER_DEFINED, this);
                this.mTrackablesDict[simpleTargetData.id] = imageTarget;
                Debug.Log(string.Format("Trackable created: {0}, {1}", num, stringBuilder));
                return(((StateManagerImpl)TrackerManager.Instance.GetStateManager()).FindOrCreateImageTargetBehaviourForTrackable(imageTarget, gameObject, this));
            }
            Debug.LogError("DataSet.CreateTrackable returned unknown or incompatible trackable type!");
            return(null);
        }
        public override bool DeinitTracker <T>()
        {
            bool flag = true;

            if (VuforiaRuntimeUtilities.IsPlayMode() && (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker)))
            {
                flag = false;
            }
            if (flag && VuforiaWrapper.Instance.TrackerManagerDeinitTracker((int)TypeMapping.GetTypeID(typeof(T))) == 0)
            {
                Debug.LogError("Could not deinitialize the tracker.");
                return(false);
            }
            if (typeof(T) == typeof(ObjectTracker))
            {
                this.mObjectTracker = null;
            }
            else if (typeof(T) == typeof(TextTracker))
            {
                this.mTextTracker = null;
            }
            else if (typeof(T) == typeof(SmartTerrainTracker))
            {
                this.mSmartTerrainTracker = null;
            }
            else
            {
                if (typeof(T) != typeof(DeviceTracker) && typeof(T) != typeof(RotationalDeviceTracker))
                {
                    Debug.LogError("Could not deinitialize tracker. Unknown tracker type.");
                    return(false);
                }
                this.mDeviceTracker = null;
            }
            return(true);
        }
Example #9
0
 public override void Stop()
 {
     VuforiaWrapper.Instance.TrackerStop((int)TypeMapping.GetTypeID(typeof(TextTracker)));
     this.IsActive = false;
     ((WordManagerImpl)TrackerManager.Instance.GetStateManager().GetWordManager()).SetWordBehavioursToNotFound();
 }
Example #10
0
 public override void Stop()
 {
     VuforiaWrapper.Instance.TrackerStop((int)TypeMapping.GetTypeID(typeof(RotationalDeviceTracker)));
     this.IsActive = false;
     VuforiaManager.Instance.WorldCenterMode = VuforiaARController.WorldCenterMode.CAMERA;
 }