Beispiel #1
0
 public void CopyFrom(TouchCluster other)
 {
     Clear();
     foreach (var entry in other.Touches)
     {
         Touches.Add(entry.Key, entry.Value);
     }
     ActiveTouchId = other.ActiveTouchId;
     Centroid      = other.Centroid;
     ClusterId     = other.ClusterId;
 }
Beispiel #2
0
        public bool GetTouchCluster(TouchCluster cluster)
        {
            cluster.Clear();

            if (Root == null)
            {
                return(false);
            }

            CollectTouchesInTree(Root, cluster);
            cluster.SetActiveTouch(_touchPoints[ActiveTouchIndex]);
            cluster.ClusterId = ClusterId;
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// This method updates the positions of the TouchPts in this TouchCluster
        /// to account for translation of the entire cluster by comparing the centroid positions.
        /// This makes analysis of the relative touch positions (rotation, pinch) easier by removing
        /// the common translation. It also helps identify a pinch or rotation where a single touch
        /// is moving, or where the touches are moving by different amounts.
        /// </summary>
        /// <param name="newPosition"></param>
        /// <returns></returns>
        public bool NormalizeForCentroidDelta(TouchCluster newPosition)
        {
            // Update positions of touches by the amount necessary to align the Centroid to the new Centroid position
            Vector2 delta = newPosition.Centroid - Centroid;

            if (delta == Vector2.zero)
            {
                return(false);
            }

            foreach (int key in Touches.Keys.ToList())
            {
                var touch = Touches[key];
                touch.position += delta;
                Touches[key]    = touch;
            }
            return(true);
        }