示例#1
0
        private void KeyFrameRemove()
        {
            Motion m = _document.Map.Motions[CurrentMotionIndex];
            List<MotionKeyFrames> KeyFrames = m.KeyFrames;
            MotionKeyFrames del = null;
            foreach(MotionKeyFrames k in KeyFrames) if (k.KeyTime == CurrentKeyFrame) del = k;
            if (del != null && KeyFrames.Count > 1) KeyFrames.Remove(del);

            UpdateKeyFrameList(m);
            _document.PerformAction("Transform selection",
                                         new Edit(Solids,
                                         new TransformEditOperation(KeyFrameTransform(), flags)));
        }
示例#2
0
        private bool KeyFrameAdd(bool prompt = true, Coordinate c = null, Quaternion q = null)
        {
            if (prompt) {
                if (c == null) c = new Coordinate(0.000000m, 0.000000m, 0.000000m);
                if (q == null) q = new Quaternion(0.000000m, 0.000000m, 0.000000m, 1.000000m);
            }
            else //if we are not prompting user has clicked animation
            {
                if (c == null) c = new Coordinate((decimal)KeyFrameData.CurrentRow.Cells[1].Value,
                                                  (decimal)KeyFrameData.CurrentRow.Cells[2].Value,
                                                  (decimal)KeyFrameData.CurrentRow.Cells[3].Value);

                if (q == null) q = new Quaternion((decimal)KeyFrameData.CurrentRow.Cells[4].Value,
                                                  (decimal)KeyFrameData.CurrentRow.Cells[5].Value,
                                                  (decimal)KeyFrameData.CurrentRow.Cells[6].Value,
                                                  (decimal)KeyFrameData.CurrentRow.Cells[7].Value);
            }
            


            float time;
            if (prompt) time = PromptKeyTime();
            else time = (float)KeyFrameData.CurrentRow.Cells[0].Value;
            
            if (time < 0) return false;

            Motion m = _document.Map.Motions[CurrentMotionIndex];
            
            List<MotionKeyFrames> KeyFrames = m.KeyFrames;
            foreach (MotionKeyFrames k in KeyFrames) if (time == k.KeyTime) time += 0.01f;
            MotionKeyFrames NewFrame = new MotionKeyFrames(time, m);

            NewFrame.SetTranslation(c);
            NewFrame.SetRotation(q);

            KeyFrames.Add(NewFrame);
            m.KeyFrames = KeyFrames.OrderBy(x => x.KeyTime).ToList();
            
            UpdateKeyFrameList(m,time);
            _document.PerformAction("Transform selection",
                                         new Edit(Solids,
                                         new TransformEditOperation(KeyFrameTransform(), flags)));
            return true;
        }