void Start()
    {
        instantTrackable = FindObjectOfType <InstantTrackableBehaviour>();
        if (instantTrackable == null)
        {
            return;
        }

        instantTrackable.OnTrackFail();
        StartCamera();

        TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
        SensorDevice.GetInstance().Start();

        // For see through smart glass setting
        if (ConfigurationScriptableObject.GetInstance().WearableType == WearableCalibration.WearableType.OpticalSeeThrough)
        {
            WearableManager.GetInstance().GetDeviceController().SetStereoMode(true);

            CameraBackgroundBehaviour cameraBackground = FindObjectOfType <CameraBackgroundBehaviour>();
            cameraBackground.gameObject.SetActive(false);

            WearableManager.GetInstance().GetCalibration().CreateWearableEye(Camera.main.transform);

            // BT-300 screen is splited in half size, but R-7 screen is doubled.
            if (WearableManager.GetInstance().GetDeviceController().IsSideBySideType() == true)
            {
                // Do something here. For example resize gui to fit ratio
            }
        }
    }
 void OnDestroy()
 {
     SensorDevice.GetInstance().Stop();
     TrackerManager.GetInstance().StopTracker();
     TrackerManager.GetInstance().DestroyTracker();
     StopCamera();
 }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            return;
        }

        Trackable track = trackingResult.GetTrackable(0);

        instantTrackable.OnTrackSuccess(track.GetId(), track.GetName(), track.GetPose());

                #if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            if (linePointCount < 100)
            {
                linePoint [linePointCount++] = TrackerManager.GetInstance().GetWorldPositionFromScreenCoordinate(Input.mousePosition);
                lineRenderer.positionCount   = linePointCount;
                lineRenderer.SetPositions(linePoint);
            }
        }
                #else
        if (Input.touchCount > 0)
        {
            if (linePointCount < 100)
            {
                linePoint [linePointCount++] = TrackerManager.GetInstance().GetWorldPositionFromScreenCoordinate(Input.GetTouch(0).position);
                lineRenderer.positionCount   = linePointCount;
                lineRenderer.SetPositions(linePoint);
            }
        }

        if (Input.GetTouch(0).phase == TouchPhase.Ended)
        {
            linePointCount = 0;
        }
                #endif
    }
 void StopCamera()
 {
     if (cameraStartDone)
     {
         Debug.Log("Unity StopCamera");
         CameraDevice.GetInstance().Stop();
         cameraStartDone = false;
         SensorDevice.GetInstance().Stop();
     }
 }
Beispiel #5
0
 void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         SensorDevice.GetInstance().Stop();
         TrackerManager.GetInstance().StopTracker();
         startTrackerDone = false;
         StopCamera();
     }
 }
 void StartCamera()
 {
     if (!cameraStartDone)
     {
         Debug.Log("Unity StartCamera");
         ResultCode result = CameraDevice.GetInstance().Start();
         if (result == ResultCode.Success)
         {
             cameraStartDone = true;
             SensorDevice.GetInstance().Start();
             //CameraDevice.GetInstance().SetAutoWhiteBalanceLock(true);   // For ODG-R7 preventing camera flickering
         }
     }
 }
    void Start()
    {
        instantTrackable = FindObjectOfType <InstantTrackableBehaviour>();
        if (instantTrackable == null)
        {
            return;
        }

        instantTrackable.OnTrackFail();
        StartCamera();

        TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
        SensorDevice.GetInstance().Start();
    }
 void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         SensorDevice.GetInstance().Stop();
         TrackerManager.GetInstance().StopTracker();
         StopCamera();
     }
     else
     {
         StartCamera();
         TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
         SensorDevice.GetInstance().Start();
     }
 }
    void Update()
    {
        if (instantTrackable == null)
        {
            return;
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            instantPlaneGrid.EnableDrawing(false);
            return;
        }

        instantPlaneGrid.EnableDrawing(true);

        Trackable trackable = trackingResult.GetTrackable(0);

        planMatrix = trackable.GetPose();
        Matrix4x4 poseMatrix = trackable.GetPose() * Matrix4x4.Translate(touchSumPosition);

        instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);

        if (Input.touchCount > 0 && !rotationController.getRotationState() && !zoomInOut.getScaleState())
        {
            UpdateTouchDelta(Input.GetTouch(0).position);
        }
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        if (instantTrackable == null)
        {
            return;
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            return;
        }

        if (Input.touchCount > 0)
        {
            UpdateTouchDelta(Input.GetTouch(0).position);
        }

        Trackable trackable  = trackingResult.GetTrackable(0);
        Matrix4x4 poseMatrix = trackable.GetPose() * Matrix4x4.Translate(touchSumPosition);

        instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);
    }
Beispiel #11
0
    void Update()
    {
        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        if (trackingResult.GetCount() == 0)
        {
            foreach (var trackable in instantTrackables)
            {
                trackable.OnTrackFail();
            }
            return;
        }

#if UNITY_EDITOR
        if (Input.GetMouseButton(0))
        {
            PointerEventData eventData = new PointerEventData(EventSystem.current);
            eventData.position = Input.mousePosition;
            List <RaycastResult> raycastResults = new List <RaycastResult>();
            EventSystem.current.RaycastAll(eventData, raycastResults);
            if (raycastResults.Count > 0)
            {
                for (int j = 0; j < raycastResults.Count; j++)
                {
                    Button btn = raycastResults [j].gameObject.GetComponent <Button> ();
                    if (btn == null)
                    {
                        return;
                    }
                }
            }

            touchSumPositions[id] = TrackerManager.GetInstance().GetWorldPositionFromScreenCoordinate(Input.mousePosition);
        }
#else
        if (Input.touchCount > 0)
        {
            PointerEventData eventData = new PointerEventData(EventSystem.current);
            eventData.position = Input.GetTouch(0).position;
            List <RaycastResult> raycastResults = new List <RaycastResult>();
            EventSystem.current.RaycastAll(eventData, raycastResults);
            if (raycastResults.Count > 0)
            {
                for (int j = 0; j < raycastResults.Count; j++)
                {
                    Button btn = raycastResults[j].gameObject.GetComponent <Button>();
                    if (btn == null)
                    {
                        return;
                    }
                }
            }

            UpdateTouchPositionDelta(id);
        }
#endif

        for (int i = 0; i < instantTrackables.Count; i++)
        {
            Trackable track      = trackingResult.GetTrackable(0);
            Matrix4x4 poseMatrix = track.GetPose() * Matrix4x4.Translate(touchSumPositions[i]);
            instantTrackables[i].OnTrackSuccess(track.GetId(), track.GetName(), poseMatrix);
        }
    }
Beispiel #12
0
 private void StopCameraInternal()
 {
     StopCamera();
     SensorDevice.GetInstance().Stop();
 }