public void PurgeOld() { // Remove any old spikes. for (int i = m_spikes.Count - 1; i >= 0; i--) { Spike oldSpike = (Spike)m_spikes[i]; if (Time.time - oldSpike.m_endTime > m_gestures.MaxGestureAge) { // All remaining spikes are old, so remove them. (NOTE: they are at the beginning.) m_spikes.RemoveRange(0, i + 1); break; } } }
public void Awake() { m_running = false; m_hasAccel = false; m_hasGyro = false; m_rotationBase = Quaternion.Euler(90, 0, 0); m_calibrate = Vector3.zero; m_gravity = Vector3.zero; m_attitudeXZ = Quaternion.identity; m_attitudeXYZ = Quaternion.identity; m_current = Vector3.zero; m_user = Vector3.zero; m_cur = new Spike(); m_spikes = new Spikes(this); m_hasGestureCandidate = false; m_lastGestureTime = 0; m_recording = new Recording(); }
public bool FindMatch(Spike newSpike, out Spike match) { // Start at the penultimate item since the last item is newSpike itself. for (int i = m_spikes.Count - 2; i >= 0; i--) { Spike oldSpike = (Spike)m_spikes[i]; float dot = Vector3.Dot(oldSpike.m_dir.normalized, newSpike.m_dir.normalized); // If this old spike points mostly the opposite direction, and the two spikes combined // exceed the minimum gesture magnitude, it's a match. if ((dot < -m_gestures.m_maxGestureAngleDot) && (newSpike.m_dir - oldSpike.m_dir).magnitude > m_gestures.MinGestureMagnitude) { match = oldSpike; return(true); } } match = new Spike(); return(false); }
public void Add(Spike spike) { // Add the spike to the end. m_spikes.Add(spike); }