Пример #1
0
        public bool TryGetValue(IOTrackType Type, float Frame, out float Value)
        {
            if (!Tracks.ContainsKey(Type))
            {
                Value = 0;
                return(false);
            }
            else
            {
                List <IOAnimKey> Keys = Tracks[Type];
                if (Keys.Count == 0)
                {
                    Value = 0;
                    return(false);
                }
                for (int i = 0; i < Keys.Count - 1; i++)
                {
                    // at frame
                    if (Frame == Keys[i].Frame)
                    {
                        Value = Keys[i].Value;
                        return(true);
                    }

                    // need interpolation
                    if (Frame > Keys[i].Frame && Frame < Keys[i + 1].Frame)
                    {
                        // TODO: implement interpolation
                    }
                }
                // last key
                Value = Keys[Keys.Count - 1].Value;
                return(true);
            }
        }
Пример #2
0
 public List <IOAnimKey> GetKeysForTrack(IOTrackType type)
 {
     if (Tracks.ContainsKey(type))
     {
         return(Tracks[type]);
     }
     else
     {
         return(new List <IOAnimKey>());
     }
 }
Пример #3
0
        public void AddKey(string BoneName, IOTrackType TrackType, float Frame, float Value, IOInterpolationType InterpolationType = IOInterpolationType.Linear, float In = 0, float Out = 0)
        {
            IOAnimNode Node = null;

            if (!TryGetNodeByName(BoneName, out Node))
            {
                Node = new IOAnimNode(BoneName);
                Nodes.Add(Node);
            }

            Node.AddKey(TrackType, new IOAnimKey()
            {
                Frame             = Frame,
                Value             = Value,
                InterpolationType = InterpolationType,
                In  = In,
                Out = Out
            });
        }
Пример #4
0
        public void AddKey(IOTrackType TrackType, IOAnimKey Key)
        {
            if (!Tracks.ContainsKey(TrackType))
            {
                Tracks.Add(TrackType, new List <IOAnimKey>());
            }

            List <IOAnimKey> Keys = Tracks[TrackType];

            for (int i = 0; i < Keys.Count - 1; i++)
            {
                if (Keys[i].Frame <= Key.Frame && Keys[i + 1].Frame >= Key.Frame)
                {
                    // insert here
                    Keys.Insert(i + 1, Key);
                    return;
                }
            }
            Keys.Add(Key);
        }
Пример #5
0
        private static void AddAnimData(AnimBone animBone, IOAnimNode node, IOTrackType type, ControlType ctype, TrackType ttype)
        {
            AnimData d = new AnimData();

            d.controlType = ctype;
            d.type        = ttype;
            foreach (IOAnimKey key in node.GetKeysForTrack(type))
            {
                AnimKey animKey = new AnimKey()
                {
                    input  = key.Frame + 1,
                    output = key.Value,
                };
                d.keys.Add(animKey);
            }

            if (d.keys.Count > 0)
            {
                animBone.atts.Add(d);
            }
        }