Esempio n. 1
0
        public void AverageKeys(string baseName, string morphName)
        {
            SHP0EntryNode w = FindChild(baseName, false) as SHP0EntryNode;

            if (w == null)
            {
                return;
            }

            SHP0VertexSetNode t = w.FindChild(morphName, false) as SHP0VertexSetNode;

            if (t == null)
            {
                return;
            }

            if (t.Keyframes._keyCount > 1)
            {
                KeyframeEntry root = t.Keyframes._keyRoot;
                if (root._next != root && root._prev != root && root._prev != root._next)
                {
                    float tan = (root._next._tangent + root._prev._tangent) / 2.0f;
                    float val = (root._next._value + root._prev._value) / 2.0f;

                    root._next._tangent = tan;
                    root._prev._tangent = tan;

                    root._next._value = val;
                    root._prev._value = val;
                }
            }

            SignalPropertyChange();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an animation to the end of this one
        /// </summary>
        public void Append(SHP0Node external)
        {
            KeyframeEntry kfe;

            int origIntCount = FrameCount;

            FrameCount += external.FrameCount;

            foreach (SHP0EntryNode w in external.Children)
            {
                foreach (SHP0VertexSetNode extEntry in w.Children)
                {
                    SHP0VertexSetNode intEntry = null;
                    if ((intEntry = (SHP0VertexSetNode)FindChild(w.Name + "/" + extEntry.Name, false)) == null)
                    {
                        SHP0EntryNode wi = null;
                        if ((wi = (SHP0EntryNode)FindChild(w.Name, false)) == null)
                        {
                            AddChild(wi = new SHP0EntryNode()
                            {
                                Name = FindName(null), _flags = w._flags
                            });
                        }

                        SHP0VertexSetNode newIntEntry = new SHP0VertexSetNode(extEntry.Name);
                        newIntEntry.SetSize(extEntry.FrameCount + origIntCount, Loop);
                        for (int x = 0; x < extEntry.FrameCount; x++)
                        {
                            if ((kfe = extEntry.GetKeyframe(x)) != null)
                            {
                                newIntEntry.Keyframes.SetFrameValue(x + origIntCount, kfe._value)._tangent = kfe._tangent;
                            }
                        }
                        wi.AddChild(newIntEntry);
                    }
                    else
                    {
                        for (int x = 0; x < extEntry.FrameCount; x++)
                        {
                            if ((kfe = extEntry.GetKeyframe(x)) != null)
                            {
                                intEntry.Keyframes.SetFrameValue(x + origIntCount, kfe._value)._tangent = kfe._tangent;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public unsafe SHP0EntryNode FindOrCreateEntry(string name)
        {
            foreach (SHP0EntryNode t in Children)
            {
                if (t.Name == name)
                {
                    return(t);
                }
            }

            SHP0EntryNode entry = new SHP0EntryNode();

            entry.Name   = name;
            entry._flags = 3;
            AddChild(entry);
            entry.AddChild(new SHP0VertexSetNode(FindName("NewMorphTarget")));
            return(entry);
        }
        public unsafe SHP0EntryNode FindOrCreateEntry(string name)
        {
            foreach (SHP0EntryNode t in Children)
                if (t.Name == name)
                    return t;

            SHP0EntryNode entry = new SHP0EntryNode();
            entry.Name = name;
            entry._flags = 3;
            AddChild(entry);
            entry.AddChild(new SHP0VertexSetNode(FindName("NewMorphTarget")));
            return entry;
        }
        /// <summary>
        /// Adds an animation to the end of this one
        /// </summary>
        public void Append(SHP0Node external)
        {
            KeyframeEntry kfe;

            int origIntCount = FrameCount;
            FrameCount += external.FrameCount;

            foreach (SHP0EntryNode w in external.Children)
                foreach (SHP0VertexSetNode _extEntry in w.Children)
                {
                    SHP0VertexSetNode _intEntry = null;
                    if ((_intEntry = (SHP0VertexSetNode)FindChild(w.Name + "/" + _extEntry.Name, false)) == null)
                    {
                        SHP0EntryNode wi = null;
                        if ((wi = (SHP0EntryNode)FindChild(w.Name, false)) == null)
                            AddChild(wi = new SHP0EntryNode() { Name = FindName(null), _flags = w._flags });

                        SHP0VertexSetNode newIntEntry = new SHP0VertexSetNode(_extEntry.Name);
                        newIntEntry._numFrames = _extEntry.FrameCount + origIntCount;
                        for (int x = 0; x < _extEntry.FrameCount; x++)
                                if ((kfe = _extEntry.GetKeyframe(x)) != null)
                                    newIntEntry.Keyframes.SetFrameValue(x + origIntCount, kfe._value)._tangent = kfe._tangent;
                        wi.AddChild(newIntEntry);
                    }
                    else
                        for (int x = 0; x < _extEntry.FrameCount; x++)
                            if ((kfe = _extEntry.GetKeyframe(x)) != null)
                                _intEntry.Keyframes.SetFrameValue(x + origIntCount, kfe._value)._tangent = kfe._tangent;
                }
        }