示例#1
0
        protected override bool OnInitialize()
        {
            MDL0Shader *header = Header;

            _datalen    = header->_dataLength;
            _mdl0offset = header->_mdl0Offset;

            stages = header->_stages;

            res0 = header->_res0;
            res1 = header->_res1;
            res2 = header->_res2;

            ref0 = header->_ref0;
            ref1 = header->_ref1;
            ref2 = header->_ref2;
            ref3 = header->_ref3;
            ref4 = header->_ref4;
            ref5 = header->_ref5;
            ref6 = header->_ref6;
            ref7 = header->_ref7;

            pad0 = header->_pad0;
            pad1 = header->_pad1;

            if (_name == null)
            {
                _name = String.Format("Shader{0}", Index);
            }

            //Attach to materials
            byte *pHeader = (byte *)Header;

            if ((Model != null) && (Model._matList != null))
            {
                foreach (MDL0MaterialNode mat in Model._matList)
                {
                    MDL0Material *mHeader = mat.Header;
                    if (((byte *)mHeader + mHeader->_shaderOffset) == pHeader)
                    {
                        mat._shader = this;
                        _materials.Add(mat);
                    }
                }
            }

            _swapBlock = *header->SwapBlock;
            getIRefValues();

            Populate();
            return(true);
        }
        public override bool OnInitialize()
        {
            MDL0Shader *header = Header;

            _datalen    = header->_dataLength;
            _mdl0offset = header->_mdl0Offset;

            _stages = header->_stages;

            _res0 = header->_res0;
            _res1 = header->_res1;
            _res2 = header->_res2;

            _ref0 = header->_ref0;
            _ref1 = header->_ref1;
            _ref2 = header->_ref2;
            _ref3 = header->_ref3;
            _ref4 = header->_ref4;
            _ref5 = header->_ref5;
            _ref6 = header->_ref6;
            _ref7 = header->_ref7;

            _pad0 = header->_pad0;
            _pad1 = header->_pad1;

            //Attach to materials
            byte *pHeader = (byte *)Header;

            if ((Model != null) && (Model._matList != null))
            {
                foreach (MDL0MaterialNode mat in Model._matList)
                {
                    MDL0Material *mHeader = mat.Header;
                    if (((byte *)mHeader + mHeader->_shaderOffset) == pHeader)
                    {
                        mat._shader = this;
                        _materials.Add(mat);
                    }
                }
            }

            _swapBlock = *header->SwapBlock;

            Populate();
            return(true);
        }
示例#3
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            MDL0Shader *header = (MDL0Shader *)address;

            header->_dataLength = length;
            header->_index      = Index;

            header->_stages = Stages;

            header->_ref0 = _ref0;
            header->_ref1 = _ref1;
            header->_ref2 = _ref2;
            header->_ref3 = _ref3;
            header->_ref4 = _ref4;
            header->_ref5 = _ref5;
            header->_ref6 = _ref6;
            header->_ref7 = _ref7;

            header->_pad0 = 0;
            header->_pad1 = 0;
            header->_pad2 = 0;
            header->_pad3 = 0;
            header->_pad4 = 0;

            *header->SwapBlock = _swapBlock;

            StageGroup *grp = (StageGroup *)(address + 0x80);

            for (int i = 0; i < Children.Count; i++)
            {
                MDL0TEVStageNode c = (MDL0TEVStageNode)Children[i]; //Current Stage

                if (i % 2 == 0)                                     //Even Stage
                {
                    *grp = StageGroup.Default;

                    grp->SetGroup(i / 2);
                    grp->SetStage(i);

                    grp->eClrEnv.Data = c._colorEnv;
                    grp->eAlpEnv.Data = c._alphaEnv;
                    grp->eCMD.Data    = c._cmd;

                    if (i == Children.Count - 1) //Last stage is even, odd stage isn't used
                    {
                        grp->ksel.Data = new KSel(0, 0, c._kcSel, c._kaSel, 0, 0);
                        grp->tref.Data = new RAS1_TRef(c._texMapID, c._texCoord, c._texEnabled, c._colorChan, TexMapID.TexMap7, TexCoordID.TexCoord7, false, ColorSelChan.Zero);
                    }
                }
                else //Odd Stage
                {
                    MDL0TEVStageNode p = (MDL0TEVStageNode)Children[i - 1]; //Previous Stage

                    grp->SetStage(i);

                    grp->oClrEnv.Data = c._colorEnv;
                    grp->oAlpEnv.Data = c._alphaEnv;
                    grp->oCMD.Data    = c._cmd;

                    grp->ksel.Data = new KSel(0, 0, p._kcSel, p._kaSel, c._kcSel, c._kaSel);
                    grp->tref.Data = new RAS1_TRef(p._texMapID, p._texCoord, p._texEnabled, p._colorChan, c._texMapID, c._texCoord, c._texEnabled, c._colorChan);

                    grp = grp->Next;
                }
            }
        }
示例#4
0
        protected internal override void OnRebuild(VoidPtr address, int length, bool force)
        {
            MDL0Shader *header = (MDL0Shader *)address;

            if (Model._isImport)
            {
                ref1                         =
                    ref2                     =
                        ref3                 =
                            ref4             =
                                ref5         =
                                    ref6     =
                                        ref7 = -1;

                if (Model._importOptions._mdlType == 0)
                {
                    stages = 3;
                }
                else
                {
                    stages = 1;
                }
            }

            header->_dataLength = length;
            header->_index      = Index;

            header->_stages = Model._isImport ? stages : (byte)Children.Count;

            header->_res0 = res0;
            header->_res1 = res1;
            header->_res2 = res2;

            header->_ref0 = ref0;
            header->_ref1 = ref1;
            header->_ref2 = ref2;
            header->_ref3 = ref3;
            header->_ref4 = ref4;
            header->_ref5 = ref5;
            header->_ref6 = ref6;
            header->_ref7 = ref7;

            header->_pad0 = pad0;
            header->_pad1 = pad1;

            *header->SwapBlock = _swapBlock;

            //int offset = 0x80;
            //foreach (MDL0ShaderStructNode s in Children)
            //{
            //    s.Rebuild(address + offset, 0x30, force);
            //    offset += 0x30;
            //}

            StageGroup *grp = (StageGroup *)(address + 0x80);

            for (int i = 0; i < Children.Count; i++)
            {
                TEVStage c = (TEVStage)Children[i]; //Current Stage

                if (i % 2 == 0)                     //Even Stage
                {
                    *grp = StageGroup.Default;

                    grp->SetGroup(i / 2);
                    grp->SetStage(i);

                    grp->eClrEnv.Data.Value = c.rawColEnv;
                    grp->eAlpEnv.Data.Value = c.rawAlphaEnv;
                    grp->eCMD.Data.Value    = c.rawCMD;

                    if (i == Children.Count - 1) //Last stage is even, odd stage isn't used
                    {
                        grp->ksel.Data.Value = KSel.Shift(0, 0, c.kcsel, c.kasel, 0, 0);
                        grp->tref.Data.Value = RAS1_TRef.Shift(c.ti, c.tc, c.te ? 1 : 0, c.cc, 7, 7, 0, 7);
                    }
                }
                else //Odd Stage
                {
                    TEVStage p = (TEVStage)Children[i - 1]; //Previous Stage

                    grp->SetStage(i);

                    grp->oClrEnv.Data.Value = c.rawColEnv;
                    grp->oAlpEnv.Data.Value = c.rawAlphaEnv;
                    grp->oCMD.Data.Value    = c.rawCMD;

                    grp->ksel.Data.Value = KSel.Shift(0, 0, p.kcsel, p.kasel, c.kcsel, c.kasel);
                    grp->tref.Data.Value = RAS1_TRef.Shift(p.ti, p.tc, p.te ? 1 : 0, p.cc, c.ti, c.tc, c.te ? 1 : 0, c.cc);

                    grp = grp->Next;
                }
            }

            if (Model._isImport)
            {
                StageGroup *struct0 = header->First;
                *           struct0 = StageGroup.Default;
                struct0->SetGroup(0);
                switch (Model._importOptions._mdlType)
                {
                case 0:     //Character

                    struct0->SetStage(0);
                    struct0->SetStage(1);

                    struct0->mask.Data.Value    = 0xFFFFF0;
                    struct0->ksel.Data.Value    = 0xE378C0;
                    struct0->tref.Data.Value    = 0x03F040;
                    struct0->eClrEnv.Data.Value = 0x28F8AF;
                    struct0->oClrEnv.Data.Value = 0x08FEB0;
                    struct0->eAlpEnv.Data.Value = 0x08F2F0;
                    struct0->oAlpEnv.Data.Value = 0x081FF0;

                    //new MDL0ShaderStructNode().Initialize(this, header->First, StageGroup.Size);

                    StageGroup *struct1 = struct0->Next;
                    *           struct1 = StageGroup.Default;

                    struct1->SetGroup(1);
                    struct1->SetStage(2);

                    struct1->mask.Data.Value    = 0xFFFFF0;
                    struct1->ksel.Data.Value    = 0x0038C0;
                    struct1->tref.Data.Value    = 0x3BF3BF;
                    struct1->eClrEnv.Data.Value = 0x0806EF;
                    struct1->eAlpEnv.Data.Value = 0x081FF0;

                    //new MDL0ShaderStructNode().Initialize(this, struct0->Next, StageGroup.Size);
                    break;

                case 1:     //Stage/Item

                    struct0->SetStage(0);

                    struct0->mask.Data.Value    = 0xFFFFF0;
                    struct0->ksel.Data.Value    = 0x0038C0;
                    struct0->tref.Data.Value    = 0x3BF040;
                    struct0->eClrEnv.Data.Value = 0x28F8AF;
                    struct0->eAlpEnv.Data.Value = 0x08F2F0;

                    //new MDL0ShaderStructNode().Initialize(this, header->First, StageGroup.Size);
                    break;
                }
            }
        }
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            MDL0Shader *header = (MDL0Shader *)address;

            if (Model._isImport)
            {
                _ref1                         =
                    _ref2                     =
                        _ref3                 =
                            _ref4             =
                                _ref5         =
                                    _ref6     =
                                        _ref7 = -1;

                if (Collada._importOptions._mdlType == 0)
                {
                    _stages = 3;
                }
                else
                {
                    _stages = 1;
                }
            }

            header->_dataLength = length;
            header->_index      = Index;

            header->_stages = Model._isImport ? _stages : (byte)Children.Count;

            header->_res0 = 0;
            header->_res1 = 0;
            header->_res2 = 0;

            header->_ref0 = _ref0;
            header->_ref1 = _ref1;
            header->_ref2 = _ref2;
            header->_ref3 = _ref3;
            header->_ref4 = _ref4;
            header->_ref5 = _ref5;
            header->_ref6 = _ref6;
            header->_ref7 = _ref7;

            header->_pad0 = 0;
            header->_pad1 = 0;

            *header->SwapBlock = _swapBlock;

            StageGroup *grp = (StageGroup *)(address + 0x80);

            for (int i = 0; i < Children.Count; i++)
            {
                TEVStage c = (TEVStage)Children[i]; //Current Stage

                if (i % 2 == 0)                     //Even Stage
                {
                    *grp = StageGroup.Default;

                    grp->SetGroup(i / 2);
                    grp->SetStage(i);

                    grp->eClrEnv.Data = c._colorEnv;
                    grp->eAlpEnv.Data = c._alphaEnv;
                    grp->eCMD.Data    = c._cmd;

                    if (i == Children.Count - 1) //Last stage is even, odd stage isn't used
                    {
                        grp->ksel.Data = new KSel(0, 0, c._kcSel, c._kaSel, 0, 0);
                        grp->tref.Data = new RAS1_TRef(c._texMapID, c._texCoord, c._texEnabled, c._colorChan, TexMapID.TexMap7, TexCoordID.TexCoord7, false, ColorSelChan.Zero);
                    }
                }
                else //Odd Stage
                {
                    TEVStage p = (TEVStage)Children[i - 1]; //Previous Stage

                    grp->SetStage(i);

                    grp->oClrEnv.Data = c._colorEnv;
                    grp->oAlpEnv.Data = c._alphaEnv;
                    grp->oCMD.Data    = c._cmd;

                    grp->ksel.Data = new KSel(0, 0, p._kcSel, p._kaSel, c._kcSel, c._kaSel);
                    grp->tref.Data = new RAS1_TRef(p._texMapID, p._texCoord, p._texEnabled, p._colorChan, c._texMapID, c._texCoord, c._texEnabled, c._colorChan);

                    grp = grp->Next;
                }
            }

            if (Model._isImport)
            {
                StageGroup *struct0 = header->First;
                *           struct0 = StageGroup.Default;
                struct0->SetGroup(0);

                switch (Collada._importOptions._mdlType)
                {
                case Modeling.Collada.ImportOptions.MDLType.Character:

                    struct0->SetStage(0);
                    struct0->SetStage(1);

                    struct0->mask.Data.Value    = 0xFFFFF0;
                    struct0->ksel.Data.Value    = 0xE378C0;
                    struct0->tref.Data.Value    = 0x03F040;
                    struct0->eClrEnv.Data.Value = 0x28F8AF;
                    struct0->oClrEnv.Data.Value = 0x08FEB0;
                    struct0->eAlpEnv.Data.Value = 0x08F2F0;
                    struct0->oAlpEnv.Data.Value = 0x081FF0;

                    StageGroup *struct1 = struct0->Next;
                    *           struct1 = StageGroup.Default;

                    struct1->SetGroup(1);
                    struct1->SetStage(2);

                    struct1->mask.Data.Value    = 0xFFFFF0;
                    struct1->ksel.Data.Value    = 0x0038C0;
                    struct1->tref.Data.Value    = 0x3BF3BF;
                    struct1->eClrEnv.Data.Value = 0x0806EF;
                    struct1->eAlpEnv.Data.Value = 0x081FF0;

                    break;

                case Modeling.Collada.ImportOptions.MDLType.Stage:

                    struct0->SetStage(0);

                    struct0->mask.Data.Value    = 0xFFFFF0;
                    struct0->ksel.Data.Value    = 0x0038C0;
                    struct0->tref.Data.Value    = 0x3BF040;
                    struct0->eClrEnv.Data.Value = 0x28F8AF;
                    struct0->eAlpEnv.Data.Value = 0x08F2F0;

                    break;
                }
            }
        }