Ejemplo n.º 1
0
        public static TransmissionRoot Add(string ip)
        {
            TransmissionRoot transmissionRoot = Get(ip);

            if (transmissionRoot != null)
            {
                return(transmissionRoot);
            }
            else
            {
                GameObject rootGameObject = new GameObject($"(Root - {ip})");
                transmissionRoot       = rootGameObject.AddComponent <TransmissionRoot>();
                transmissionRoot.owner = ip;
                transmissionRoot.Initialize();
                return(transmissionRoot);
            }
        }
Ejemplo n.º 2
0
        private void HandlePCFReceived(string from, string CFUID, Pose offset, int interval)
        {
            //find a matching local PCF:
            if (_localPCFReferences.ContainsKey(CFUID))
            {
                if (!alignedPeers.Contains(from))
                {
                    //save and report alignment:
                    alignedPeers.Add(from);
                    events.OnPeerAligned.Invoke(from);
                }

                //get peer root offset from this PCF:
                _transformHelper.SetPositionAndRotation(_localPCFReferences[CFUID].Position, _localPCFReferences[CFUID].Orientation);
                Vector3    position = _transformHelper.TransformPoint(offset.position);
                Quaternion rotation = _transformHelper.rotation * offset.rotation;

                //first pcf message from this peer?
                if (!_alignmentHistory.ContainsKey(from))
                {
                    //establish alignment history:
                    _alignmentHistory.Add(from, new SpatialAlignmentHistory(interval));

                    //snap peer root to initial:
                    TransmissionRoot.Get(from).SetPositionAndRotationTargets(position, rotation);
                }

                //same interval:
                if (_alignmentHistory[from].interval == interval)
                {
                    _alignmentHistory[from].positions.Add(position);
                    _alignmentHistory[from].rotations.Add(rotation);
                }
                else
                {
                    //new interval:
                    _alignmentHistory[from].interval = interval;
                    TransmissionRoot.Get(from).SetPositionAndRotationTargets(_alignmentHistory[from].AveragePosition, _alignmentHistory[from].AverageRotation);

                    //get ready for next interval's queue:
                    _alignmentHistory[from].Clear();
                    _alignmentHistory[from].positions.Add(position);
                    _alignmentHistory[from].rotations.Add(rotation);
                }
            }
        }