public void BufferNewValue(Pose newPose, float delta) { Vector3 newPosition = newPose.position; Vector3 newVelocity = Vector3.zero; if (delta > Mathf.Epsilon && _previousPosition.HasValue) { newVelocity = (newPosition - _previousPosition.Value) / delta; } int nextWritePos = (_lastWritePos < 0) ? 0 : (_lastWritePos + 1) % _bufferLength; if (Velocities.Count <= nextWritePos) { Velocities.Add(newVelocity); } else { Velocities[nextWritePos] = newVelocity; } _previousPosition = newPosition; _lastWritePos = nextWritePos; }
/// <summary> /// Converts the form settings to the actual pitches and velocities /// </summary> /// <param name="bcfs"></param> public BasicChordMidiSettings(BasicChordFormSettings bcfs) { Durations = new List <int>(bcfs.Durations); ChordOffs = new List <bool>(bcfs.ChordOffs); for (int chordIndex = 0; chordIndex < bcfs.Durations.Count; ++chordIndex) { List <byte> midiPitches = new List <byte>(); List <byte> midiVelocities = new List <byte>(); float verticalVelocityFactor = 1.0F; if (bcfs.VerticalVelocityFactors.Count > chordIndex) { verticalVelocityFactor = bcfs.VerticalVelocityFactors[chordIndex]; } if (bcfs.ChordDensities[chordIndex] > 0) { if (bcfs.ChordDensities[chordIndex] == 1) { midiPitches.Add(bcfs.MidiPitches[chordIndex]); midiVelocities.Add(bcfs.Velocities[chordIndex]); } else { midiPitches = GetMidiPitches(chordIndex, bcfs.MidiPitches, bcfs.ChordDensities, bcfs.Inversions, bcfs.InversionIndices); midiVelocities = GetVerticalVelocities(bcfs.Velocities[chordIndex], bcfs.ChordDensities[chordIndex], verticalVelocityFactor); } } MidiPitches.Add(midiPitches); Velocities.Add(midiVelocities); } }
public void Update(Vector2 position, Vector2 velocity) { Positions.Add(position); ActualPosition = position; Velocities.Add(velocity); ActualVelocity = velocity; }
public void Add(Body body) { body.IslandIndex = Bodies.Count; Bodies.Add(body); Velocities.Add(new VelocityState()); }