示例#1
0
                    private MTX44 InterpolateMTX44_50_50(MTX44 a, MTX44 b)
                    {
                        a[0, 0] += b[0, 0];
                        a[1, 0] += b[1, 0];
                        a[2, 0] += b[2, 0];
                        a[0, 1] += b[0, 1];
                        a[1, 1] += b[1, 1];
                        a[2, 1] += b[2, 1];
                        Vector3 vector3_1 = Vector3.Normalize(new Vector3(a[0, 0], a[1, 0], a[2, 0]));

                        a[0, 0] = vector3_1.X;
                        a[1, 0] = vector3_1.Y;
                        a[2, 0] = vector3_1.Z;
                        Vector3 vector3_2 = Vector3.Normalize(new Vector3(a[0, 1], a[1, 1], a[2, 1]));

                        a[0, 1]  = vector3_2.X;
                        a[1, 1]  = vector3_2.Y;
                        a[2, 1]  = vector3_2.Z;
                        a[0, 2] += b[0, 2];
                        a[1, 2] += b[1, 2];
                        a[2, 2] += b[2, 2];
                        Vector3 vector3_3 = Vector3.Normalize(new Vector3(a[0, 2], a[1, 2], a[2, 2]));

                        a[0, 2] = vector3_3.X;
                        a[1, 2] = vector3_3.Y;
                        a[2, 2] = vector3_3.Z;
                        return(a);
                    }
示例#2
0
                public MTX44 GetMatrix()
                {
                    MTX44 mtX44 = new MTX44();

                    return((MTX44)GlNitro.glNitroPivot(new float[2]
                    {
                        this.A,
                        this.B
                    }, (int)this.info & 15, (int)this.info >> 4 & 15));
                }
示例#3
0
                public MTX44 GetMatrix()
                {
                    short num1  = (short)((int)this.data[4] & 7);
                    short num2  = (short)((int)this.data[4] >> 3);
                    short num3  = (short)((int)num1 << 3 | (int)this.data[0] & 7);
                    short num4  = (short)((int)this.data[0] >> 3);
                    short num5  = (short)((int)num3 << 3 | (int)this.data[1] & 7);
                    short num6  = (short)((int)this.data[1] >> 3);
                    short num7  = (short)((int)num5 << 3 | (int)this.data[2] & 7);
                    short num8  = (short)((int)this.data[2] >> 3);
                    short num9  = (short)((int)num7 << 3 | (int)this.data[3] & 7);
                    short num10 = (short)((int)this.data[3] >> 3);
                    short num11 = (short)((int)(short)((int)num9 << 3) >> 3);
                    MTX44 mtX44 = new MTX44();

                    mtX44[0, 0] = (float)num4;
                    mtX44[1, 0] = (float)num6;
                    mtX44[2, 0] = (float)num8;
                    mtX44[0, 1] = (float)num10;
                    mtX44[1, 1] = (float)num2;
                    mtX44[2, 1] = (float)num11;
                    Vector3 vector3 = this.vecCross_(new Vector3(mtX44[0, 0], mtX44[1, 0], mtX44[2, 0]), new Vector3(mtX44[0, 1], mtX44[1, 1], mtX44[2, 1]));

                    mtX44[0, 2]  = vector3.X;
                    mtX44[1, 2]  = vector3.Y;
                    mtX44[2, 2]  = vector3.Z;
                    mtX44[0, 0] /= 4096f;
                    mtX44[1, 0] /= 4096f;
                    mtX44[2, 0] /= 4096f;
                    mtX44[0, 1] /= 4096f;
                    mtX44[1, 1] /= 4096f;
                    mtX44[2, 1] /= 4096f;
                    mtX44[0, 2] /= 4096f;
                    mtX44[1, 2] /= 4096f;
                    mtX44[2, 2] /= 4096f;
                    return(mtX44);
                }
示例#4
0
        public void Render(BCA Bca, int BcaFrame)
        {
            bool flag1 = Bca != null;

            Matrix4[] matrix4Array = (Matrix4[])null;
            if (flag1)
            {
                matrix4Array = Bca.GetMatrices(this.Bones, BcaFrame, (int)this.Header.PosScale);
            }
            int num1 = 0;

            while (true)
            {
                GlNitro.Nitro3DContext Context = new GlNitro.Nitro3DContext();
                foreach (BMD.BMDBone bone in this.Bones)
                {
                    for (int index1 = 0; (long)index1 < (long)bone.NrDLMatPairs; ++index1)
                    {
                        BMD.BMDMaterial    material    = this.Materials[(int)bone.PolyMat.Values.ToArray <byte>()[index1]];
                        BMD.BMDDisplayList displayList = this.DisplayLists[(int)bone.PolyMat.Keys.ToArray <byte>()[index1]];
                        byte num2 = bone.PolyMat.Values.ToArray <byte>()[index1];
                        bool flag2;
                        if (material.TexID != -1 && this.Textures[material.TexID].Fmt != Graphic.GXTexFmt.GX_TEXFMT_NONE)
                        {
                            flag2 = true;
                            if ((this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_A3I5 || this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_A5I3 || ((int)(material.polyAttr >> 16) & 31) != 31) && num1 != 1)
                            {
                                flag2 = false;
                            }
                            if ((this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_NONE || this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_PLTT4 || (this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_PLTT16 || this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_PLTT256) || (this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_COMP4x4 || this.Textures[material.TexID].Fmt == Graphic.GXTexFmt.GX_TEXFMT_DIRECT)) && ((int)(material.polyAttr >> 16) & 31) == 31 && num1 != 0)
                            {
                                flag2 = false;
                            }
                        }
                        else
                        {
                            flag2 = true;
                        }
                        if (flag2)
                        {
                            Gl.glBindTexture(3553, (int)num2 + 1);
                            Gl.glMatrixMode(5890);
                            if (material.TexID == -1)
                            {
                                Gl.glLoadIdentity();
                            }
                            else
                            {
                                Gl.glLoadMatrixf(material.GetMatrix((int)this.Textures[material.TexID].S, (int)this.Textures[material.TexID].T));
                            }
                            Gl.glEnable(3008);
                            Gl.glAlphaFunc(516, 0.0f);
                            Context.LightEnabled[0] = ((int)material.polyAttr & 1) == 1;
                            Context.LightEnabled[1] = ((int)(material.polyAttr >> 1) & 1) == 1;
                            Context.LightEnabled[2] = ((int)(material.polyAttr >> 2) & 1) == 1;
                            Context.LightEnabled[3] = ((int)(material.polyAttr >> 3) & 1) == 1;
                            Color color1 = Graphic.ConvertABGR1555((short)((int)material.diffAmb & (int)short.MaxValue));
                            Color color2 = Graphic.ConvertABGR1555((short)((int)(material.diffAmb >> 16) & (int)short.MaxValue));
                            Context.DiffuseColor = color1;
                            Context.AmbientColor = color2;
                            Color color3 = Graphic.ConvertABGR1555((short)((int)material.specEmi & (int)short.MaxValue));
                            Color color4 = Graphic.ConvertABGR1555((short)((int)(material.specEmi >> 16) & (int)short.MaxValue));
                            Context.SpecularColor = color3;
                            Context.EmissionColor = color4;
                            switch (material.polyAttr >> 14 & 1U)
                            {
                            case 0:
                                Gl.glDepthFunc(513);
                                break;

                            case 1:
                                Gl.glDepthFunc(514);
                                break;
                            }
                            int num3 = -1;
                            switch (material.polyAttr >> 4 & 3U)
                            {
                            case 0:
                                num3 = 8448;
                                break;

                            case 1:
                                num3 = 8449;
                                break;

                            case 2:
                                num3 = 8448;
                                break;

                            case 3:
                                num3 = 8448;
                                break;
                            }
                            Gl.glTexEnvi(8960, 8704, num3);
                            Context.Alpha = (int)(material.polyAttr >> 16) & 31;
                            if (((int)(material.diffAmb >> 15) & 1) == 1)
                            {
                                Gl.glColor4f((float)color1.R / (float)byte.MaxValue, (float)color1.G / (float)byte.MaxValue, (float)color1.B / (float)byte.MaxValue, (float)Context.Alpha / 31f);
                            }
                            else
                            {
                                Gl.glColor4f(0.0f, 0.0f, 0.0f, (float)Context.Alpha / 31f);
                            }
                            Context.UseSpecularReflectionTable = ((int)(material.specEmi >> 15) & 1) == 1;
                            int mode = -1;
                            switch (material.polyAttr >> 6 & 3U)
                            {
                            case 0:
                                mode = 1032;
                                break;

                            case 1:
                                mode = 1028;
                                break;

                            case 2:
                                mode = 1029;
                                break;

                            case 3:
                                mode = 0;
                                break;
                            }
                            Gl.glCullFace(mode);
                            Gl.glMatrixMode(5888);
                            Gl.glDisable(3168);
                            Gl.glDisable(3169);
                        }
                        MTX44[] mtX44Array = new MTX44[31];
                        int     index2     = 0;
                        foreach (ushort boneId in displayList.DL.BoneIDs)
                        {
                            if (!flag1)
                            {
                                mtX44Array[index2] = (MTX44)this.Bones[(int)boneId].GetMatrix();
                                ++index2;
                            }
                            else
                            {
                                mtX44Array[index2] = this.Matrix4ToMTX44(matrix4Array[(int)boneId]);
                                ++index2;
                            }
                        }
                        Context.MatrixStack = mtX44Array;
                        if (flag2)
                        {
                            GlNitro.glNitroGx(displayList.DL.Data, new MTX44(), ref Context, (int)this.Header.PosScale, false);
                            Gl.glEnd();
                        }
                    }
                }
                if (num1 == 0)
                {
                    ++num1;
                }
                else
                {
                    break;
                }
            }
        }
示例#5
0
                    public MTX44 GetMatrix(int Frame)
                    {
                        if (this.rot5 == null && this.rot3 == null)
                        {
                            return(this.const_rot3 == null?this.const_rot5.GetMatrix() : this.const_rot3.GetMatrix());
                        }
                        int num = (int)((this.info & this.NNS_G3D_JNTANM_RINFO_LAST_INTERP_MASK) >> 16);

                        if (((int)this.info & (int)this.NNS_G3D_JNTANM_RINFO_STEP_MASK) == 0)
                        {
                            return(this.rot3[Frame] == null ? this.rot5[Frame].GetMatrix() : this.rot3[Frame].GetMatrix());
                        }
                        if (((int)this.info & (int)this.NNS_G3D_JNTANM_RINFO_STEP_2) != 0)
                        {
                            if ((Frame & 1) == 0)
                            {
                                return(this.rot3[Frame >> 1] == null ? this.rot5[Frame >> 1].GetMatrix() : this.rot3[Frame >> 1].GetMatrix());
                            }
                            return(Frame > num ? (this.rot3[(num >> 1) + 1] == null ? this.rot5[(num >> 1) + 1].GetMatrix() : this.rot3[(num >> 1) + 1].GetMatrix()) : this.InterpolateMTX44_50_50(this.rot3[Frame >> 1] == null ? this.rot5[Frame >> 1].GetMatrix() : this.rot3[Frame >> 1].GetMatrix(), this.rot3[(Frame >> 1) + 1] == null ? this.rot5[(Frame >> 1) + 1].GetMatrix() : this.rot3[(Frame >> 1) + 1].GetMatrix()));
                        }
                        if (((int)this.info & (int)this.NNS_G3D_JNTANM_RINFO_STEP_4) == 0)
                        {
                            return(new MTX44());
                        }
                        if ((Frame & 3) == 0)
                        {
                            return(this.rot3[Frame >> 2] == null ? this.rot5[Frame >> 2].GetMatrix() : this.rot3[Frame >> 2].GetMatrix());
                        }
                        if (Frame > num)
                        {
                            return(this.rot3[(num >> 2) + (Frame & 3)] == null ? this.rot5[(num >> 2) + (Frame & 3)].GetMatrix() : this.rot3[(num >> 2) + (Frame & 3)].GetMatrix());
                        }
                        if ((Frame & 1) == 0)
                        {
                            return(this.InterpolateMTX44_50_50(this.rot3[Frame >> 2] == null ? this.rot5[Frame >> 2].GetMatrix() : this.rot3[Frame >> 2].GetMatrix(), this.rot3[(Frame >> 2) + 1] == null ? this.rot5[(Frame >> 2) + 1].GetMatrix() : this.rot3[(Frame >> 2) + 1].GetMatrix()));
                        }
                        int index1;
                        int index2;

                        if ((Frame & 2) != 0)
                        {
                            index1 = Frame >> 2;
                            index2 = index1 + 1;
                        }
                        else
                        {
                            index2 = Frame >> 2;
                            index1 = index2 + 1;
                        }
                        MTX44 mtX44_1 = this.rot3[index2] == null ? this.rot5[index2].GetMatrix() : this.rot3[index2].GetMatrix();
                        MTX44 mtX44_2 = this.rot3[index1] == null ? this.rot5[index1].GetMatrix() : this.rot3[index1].GetMatrix();

                        mtX44_1[0, 0] = mtX44_1[0, 0] * 3f + mtX44_2[0, 0];
                        mtX44_1[1, 0] = mtX44_1[1, 0] * 3f + mtX44_2[1, 0];
                        mtX44_1[2, 0] = mtX44_1[2, 0] * 3f + mtX44_2[2, 0];
                        mtX44_1[0, 1] = mtX44_1[0, 1] * 3f + mtX44_2[0, 1];
                        mtX44_1[1, 1] = mtX44_1[1, 1] * 3f + mtX44_2[1, 1];
                        mtX44_1[2, 1] = mtX44_1[2, 1] * 3f + mtX44_2[2, 1];
                        Vector3 vector3_1 = Vector3.Normalize(new Vector3(mtX44_1[0, 0], mtX44_1[1, 0], mtX44_1[2, 0]));

                        mtX44_1[0, 0] = vector3_1.X;
                        mtX44_1[1, 0] = vector3_1.Y;
                        mtX44_1[2, 0] = vector3_1.Z;
                        Vector3 vector3_2 = Vector3.Normalize(new Vector3(mtX44_1[0, 1], mtX44_1[1, 1], mtX44_1[2, 1]));

                        mtX44_1[0, 1] = vector3_2.X;
                        mtX44_1[1, 1] = vector3_2.Y;
                        mtX44_1[2, 1] = vector3_2.Z;
                        mtX44_1[0, 2] = mtX44_1[0, 2] * 3f + mtX44_2[0, 2];
                        mtX44_1[1, 2] = mtX44_1[1, 2] * 3f + mtX44_2[1, 2];
                        mtX44_1[2, 2] = mtX44_1[2, 2] * 3f + mtX44_2[2, 2];
                        Vector3 vector3_3 = Vector3.Normalize(new Vector3(mtX44_1[0, 2], mtX44_1[1, 2], mtX44_1[2, 2]));

                        mtX44_1[0, 2] = vector3_3.X;
                        mtX44_1[1, 2] = vector3_3.Y;
                        mtX44_1[2, 2] = vector3_3.Z;
                        return(mtX44_1);
                    }
示例#6
0
                    public float[] GetMatrix(int Frame, int origWidth, int origHeight)
                    {
                        float num1        = this.GetValue(this.scaleS, this.scaleSEx, this.Ss, Frame);
                        float num2        = this.GetValue(this.scaleT, this.scaleTEx, this.St, Frame);
                        uint  sinCosValue = this.GetSinCosValue(this.rot, this.rotEx, this.r, Frame);
                        float num3        = (float)(sinCosValue & (uint)ushort.MaxValue) / 4096f;
                        float num4        = (float)(sinCosValue >> 16) / 4096f;
                        float num5        = this.GetValue(this.transS, this.transSEx, this.Ts, Frame);
                        float num6        = this.GetValue(this.transT, this.transTEx, this.Tt, Frame);
                        MTX44 mtX44       = new MTX44();

                        mtX44.Zero();
                        bool flag1 = this.Ss != null || this.St != null || (double)num1 != 1.0 || (double)num2 != 1.0;
                        bool flag2 = this.r != null || (double)num3 != 0.0 || (double)num4 != 1.0;
                        bool flag3 = this.Ts != null || this.Tt != null || (double)num5 != 0.0 || (double)num6 != 0.0;

                        if (!flag1 && !flag2 && !flag3)
                        {
                            mtX44[0, 0] = 1f;
                            mtX44[1, 0] = 0.0f;
                            mtX44[0, 1] = 0.0f;
                            mtX44[1, 1] = 1f;
                            mtX44[0, 3] = 0.0f;
                            mtX44[1, 3] = 0.0f;
                        }
                        else if (!flag1 && !flag2 && flag3)
                        {
                            mtX44[0, 0] = 1f;
                            mtX44[1, 1] = 1f;
                            mtX44[1, 0] = 0.0f;
                            mtX44[0, 3] = (float)(-((double)num5 * (double)origWidth) * 16.0);
                            mtX44[1, 3] = (float)((double)num6 * (double)origHeight * 16.0);
                            mtX44[0, 1] = 0.0f;
                        }
                        else if (!flag1 && flag2 && !flag3)
                        {
                            float num7 = (float)origWidth * 4096f;
                            float num8 = (float)origHeight * 4096f;
                            float num9 = num8 / num7;
                            mtX44[0, 0] = num4;
                            mtX44[1, 1] = num4;
                            mtX44[1, 0] = (float)(-(double)num3 * (double)num9 / 4096.0);
                            float num10 = num7 / num8;
                            mtX44[0, 3] = (float)((-(double)num3 - (double)num4 + 1.0) * (double)origWidth * 8.0);
                            mtX44[1, 3] = (float)(((double)num3 - (double)num4 + 1.0) * (double)origHeight * 8.0);
                            mtX44[0, 1] = (float)((double)num3 * (double)num10 / 4096.0);
                        }
                        else if (!flag1 && flag2 && flag3)
                        {
                            float num7 = (float)origWidth * 4096f;
                            float num8 = (float)origHeight * 4096f;
                            float num9 = num8 / num7;
                            mtX44[0, 0] = num4;
                            mtX44[1, 1] = num4;
                            mtX44[1, 0] = (float)(-(double)num3 * (double)num9 / 4096.0);
                            float num10 = num7 / num8;
                            mtX44[0, 3] = (float)((-(double)num3 - (double)num4 + 1.0) * (double)origWidth * 8.0 - (double)num5 * (double)origWidth * 16.0);
                            mtX44[1, 3] = (float)(((double)num3 - (double)num4 + 1.0) * (double)origHeight * 8.0 + (double)num6 * (double)origHeight * 16.0);
                            mtX44[0, 1] = (float)((double)num3 * (double)num10 / 4096.0);
                        }
                        else if (flag1 && !flag2 && !flag3)
                        {
                            mtX44[0, 0] = num1;
                            mtX44[1, 1] = num2;
                            mtX44[1, 0] = 0.0f;
                            mtX44[0, 3] = 0.0f;
                            mtX44[1, 3] = (float)((-2.0 * (double)num2 + 2.0) * (double)origHeight * 8.0);
                            mtX44[0, 1] = 0.0f;
                        }
                        else if (flag1 && !flag2 && flag3)
                        {
                            mtX44[0, 0] = num1;
                            mtX44[1, 1] = num2;
                            mtX44[1, 0] = 0.0f;
                            mtX44[0, 3] = (float)-((double)num1 * (double)num5 / (double)byte.MaxValue) * (float)origWidth;
                            mtX44[1, 3] = (float)((-(double)num2 - (double)num2 + 2.0) * (double)origHeight * 8.0 + (double)num2 * (double)num6 / (double)byte.MaxValue * (double)origHeight);
                            mtX44[0, 1] = 0.0f;
                        }
                        else if (flag1 && flag2 && !flag3)
                        {
                            float num7  = (float)origWidth * 4096f;
                            float num8  = (float)origHeight * 4096f;
                            float num9  = num8 / num7;
                            float num10 = (float)((double)num1 * (double)num3 / 4096.0);
                            float num11 = (float)((double)num1 * (double)num4 / 4096.0);
                            float num12 = (float)((double)num2 * (double)num3 / 4096.0);
                            float num13 = (float)((double)num2 * (double)num4 / 4096.0);
                            mtX44[0, 0] = num11;
                            mtX44[1, 1] = num13;
                            mtX44[0, 1] = (float)(-(double)num12 * (double)num9 / 4096.0);
                            float num14 = num7 / num8;
                            mtX44[0, 3] = (float)((-(double)num10 - (double)num11 + (double)num1) * (double)origWidth * 8.0);
                            mtX44[1, 3] = (float)(((double)num12 - (double)num13 - (double)num2 + 2.0) * (double)origHeight * 8.0);
                            mtX44[0, 1] = (float)((double)num10 * (double)num14 / 4096.0);
                        }
                        else if (flag1 && flag2 && flag3)
                        {
                            float num7  = (float)origWidth * 4096f;
                            float num8  = (float)origHeight * 4096f;
                            float num9  = num8 / num7;
                            float num10 = (float)((double)num1 * (double)num3 / 4096.0);
                            float num11 = (float)((double)num1 * (double)num4 / 4096.0);
                            float num12 = (float)((double)num2 * (double)num3 / 4096.0);
                            float num13 = (float)((double)num2 * (double)num4 / 4096.0);
                            mtX44[0, 0] = num11;
                            mtX44[1, 1] = num13;
                            mtX44[1, 0] = (float)(-(double)num12 * (double)num9 / 4096.0);
                            float num14 = num7 / num8;
                            mtX44[0, 3] = (float)((-(double)num10 - (double)num11 + (double)num1) * (double)origWidth * 8.0 - (double)num1 * (double)num5 / (double)byte.MaxValue * (double)origWidth);
                            mtX44[1, 3] = (float)(((double)num12 - (double)num13 - (double)num2 + 2.0) * (double)origHeight * 8.0 + (double)num2 * (double)num6 / (double)byte.MaxValue * (double)origHeight);
                            mtX44[0, 1] = (float)((double)num10 * (double)num14 / 4096.0);
                        }
                        mtX44[2, 2] = 1f;
                        mtX44[3, 3] = 1f;
                        return((float[])mtX44);
                    }