public void Default()
        {
            Name      = "NewRef";
            Index1    = Index;
            Index2    = Index;
            _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.TexUnk1 = -1;
            _texMatrix.TexUnk2 = -1;
            _texMatrix.TexUnk4 = 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);
        }
Beispiel #2
0
        public bool HasFlag(TexFlags flag)
        {
            if (Header == null)
            {
                return(false);
            }

            return((Header.Flags & flag) == flag);
        }
        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);
        }
        protected override bool OnInitialize()
        {
            MDL0TextureRef *header = Header;

            _unk2    = header->_unk2;
            _unk3    = header->_unk3;
            _index1  = header->_index1;
            _index2  = header->_index2;
            _uWrap   = header->_uWrap;
            _vWrap   = header->_vWrap;
            _minFltr = header->_minFltr;
            _magFltr = header->_magFltr;
            _float   = header->_lodBias;
            _unk10   = header->_unk10;
            _unk11   = header->_unk11 == 1;
            _unk12   = header->_unk12 == 1;
            _unk13   = header->_unk13;

            if (header->_stringOffset != 0)
            {
                if (!Material._replaced)
                {
                    _name = header->ResourceString;
                }
                else
                {
                    _name = Material._name + "_Texture" + Index;
                }

                _texture = Model.FindOrCreateTexture(_name);
                _texture._references.Add(this);
            }
            if (header->_secondaryOffset != 0)
            {
                string name;
                if (!Material._replaced)
                {
                    name = header->SecondaryTexture;
                }
                else
                {
                    name = Material._name + "_Texture" + Index;
                }

                _palette = Model.FindOrCreatePalette(name);
                _palette._references.Add(this);
            }

            if (((MDL0MaterialNode)Parent).XFCommands.Length != 0)
            {
                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();
            //    }
            //}

            MDL0MtlTexSettings *TexSettings = ((MDL0MaterialNode)Parent).Header->TexMatrices(Model._version);

            _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);
        }
Beispiel #6
0
        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);
        }