private void créerToolStripMenuItem2_Click(object sender, EventArgs e) { if (stripBeforeListAnim.SelectedIndex == -1) { Program.AddAnimation(); } else { var baseAnim = Program.DynamicObject.Animations.FirstOrDefault((a) => a.Name == stripBeforeListAnim.SelectedItem.ToString()); var anim = Program.DynamicObject.CreateAnimation(); foreach (var bone in baseAnim.Bones) { var couple = new Couple <Bone, List <Animation.Key> >(); couple.Key = bone.Key; couple.Value = new List <Animation.Key>(); Animation.Key firstKey = bone.Value.FirstOrDefault(); if (firstKey != null) { couple.Value.Add(new Animation.Key() { Position = Time.FromSeconds(1), Transform = new Transformable(firstKey.Transform) }); anim.Bones.Add(couple); } } anim.Name = "Avant " + baseAnim.Name; anim.Duration = Time.FromSeconds(1); Program.selection = anim; } }
private void créerToolStripMenuItem_Click(object sender, EventArgs e) { if (stripCopyListAnim.SelectedIndex == -1) { Program.AddAnimation(); } else { var baseAnim = Program.DynamicObject.Animations.FirstOrDefault((a) => a.Name == stripCopyListAnim.SelectedItem.ToString()); var anim = Program.DynamicObject.CreateAnimation(); foreach (var bone in baseAnim.Bones) { var couple = new Couple <Bone, List <Animation.Key> >(); couple.Key = bone.Key; couple.Value = new List <Animation.Key>(); foreach (var key in bone.Value) { var copyKey = new Animation.Key(); copyKey.Transform = new Transformable(key.Transform); copyKey.Position = key.Position; couple.Value.Add(copyKey); } anim.Bones.Add(couple); } anim.Name = "Copie de " + baseAnim.Name; anim.Duration = baseAnim.Duration; Program.selection = anim; } }
private void créerToolStripMenuItem3_Click(object sender, EventArgs e) { if (stripBetweenAListAnim.SelectedIndex == -1 || stripBetweenBListAnim.SelectedIndex == -1) { Program.AddAnimation(); } else { var baseAnimB = Program.DynamicObject.Animations.FirstOrDefault((a) => a.Name == stripBetweenBListAnim.SelectedItem.ToString()); var baseAnimA = Program.DynamicObject.Animations.FirstOrDefault((a) => a.Name == stripBetweenAListAnim.SelectedItem.ToString()); var anim = Program.DynamicObject.CreateAnimation(); List <Bone> toCompute = new List <Bone>(); foreach (var bone in Program.DynamicObject.BonesHierarchy) { if (baseAnimA.Bones.Find((couple) => couple.Key.ID == bone.ID) != null || baseAnimB.Bones.Find((couple) => couple.Key.ID == bone.ID) != null) { toCompute.Add(bone); } } foreach (var bone in toCompute) { Animation.Key first = new Animation.Key() { Position = Time.FromSeconds(1), Transform = new Transformable() }; Animation.Key last = new Animation.Key() { Position = Time.Zero, Transform = new Transformable() }; Couple <Bone, List <Animation.Key> > coupleAfter = baseAnimA.Bones.Find((c) => c.Key.ID == bone.ID); Couple <Bone, List <Animation.Key> > coupleBefore = baseAnimB.Bones.Find((c) => c.Key.ID == bone.ID); if (coupleAfter != null) { var tmp = new List <Animation.Key>(coupleAfter.Value.ToArray()); tmp.Sort(); first.Transform = new Transformable(tmp.First().Transform); } if (coupleBefore != null) { var tmp = new List <Animation.Key>(coupleBefore.Value.ToArray()); tmp.Sort(); last.Transform = new Transformable(tmp.Last().Transform); } anim.Bones.Add(new Couple <Bone, List <Animation.Key> >() { Key = bone, Value = new List <Animation.Key>() { last, first } }); } anim.Name = "Entre " + baseAnimB.Name + " et " + baseAnimA.Name; anim.Duration = Time.FromSeconds(1); Program.selection = anim; } }