private void RefreshTableCompositeBoneTransforms()
        {
            tableBoneTransforms.TableModel.Rows.Clear();
            CompositeKeyFrame selectedKeyFrame = SelectedCompositeKeyFrame;

            foreach (CompositeBoneTransform boneTransform in selectedKeyFrame.BoneTransforms)
            {
                Cell[] cells = new Cell[2];
                cells[0] = new Cell(boneTransform.BoneReference);
                cells[1] = new Cell("", boneTransform.IsVisible, null);
                Row newRow = new Row(cells);
                tableBoneTransforms.TableModel.Rows.Add(newRow);
            }
            if (selectedKeyFrame.BoneTransforms.Count > 0)
            {
                if (String.IsNullOrEmpty(_lastSelectedBone))
                {
                    tableBoneTransforms.TableModel.Selections.Clear();
                }
                else
                {
                    for (int i = 0; i < selectedKeyFrame.BoneTransforms.Count; i++)
                    {
                        if (selectedKeyFrame.BoneTransforms[i].BoneReference
                            == _lastSelectedBone)
                        {
                            tableBoneTransforms.TableModel.Selections.Clear();
                            tableBoneTransforms.TableModel.Selections.AddCell(i, 1);
                        }
                    }
                }
            }
            tableBoneTransforms.Invalidate();
        }
        private void toolStripButtonKeyFrameCopy_Click(object sender, EventArgs e)
        {
            CompositeAnimation anim = SelectedCompositeAnimation;

            CompositeKeyFrameClipBoard = new CompositeKeyFrame();
            SelectedCompositeKeyFrame.CopyValuesTo(CompositeKeyFrameClipBoard, anim);
            toolStripButtonKeyFramePaste.Enabled = true;
        }
 private void tableBoneTransforms_CellPropertyChanged(object sender, XPTable.Events.CellEventArgs e)
 {
     if (e.EventType == XPTable.Events.CellEventType.CheckStateChanged)
     {
         int index = e.CellPos.Row;
         CompositeKeyFrame      selectedFrame = SelectedCompositeKeyFrame;
         CompositeBoneTransform boneTransform = selectedFrame.BoneTransforms[index];
         boneTransform.IsVisible = (bool)e.Cell.Checked;
     }
 }
Example #4
0
 public void DrawKeyFrame(CompositeKeyFrame keyFrame)
 {
     if (keyFrame != null)
     {
         CompositeAnimation anim = keyFrame.Parent;
         anim.ResetToKeyFrame(ParentEditor.tableKeyFrames.SelectedIndicies[0]);
         CompositeEntity.Update(1 / 60f);
         CompositeEntity.Draw(1 / 60f);
     }
 }
        private void toolStripButtonLevelDownBoneTransform_Click(object sender, EventArgs e)
        {
            CompositeAnimation     anim          = SelectedCompositeAnimation;
            CompositeKeyFrame      selectedFrame = SelectedCompositeKeyFrame;
            CompositeBoneTransform boneTransform = SelectedCompositeBoneTransform;
            int index = tableBoneTransforms.SelectedIndicies[0];

            if (index < selectedFrame.BoneTransforms.Count - 1)
            {
                selectedFrame.BoneTransforms.RemoveAt(index);
                selectedFrame.BoneTransforms.Insert(index + 1, boneTransform);
                _lastSelectedBone = boneTransform.BoneReference;
                RefreshTableCompositeBoneTransforms();
            }
        }
        private void toolStripButtonKeyFramePaste_Click(object sender, EventArgs e)
        {
            CompositeAnimation anim = SelectedCompositeAnimation;
            int insertIndex         = -1;

            int[] selectedIndicies = tableKeyFrames.SelectedIndicies;
            if (anim.KeyFrames.Count > 0 && selectedIndicies.Length > 0)
            {
                insertIndex = selectedIndicies[0];
            }
            CompositeKeyFrame newInstance = new CompositeKeyFrame();

            CompositeKeyFrameClipBoard.CopyValuesTo(newInstance, anim);
            anim.KeyFrames.Insert(insertIndex + 1, newInstance);
            RefreshListKeyFrames();
        }
        private void toolStripButtonAddKeyFrame_Click(object sender, EventArgs e)
        {
            CompositeAnimation anim     = SelectedCompositeAnimation;
            CompositeKeyFrame  newFrame = new CompositeKeyFrame(anim);

            if (SelectedCompositeKeyFrame != null)
            {
                SelectedCompositeKeyFrame.CopyValuesTo(newFrame, SelectedCompositeKeyFrame.Parent);
            }
            else
            {
                newFrame.GenerateDefaultBoneTransformsList();
            }
            anim.KeyFrames.Add(newFrame);
            RefreshListKeyFrames();
        }
 private void tableKeyFrames_CellPropertyChanged(object sender, XPTable.Events.CellEventArgs e)
 {
     // Duration
     if (e.Cell.Data != null)
     {
         Console.WriteLine("KF duration modified from " + e.OldValue + " to " + e.Cell.Data);
         CompositeKeyFrame selectedKeyFrame = SelectedCompositeKeyFrame;
         selectedKeyFrame.Duration = Int32.Parse(e.Cell.Data.ToString());
         SelectedCompositeAnimation.Reset();
         this.UpdatePreview = true;
     }
     else
     {
         Console.WriteLine("KF name modified from " + e.OldValue + " to " + e.Cell.Text);
         SelectedCompositeKeyFrame.Name = e.Cell.Text;
     }
 }
 private void treeViewBones_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (e.Node != null)
     {
         String oldName = e.Node.Text;
         String newName = e.Label;
         Console.WriteLine("Renamed node " + oldName + " to " + newName);
         if (String.IsNullOrEmpty(newName) == false &&
             IsBoneNodeNameUnique(CompositeEntity.RootBone, newName))
         {
             CompositeBone bone = e.Node.Tag as CompositeBone;
             bone.Name = newName;
             CleanBoneInSceneControl(oldName);
             // sync bone transforms with the new Bone name
             for (int i = 0; i < CompositeEntity.Animations.Count; i++)
             {
                 // loop through every keyframe to sync them
                 for (int j = 0; j < CompositeEntity.Animations[i].KeyFrames.Count; j++)
                 {
                     CompositeKeyFrame keyframe = CompositeEntity.Animations[i].KeyFrames[j];
                     // loop to find the previous bone
                     for (int k = 0; k < keyframe.BoneTransforms.Count; k++)
                     {
                         CompositeBoneTransform transform = keyframe.BoneTransforms[k];
                         if (transform.BoneReference == oldName)
                         {
                             transform.BoneReference = bone.Name;
                             break;
                         }
                     }
                 }
             }
         }
         else
         {
             e.CancelEdit = true;
         }
     }
 }