Пример #1
0
        public void CreateEntry()
        {
            bool indirect = false;
            int  value    = 0;

            foreach (SRT0TextureNode t in Children)
            {
                if (t._textureIndex == value && !t._indirect)
                {
                    value++;
                }
            }
            if (value == 8)
            {
                indirect = true;
                value    = 0;
                foreach (SRT0TextureNode t in Children)
                {
                    if (t._textureIndex == value && t._indirect)
                    {
                        value++;
                    }
                }
                if (value == 3)
                {
                    return;
                }
            }
            SRT0TextureNode node = new SRT0TextureNode(value, indirect);

            AddChild(node);
        }
Пример #2
0
        public unsafe SRT0TextureNode FindOrCreateEntry(string name, int index, bool ind)
        {
            foreach (SRT0EntryNode t in Children)
            {
                if (t.Name == name)
                {
                    int value = 0;
                    foreach (SRT0TextureNode x in t.Children)
                    {
                        if (x._textureIndex == value && x._indirect == ind)
                        {
                            return(x);
                        }
                    }

                    SRT0TextureNode child = new SRT0TextureNode(index, ind);
                    t.AddChild(child);
                    return(child);
                }
            }
            SRT0EntryNode entry = new SRT0EntryNode();

            entry.Name = name;
            AddChild(entry);
            SRT0TextureNode tex = new SRT0TextureNode(index, ind);

            entry.AddChild(tex);
            return(tex);
        }
Пример #3
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            SRT0Entry *header = (SRT0Entry *)address;

            header->_textureIndices  = (int)_texIndices;
            header->_indirectIndices = (int)_indIndices;

            int     offset       = 12 + Children.Count * 4;
            VoidPtr entryAddress = address + offset;

            int prevOffset = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                SRT0TextureNode n = (SRT0TextureNode)Children[i];

                n._dataAddr = _dataAddr;

                header->SetOffset(i, offset + prevOffset);
                n.Rebuild(entryAddress, n._entryLen, true);

                entryAddress += n._entryLen;
                prevOffset   += n._entryLen;
                _dataAddr    += n._dataLen;
            }
        }
Пример #4
0
        protected internal override void OnRebuild(VoidPtr address, int length, bool force)
        {
            SRT0Entry *header = (SRT0Entry *)address;

            header->_textureIndices = (int)_texIndices;
            header->_unk1           = _unk1;

            VoidPtr entryAddress = address + 12 + (Children.Count) * 4;

            int prevOffset = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                SRT0TextureNode n = (SRT0TextureNode)Children[i];

                n._dataAddr = _dataAddr;

                header->SetOffset(i, 12 + (Children.Count) * 4 + prevOffset);
                n.Rebuild(entryAddress, n._entryLen, true);

                entryAddress += n._entryLen;
                prevOffset   += n._entryLen;
                _dataAddr    += n._dataLen;
            }
        }
Пример #5
0
        internal unsafe SRT0TextureNode FindOrCreateEntry(string name, int index)
        {
            foreach (SRT0EntryNode t in Children)
            {
                if (t.Name == name)
                {
                    foreach (SRT0TextureNode n in t.Children)
                    {
                        if (n.TextureIndex == index)
                        {
                            return(n);
                        }
                    }
                    SRT0TextureNode child = new SRT0TextureNode(index)
                    {
                        _numFrames = _numFrames
                    };
                    t.AddChild(child);
                    return(child);
                }
            }
            SRT0EntryNode entry = new SRT0EntryNode();

            entry.Name = name;
            AddChild(entry);
            SRT0TextureNode tex = new SRT0TextureNode(index)
            {
                _numFrames = _numFrames
            };

            entry.AddChild(tex);
            return(tex);
        }
Пример #6
0
        /// <summary>
        /// Adds an animation to the end of this one
        /// </summary>
        public void Append(SRT0Node external)
        {
            KeyframeEntry kfe;

            int origIntCount = FrameCount;

            FrameCount += external.FrameCount;

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

                        SRT0TextureNode newIntEntry = new SRT0TextureNode(extEntry.Index, extEntry.Indirect)
                        {
                            Name = extEntry.Name
                        };
                        newIntEntry.SetSize(extEntry.FrameCount + origIntCount, Loop);

                        for (int x = 0; x < extEntry.FrameCount; x++)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if ((kfe = extEntry.GetKeyframe(i, x)) != null)
                                {
                                    newIntEntry.Keyframes.SetFrameValue(i, x + origIntCount, kfe._value)._tangent = kfe._tangent;
                                }
                            }
                        }
                        wi.AddChild(newIntEntry);
                    }
                    else
                    {
                        for (int x = 0; x < extEntry.FrameCount; x++)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if ((kfe = extEntry.GetKeyframe(i, x)) != null)
                                {
                                    intEntry.Keyframes.SetFrameValue(i, x + origIntCount, kfe._value)._tangent = kfe._tangent;
                                }
                            }
                        }
                    }
                }
            }
        }
 internal void ApplySRT0Texture(SRT0TextureNode node, int index)
 {
     if ((node == null) || (index == 0)) //Reset to identity
     {
         _frameState = new FrameState()
         {
             _scale = new Vector3(1)
         }
     }
     ;
     else
     {
         _frameState = new FrameState(node.GetAnimFrame(index - 1));
     }
 }
Пример #8
0
        internal void ApplySRT0Texture(SRT0TextureNode node, float index = 0, TexMatrixMode matrixMode = TexMatrixMode.MatrixMaya)
        {
            _frameState = _bindState;

            if (node != null && index >= 1)
            {
                fixed(TextureFrameState *v = &_frameState)
                {
                    float *f = (float *)v;

                    for (int i = 0; i < 5; i++)
                    {
                        if (node.Keyframes[i]._keyCount > 0)
                        {
                            f[i] = node.GetFrameValue(i, index - 1);
                        }
                    }
                    _frameState.MatrixMode = matrixMode;
                    _frameState.CalcTransforms();
                }
            }
        }
Пример #9
0
        public void CreateEntry()
        {
            int value = 0;

            foreach (SRT0TextureNode t in Children)
            {
                if (t._textureIndex == value)
                {
                    value++;
                }
            }
            if (value == 8)
            {
                return;
            }
            SRT0TextureNode node = new SRT0TextureNode(value)
            {
                _numFrames = ((SRT0Node)Parent).FrameCount
            };

            AddChild(node);
        }
Пример #10
0
        public void AverageKeys(string matName, int index)
        {
            SRT0EntryNode w = FindChild(matName, false) as SRT0EntryNode;

            if (w == null)
            {
                return;
            }

            if (index < 0 || index >= w.Children.Count)
            {
                return;
            }

            SRT0TextureNode t = w.Children[index] as SRT0TextureNode;

            for (int i = 0; i < 5; i++)
            {
                if (t.Keyframes._keyArrays[i]._keyCount > 1)
                {
                    KeyframeEntry root = t.Keyframes._keyArrays[i]._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();
        }
 internal void ApplySRT0Texture(SRT0TextureNode node, int index, bool linear)
 {
     if ((node == null) || (index == 0)) //Reset to identity
         _frameState = new FrameState() { _scale = new Vector3(1) };
     else
         _frameState = new FrameState(node.GetAnimFrame(index - 1, linear));
 }
Пример #12
0
 public void CreateEntry()
 {
     bool indirect = false;
     int value = 0;
     foreach (SRT0TextureNode t in Children)
         if (t._textureIndex == value && !t._indirect)
             value++;
     if (value == 8)
     {
         indirect = true;
         value = 0;
         foreach (SRT0TextureNode t in Children)
             if (t._textureIndex == value && t._indirect)
                 value++;
         if (value == 3)
             return;
     }
     SRT0TextureNode node = new SRT0TextureNode(value, indirect) { _numFrames = ((SRT0Node)Parent).FrameCount };
     AddChild(node);
 }
Пример #13
0
        public unsafe SRT0TextureNode FindOrCreateEntry(string name, int index, bool ind)
        {
            foreach (SRT0EntryNode t in Children)
                if (t.Name == name)
                {
                    int value = 0;
                    foreach (SRT0TextureNode x in t.Children)
                        if (x._textureIndex == value && x._indirect == ind)
                            return x;

                    SRT0TextureNode child = new SRT0TextureNode(index, ind) { _numFrames = _numFrames };
                    t.AddChild(child);
                    return child;
                }
            SRT0EntryNode entry = new SRT0EntryNode();
            entry.Name = name;
            AddChild(entry);
            SRT0TextureNode tex = new SRT0TextureNode(index, ind) { _numFrames = _numFrames };
            entry.AddChild(tex);
            return tex;
        }
Пример #14
0
        /// <summary>
        /// Adds an animation to the end of this one
        /// </summary>
        public void Append(SRT0Node external)
        {
            KeyframeEntry kfe;

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

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

                        SRT0TextureNode newIntEntry = new SRT0TextureNode(_extEntry.Index, _extEntry.Indirect) { Name = _extEntry.Name };
                        newIntEntry._numFrames = _extEntry.FrameCount + origIntCount;
                        for (int x = 0; x < _extEntry.FrameCount; x++)
                            for (int i = 0x10; i < 0x19; i++)
                                if ((kfe = _extEntry.GetKeyframe((KeyFrameMode)i, x)) != null)
                                    newIntEntry.Keyframes.SetFrameValue((KeyFrameMode)i, x + origIntCount, kfe._value)._tangent = kfe._tangent;
                        wi.AddChild(newIntEntry);
                    }
                    else
                        for (int x = 0; x < _extEntry.FrameCount; x++)
                            for (int i = 0x10; i < 0x19; i++)
                                if ((kfe = _extEntry.GetKeyframe((KeyFrameMode)i, x)) != null)
                                    _intEntry.Keyframes.SetFrameValue((KeyFrameMode)i, x + origIntCount, kfe._value)._tangent = kfe._tangent;
                }
        }