public override bool OnInitialize()
        {
            MDL0TextureRef* header = Header;

            _texPtr = header->_texPtr;
            _pltPtr = header->_pltPtr;
            _index1 = header->_index1;
            _index2 = header->_index2;
            _uWrap = header->_uWrap;
            _vWrap = header->_vWrap;
            _minFltr = header->_minFltr;
            _magFltr = header->_magFltr;
            _lodBias = header->_lodBias;
            _maxAniso = header->_maxAniso;
            _clampBias = header->_clampBias == 1;
            _texelInterp = header->_texelInterp == 1;
            _pad = header->_pad;

            if (header->_texOffset != 0)
            {
                if (_replaced && header->_texOffset >= Parent.WorkingUncompressed.Length)
                    Name = null;
                else
                {
                    if (_replaced)
                        Name = header->TextureName;
                    else
                        _name = header->TextureName;
                    _texture = Model.FindOrCreateTexture(_name);
                    _texture._references.Add(this);
                }
            }
            if (header->_pltOffset != 0)
            {
                if (_replaced && header->_pltOffset >= Parent.WorkingUncompressed.Length)
                    _palette = null;
                else
                {
                    string name = header->PaletteName;
                    _palette = Model.FindOrCreatePalette(name);
                    _palette._references.Add(this);
                }
            }

            int len = ((MDL0MaterialNode)Parent).XFCommands.Length;
            if (len != 0 && Index * 2 < len)
            {
                TexMtxFlags = new XFTexMtxInfo(((MDL0MaterialNode)Parent).XFCommands[Index * 2].values[0]);
                DualTexFlags = new XFDualTex(((MDL0MaterialNode)Parent).XFCommands[Index * 2 + 1].values[0]);
                getValues();
            }

            //if (PaletteNode == null && TextureNode != null)
            //{
            //    if (TextureNode.Source == null)
            //        TextureNode.GetSource();

            //    if (TextureNode.Source is TEX0Node && ((TEX0Node)TextureNode.Source).HasPalette)
            //    {
            //        Model._errors.Add("A palette was not set to texture reference " + Index + " in material " + Parent.Index + " (" + Parent.Name + ").");
            //        PaletteNode = Model.FindOrCreatePalette(TextureNode.Name);

            //        SignalPropertyChange();
            //    }
            //}

            MDL0TexSRTData* TexSettings = ((MDL0MaterialNode)Parent).Header->TexMatrices(((MDL0MaterialNode)Parent)._initVersion);

            _texFlags = TexSettings->GetTexFlags(Index);
            _texMatrix = TexSettings->GetTexMatrices(Index);

            _flags = (TexFlags)((((MDL0MaterialNode)Parent)._layerFlags >> (4 * Index)) & 0xF);

            _bindState = new FrameState(
                new Vector3(_texFlags.TexScale._x, _texFlags.TexScale._y, 1),
                new Vector3(_texFlags.TexRotation, 0, 0),
                new Vector3(_texFlags.TexTranslation._x, _texFlags.TexTranslation._y, 0));

            return false;
        }
        public void Default()
        {
            Name = "NewRef";
            _minFltr = 1;
            _magFltr = 1;
            UWrapMode = WrapMode.Repeat;
            VWrapMode = WrapMode.Repeat;

            _flags = (TexFlags)0xF;
            _texFlags.TexScale = new Vector2(1);
            _bindState._scale = new Vector3(1);
            _texMatrix.TexMtx = Matrix43.Identity;
            _texMatrix.SCNCamera = -1;
            _texMatrix.SCNLight = -1;
            _texMatrix.Identity = 1;

            _projection = (int)TexProjection.ST;
            _inputForm = (int)TexInputForm.AB11;
            _texGenType = (int)TexTexgenType.Regular;
            _sourceRow = (int)TexSourceRow.TexCoord0;
            _embossSource = 4;
            _embossLight = 2;

            getTexMtxVal();

            _texture = Model.FindOrCreateTexture(_name);
            _texture._references.Add(this);
        }