Beispiel #1
0
        private void HandlePCFPoseRetrieval(MLResult result, MLPCF pcf)
        {
            //save results:
            _localPCFData.Add(pcf);

            //do we have all of them?
            if (_localPCFData.Count == _localPCFs.Count)
            {
                //sort by distance:
                _localPCFData = _localPCFData.OrderBy(p => Vector3.Distance(_mainCamera.position, p.Position)).ToList();

                //grab a chunk of results:
                for (int i = 0; i < Mathf.Min(OutboundCount, _localPCFData.Count); i++)
                {
                    //find offsets:
                    _transformHelper.SetPositionAndRotation(_localPCFData[i].Position, _localPCFData[i].Orientation);
                    Vector3    positionOffset = _transformHelper.InverseTransformPoint(Vector3.zero);
                    Quaternion rotationOffset = Quaternion.Inverse(_transformHelper.rotation) * Quaternion.LookRotation(Vector3.forward);

                    //catalog:
                    _outboundPCFs.Add(new PCFMessage(_localPCFData[i].CFUID.ToString(), new Pose(positionOffset, rotationOffset), _interval));
                    _localPCFReferences.Add(_localPCFData[i].CFUID.ToString(), _localPCFData[i]);
                }

                //send them out:
                StartCoroutine("SendPCFs");
            }
        }
        /// <summary>
        /// Called once for every MLPCF successfully created.
        /// </summary>
        /// <param name="pcf">The PCF</param>
        private void HandleCreate(MLPCF pcf)
        {
            _goodPCFCount++;
            _goodPCFCountText.text = string.Format("PCFs Loaded: {0}", _goodPCFCount);

            AddPCFObject(pcf);
        }
Beispiel #3
0
        /// <summary>
        /// Called once for every MLPCF successfully created.
        /// </summary>
        /// <param name="pcf">The PCF</param>
        private void HandleCreate(MLPCF pcf)
        {
            _pcfCount++;
            _pcfCountText.text = string.Format(PCF_COUNT_TEXT_FORMAT, _pcfCount);

            AddPCFObject(pcf);
        }
Beispiel #4
0
        /// <summary>
        /// Instantiates a GameObject with a MLUTrackedPCF component that tracks the given PCF status. PCF event listeners can be specified in the parameters.
        /// </summary>
        public static MLUTrackedPCF CreateTrackedPCF(MLPCF PCF, Action <MLUTrackedPCF> onUpdate = null, Action <MLUTrackedPCF> onLost = null, Action <MLUTrackedPCF> onRegain = null)
        {
            MLUTrackedPCF trackedPCF = (new GameObject()).AddComponent <MLUTrackedPCF>();

            if (onUpdate != null)
            {
                trackedPCF.OnUpdate += onUpdate;
            }
            if (onLost != null)
            {
                trackedPCF.OnLost += onLost;
            }
            if (onRegain != null)
            {
                trackedPCF.OnRegain += onRegain;
            }
            trackedPCF.PCF = PCF;

            if (trackedPCF.inactiveOnLost && PCF.CurrentResult != MLResultCode.Ok)
            {
                trackedPCF.gameObject.SetActive(false);
            }

            return(trackedPCF);
        }
 /// <summary>
 /// Handler when a PCF Position is found. Called in conjunction with MLPersistentCoordinateFrames.GetPCFPosition(...)
 /// </summary>
 /// <param name="result">Result of the Query</param>
 /// <param name="pcf">PCF</param>
 private void HandlePCFPositionQuery(MLResult result, MLPCF pcf)
 {
     if (result.IsOk)
     {
         MLPersistentCoordinateFrames.QueueForUpdates(pcf);
     }
     --_ongoingQueriesCount;
 }
 /// <summary>
 /// Register Event Handlers for given PCF
 /// </summary>
 /// <param name="pcf">PCF</param>
 void RegisterPCFEventHandlers(MLPCF pcf)
 {
     if (pcf != null)
     {
         pcf.OnLost   += HandleLost;
         pcf.OnRegain += HandleRegain;
         pcf.OnUpdate += HandleUpdate;
     }
 }
 /// <summary>
 /// Unregister Event Handlers for given PCF
 /// </summary>
 /// <param name="pcf">PCF</param>
 void UnregisterPCFEventHandlers(MLPCF pcf)
 {
     if (pcf != null)
     {
         pcf.OnLost   -= HandleLost;
         pcf.OnRegain -= HandleRegain;
         pcf.OnUpdate -= HandleUpdate;
     }
 }
Beispiel #8
0
 /// <summary>
 /// Creates the PCF game object.
 /// </summary>
 /// <param name="pcf">Pcf.</param>
 void AddPCFObject(MLPCF pcf)
 {
     if (!_pcfObjs.Contains(pcf.GameObj))
     {
         GameObject repObj = Instantiate(_representativePrefab, Vector3.zero, Quaternion.identity);
         repObj.name             = pcf.GameObj.name;
         repObj.transform.parent = pcf.GameObj.transform;
         _pcfObjs.Add(pcf.GameObj);
     }
 }
Beispiel #9
0
 /// <summary>
 /// Handler when a PCF Position is found. Called in conjunction with MLPersistentCoordinateFrames.GetPCFPosition(...)
 /// </summary>
 /// <param name="result">Result of the Query</param>
 /// <param name="pcf">PCF</param>
 private void HandlePCFPositionQuery(MLResult result, MLPCF pcf)
 {
     if (result.IsOk)
     {
         // This is only for demonstration purposes because we want to track all the PCFs found.
         // Ideally in a production app, we only wish to track PCFs that have virtual content
         // bound to them - which is already automatically done by MLPersistentBehavior.
         MLPersistentCoordinateFrames.QueueForUpdates(pcf);
     }
     --_ongoingQueriesCount;
 }
        public MLUPCFBinding(MLPCF PCF, Vector3 position, Quaternion rotation, Vector3?scale = null)
        {
            CFUID         = PCF.CFUID;
            this.position = this.rotation = this.scale = default(SerializableUnityData);

            Quaternion inverseOrientation = Quaternion.Inverse(PCF.Orientation);

            this.Position = inverseOrientation * (position - PCF.Position);
            this.Rotation = inverseOrientation * rotation;
            this.Scale    = scale ?? Vector3.one;
        }
        public static MLUTrackedPCF GetTrackedPCF(MLPCF PCF)
        {
            for (int i = 0; i < PCFs.Count; i++)
            {
                if (PCF.CFUID.Equals(PCFs[i].CFUID))
                {
                    return(trackedPCFs[i]);
                }
            }

            return(null);
        }
Beispiel #12
0
    private void AddPCFObject(MLPCF pcf)
    {
        GameObject repObj = Instantiate(_PCFVizPrefab, Vector3.zero, Quaternion.identity);

        repObj.name = pcf.CFUID.ToString();
        repObj.transform.position = pcf.Position;
        repObj.transform.rotation = pcf.Orientation;
        PCFStatusText statusTextBehavior = repObj.GetComponent <PCFStatusText>();

        if (statusTextBehavior != null)
        {
            statusTextBehavior.PCF = pcf;
        }
        repObj.SetActive(IsDebugMode);
        _pcfObjs.Add(repObj);
    }
        /// <summary>
        /// Creates the PCF game object.
        /// </summary>
        /// <param name="pcf">Pcf.</param>
        void AddPCFObject(MLPCF pcf)
        {
            GameObject repObj = Instantiate(_prefab, Vector3.zero, Quaternion.identity);

            repObj.name = pcf.GameObj.name;
            repObj.transform.SetParent(pcf.GameObj.transform, false);

            PCFStatusText statusTextBehavior = repObj.GetComponent <PCFStatusText>();

            if (statusTextBehavior != null)
            {
                statusTextBehavior.PCF = pcf;
            }

            repObj.SetActive(IsDebugMode);
            _pcfObjs.Add(repObj);
        }
Beispiel #14
0
    public void SyncClosestPCF(CFUID id)
    {
        _closestPCFCFUID = id;
        Debug.Log("Trying to sync " + _closestPCFCFUID + " " + _closestPCFCFUID.ToGuid());

        if (_closestPCFCFUID == null)
        {
            Debug.Log("Closest PCFID is null");
        }
        if (_closestPCFGameObject != null)
        {
            return;
        }

        Debug.Log("List Size " + PCFList.Count);
        _closestPCF = PCFList.Find(x => x.CFUID == _closestPCFCFUID);
        MLPersistentCoordinateFrames.GetPCFPose(_closestPCF, HandleClosestPCFQuery);
    }
Beispiel #15
0
    private void HandleClosestPCFQuery(MLResult result, MLPCF pcf)
    {
        if (result.IsOk)
        {
            MLPersistentCoordinateFrames.QueueForUpdates(pcf);
            _closestPCF           = pcf;
            _closestPCFGameObject = new GameObject();
            _closestPCFGameObject.transform.position = _closestPCF.Position;
            _closestPCFGameObject.transform.rotation = _closestPCF.Orientation;
            Debug.Log("Found closest PCF " + _closestPCF.Position + " " + _closestPCF.CFUID);
            NetworkUI.GetComponent <NetworkUISync>().closestPCFGameobject = _closestPCFGameObject;

            if (PhotonNetwork.IsMasterClient)
            {
                pv.RPC("SyncClosestPCF", RpcTarget.OthersBuffered, _closestPCF.CFUID);
            }
        }
    }
        private static void OnPCFFoundHandler(MLPCF PCF)
        {
            if (PCFs.Contains(PCF))
            {
                return;
            }

            MLPersistentCoordinateFrames.QueueForUpdates(PCF);             // this doesn't work as spected for now
            MLUTrackedPCF trackedPCF = MLUTrackedPCF.CreateTrackedPCF(PCF);

            trackedPCF.InactiveOnLost = disableTrackedPCFsOnLost;
            PCFs.Add(PCF);
            trackedPCFs.Add(trackedPCF);
            if (OnTrackedPCFCreate != null)
            {
                OnTrackedPCFCreate(trackedPCF);
            }

            Debug.Log("MLULandscape: started tracking PCF [CFUID: " + PCF.CFUID + " | result: " + PCF.CurrentResult + "]");
        }
Beispiel #17
0
 private void OnFoundNearestPCF(MLResult arg1, MLPCF pcf)
 {
     Debug.Log("ML : Calling SpawnPCFVisual with PCF CFUID " + pcf.CFUID);
     pv.RPC("SpawnPCFVisual", RpcTarget.All, pcf.CFUID);
 }
Beispiel #18
0
 private void OnNewPCFCreated(MLPCF pcf)
 {
     Debug.Log("CFUID " + pcf.CFUID + "CFUID.ToString()" + pcf.CFUID.ToString());
     AddPCFObject(pcf);
 }
Beispiel #19
0
 private void AssignClosestPCF(MLResult result, MLPCF pcf)
 {
     MLPersistentCoordinateFrames.GetPCFPose(pcf, HandleClosestPCFQuery);
 }
Beispiel #20
0
 private void HandlePCFPositionQuery(MLResult result, MLPCF pcf)
 {
     --_ongoingQueriesCount;
 }