コード例 #1
0
        protected override void OnPopulate()
        {
            StageGroup *grp    = Header->First;
            int         offset = 0x80; //There are 8 groups max

            for (int r = 0; r < 8; r++, grp = grp->Next, offset += 0x30)
            {
                if (((byte *)Header)[offset] == 0x61)
                {
                    TEVStage s0 = new TEVStage(r * 2);

                    KSel      KSEL = new KSel(grp->ksel.Data.Value);
                    RAS1_TRef TREF = new RAS1_TRef(grp->tref.Data.Value);

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

                    s0.kcsel = KSEL.KCSEL0;
                    s0.kasel = KSEL.KASEL0;

                    s0.ti = TREF.TI0;
                    s0.tc = TREF.TC0;
                    s0.cc = TREF.CC0;
                    s0.te = TREF.TE0;

                    s0.getValues();
                    AddChild(s0, false);

                    if (grp->oClrEnv.Reg == 0x61 && grp->oAlpEnv.Reg == 0x61 && grp->oCMD.Reg == 0x61)
                    {
                        TEVStage s1 = new TEVStage(r * 2 + 1);

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

                        s1.kcsel = KSEL.KCSEL1;
                        s1.kasel = KSEL.KASEL1;

                        s1.ti = TREF.TI1;
                        s1.tc = TREF.TC1;
                        s1.cc = TREF.CC1;
                        s1.te = TREF.TE1;

                        s1.getValues();
                        AddChild(s1, false);
                    }

                    //new MDL0ShaderStructNode().Initialize(this, grp, StageGroup.Size);
                }
            }
        }
コード例 #2
0
        public override void OnPopulate()
        {
            StageGroup *grp = Header->First;

            for (int r = 0; r < 8; r++, grp = grp->Next)
            {
                if (grp->mask.Reg == 0x61)
                {
                    MDL0TEVStageNode s0 = new MDL0TEVStageNode();

                    KSel      ksel = new KSel(grp->ksel.Data.Value);
                    RAS1_TRef tref = new RAS1_TRef(grp->tref.Data.Value);

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

                    s0._kcSel = ksel.KCSel0;
                    s0._kaSel = ksel.KASel0;

                    s0._texMapID   = tref.TexMapID0;
                    s0._texCoord   = tref.TexCoord0;
                    s0._colorChan  = tref.ColorChannel0;
                    s0._texEnabled = tref.TexEnabled0;

                    s0._parent = this;
                    _children.Add(s0);

                    if (grp->oClrEnv.Reg == 0x61 && grp->oAlpEnv.Reg == 0x61 && grp->oCMD.Reg == 0x61)
                    {
                        MDL0TEVStageNode s1 = new MDL0TEVStageNode();

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

                        s1._kcSel = ksel.KCSel1;
                        s1._kaSel = ksel.KASel1;

                        s1._texMapID   = tref.TexMapID1;
                        s1._texCoord   = tref.TexCoord1;
                        s1._colorChan  = tref.ColorChannel1;
                        s1._texEnabled = tref.TexEnabled1;

                        s1._parent = this;
                        _children.Add(s1);
                    }
                }
            }
        }
コード例 #3
0
        protected override bool OnInitialize()
        {
            StageGroup *header = Header;

            _name = String.Format("Struct{0}", Index);

            command1 = header->mask.Mem;
            command2 = header->ksel.Mem;
            command3 = header->tref.Mem;
            command4 = header->eClrEnv.Mem;
            command5 = header->oClrEnv.Mem;
            command6 = header->eAlpEnv.Mem;
            command7 = header->oAlpEnv.Mem;
            command8 = header->eCMD.Mem;
            command9 = header->oCMD.Mem;

            for (int i = 0xC0; i < 0xDF; i += 2)
            {
                if (Header->oClrEnv.Mem == (BPMemory)i)
                {
                    color2 = true; break;
                }
            }
            for (int i = 0xC1; i < 0xE0; i += 2)
            {
                if (Header->oAlpEnv.Mem == (BPMemory)i)
                {
                    alpha2 = true; break;
                }
            }
            for (int i = 0x10; i < 0x20; i++)
            {
                if (Header->oCMD.Mem == (BPMemory)i)
                {
                    CMD2 = true; break;
                }
            }

            Populate();
            return(true);
        }
コード例 #4
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;
                }
            }
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
0
        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;
                }
            }
        }