Пример #1
0
        public Msetfst(Stream fs, string motionId)
        {
            ReadBar.Barent[] array = ReadBar.Explode(fs);
            int num = 0;

            ReadBar.Barent[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ReadBar.Barent barent = array2[i];
                int            k      = barent.k;
                if (k == 17 && barent.len != 0)
                {
                    var mt = new Mt1();
                    ReadBar.Barent[] array3 = ReadBar.Explode2(new MemoryStream(barent.bin, false));
                    int num2 = 0;
                    ReadBar.Barent[] array4 = array3;
                    for (int j = 0; j < array4.Length; j++)
                    {
                        ReadBar.Barent barent2 = array4[j];
                        int            k2      = barent2.k;
                        if (k2 != 9)
                        {
                            if (k2 == 16)
                            {
                                mt.fm = new FacMod(new MemoryStream(barent2.bin, false));
                            }
                        }
                        else
                        {
                            mt.off   = (uint)(barent.off + barent2.off);
                            mt.len   = (uint)barent.len;
                            mt.id    = barent.id + "#" + barent2.id;
                            mt.bin   = barent2.bin;
                            mt.k1    = num;
                            mt.isRaw = barent2.id.Equals("raw");
                        }
                        num2++;
                    }
                    al1.Add(mt);
                }
                num++;
            }
        }
Пример #2
0
 public Msetfst(Stream fs, string motionId)
 {
     ReadBar.Barent[] array = ReadBar.Explode(fs);
     int num = 0;
     ReadBar.Barent[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         ReadBar.Barent barent = array2[i];
         int k = barent.k;
         if (k == 17 && barent.len != 0)
         {
             var mt = new Mt1();
             ReadBar.Barent[] array3 = ReadBar.Explode2(new MemoryStream(barent.bin, false));
             int num2 = 0;
             ReadBar.Barent[] array4 = array3;
             for (int j = 0; j < array4.Length; j++)
             {
                 ReadBar.Barent barent2 = array4[j];
                 int k2 = barent2.k;
                 if (k2 != 9)
                 {
                     if (k2 == 16)
                     {
                         mt.fm = new FacMod(new MemoryStream(barent2.bin, false));
                     }
                 }
                 else
                 {
                     mt.off = (uint) (barent.off + barent2.off);
                     mt.len = (uint) barent.len;
                     mt.id = barent.id + "#" + barent2.id;
                     mt.bin = barent2.bin;
                     mt.k1 = num;
                     mt.isRaw = barent2.id.Equals("raw");
                 }
                 num2++;
             }
             al1.Add(mt);
         }
         num++;
     }
 }
Пример #3
0
 private void calcbody(FormII.CaseTris ct, FormII.Mesh M, Mt1 mt1)
 {
     Mdlxfst mdlx = M.mdlx;
     Msetfst mset = M.mset;
     List<Body1> albody = M.albody1;
     Mlink mlink = M.ol;
     ct.Close();
     albody.Clear();
     if (mdlx != null && mset != null)
     {
         T31 t = mdlx.alt31[0];
         Matrix[] array;
         if (mt1.isRaw)
         {
             MsetRawblk msetRawblk = new MsetRawblk(new MemoryStream(mt1.bin, false));
             int num = Math.Max(0, Math.Min(msetRawblk.cntFrames - 1, (int)Math.Floor((double)this.tick)));
             int num2 = Math.Max(0, Math.Min(msetRawblk.cntFrames - 1, (int)Math.Ceiling((double)this.tick)));
             if (num == num2)
             {
                 MsetRM msetRM = msetRawblk.alrm[num];
                 array = (M.Ma = msetRM.al.ToArray());
             }
             else
             {
                 MsetRM msetRM2 = msetRawblk.alrm[num];
                 float num3 = this.tick % 1f;
                 MsetRM msetRM3 = msetRawblk.alrm[num2];
                 float num4 = 1f - num3;
                 array = (M.Ma = new Matrix[msetRawblk.cntJoints]);
                 for (int i = 0; i < array.Length; i++)
                 {
                     array[i] = new Matrix
                     {
                         M11 = msetRM2.al[i].M11 * num4 + msetRM3.al[i].M11 * num3,
                         M21 = msetRM2.al[i].M21 * num4 + msetRM3.al[i].M21 * num3,
                         M31 = msetRM2.al[i].M31 * num4 + msetRM3.al[i].M31 * num3,
                         M41 = msetRM2.al[i].M41 * num4 + msetRM3.al[i].M41 * num3,
                         M12 = msetRM2.al[i].M12 * num4 + msetRM3.al[i].M12 * num3,
                         M22 = msetRM2.al[i].M22 * num4 + msetRM3.al[i].M22 * num3,
                         M32 = msetRM2.al[i].M32 * num4 + msetRM3.al[i].M32 * num3,
                         M42 = msetRM2.al[i].M42 * num4 + msetRM3.al[i].M42 * num3,
                         M13 = msetRM2.al[i].M13 * num4 + msetRM3.al[i].M13 * num3,
                         M23 = msetRM2.al[i].M23 * num4 + msetRM3.al[i].M23 * num3,
                         M33 = msetRM2.al[i].M33 * num4 + msetRM3.al[i].M33 * num3,
                         M43 = msetRM2.al[i].M43 * num4 + msetRM3.al[i].M43 * num3,
                         M14 = msetRM2.al[i].M14 * num4 + msetRM3.al[i].M14 * num3,
                         M24 = msetRM2.al[i].M24 * num4 + msetRM3.al[i].M24 * num3,
                         M34 = msetRM2.al[i].M34 * num4 + msetRM3.al[i].M34 * num3,
                         M44 = msetRM2.al[i].M44 * num4 + msetRM3.al[i].M44 * num3
                     };
                 }
             }
         }
         else
         {
             Msetblk msetblk = new Msetblk(new MemoryStream(mt1.bin, false));
             MemoryStream memoryStream = new MemoryStream();
             if (mlink == null)
             {
                 mlink = (M.ol = new Mlink());
             }
             mlink.Permit(new MemoryStream(M.binMdlx, false), msetblk.cntb1, new MemoryStream(M.binMset, false), msetblk.cntb2, mt1.off, this.tick, memoryStream);
             BinaryReader binaryReader = new BinaryReader(memoryStream);
             memoryStream.Position = 0L;
             array = (M.Ma = new Matrix[msetblk.cntb1]);
             for (int j = 0; j < msetblk.cntb1; j++)
             {
                 array[j] = new Matrix
                 {
                     M11 = binaryReader.ReadSingle(),
                     M12 = binaryReader.ReadSingle(),
                     M13 = binaryReader.ReadSingle(),
                     M14 = binaryReader.ReadSingle(),
                     M21 = binaryReader.ReadSingle(),
                     M22 = binaryReader.ReadSingle(),
                     M23 = binaryReader.ReadSingle(),
                     M24 = binaryReader.ReadSingle(),
                     M31 = binaryReader.ReadSingle(),
                     M32 = binaryReader.ReadSingle(),
                     M33 = binaryReader.ReadSingle(),
                     M34 = binaryReader.ReadSingle(),
                     M41 = binaryReader.ReadSingle(),
                     M42 = binaryReader.ReadSingle(),
                     M43 = binaryReader.ReadSingle(),
                     M44 = binaryReader.ReadSingle()
                 };
             }
         }
         Matrix mv = Matrix.Identity;
         if (M.parent != null && M.iMa != -1)
         {
             mv = M.parent.Ma[M.iMa];
         }
         foreach (T13vif current in t.al13)
         {
             int tops = 544;
             int top = 0;
             VU1Mem vU1Mem = new VU1Mem();
             new ParseVIF1(vU1Mem).Parse(new MemoryStream(current.bin, false), tops);
             Body1 item = SimaVU1.Sima(vU1Mem, array, tops, top, current.texi, current.alaxi, mv);
             albody.Add(item);
         }
         List<uint> list = new List<uint>();
         List<FormII.Sepa> list2 = new List<FormII.Sepa>();
         int num5 = 0;
         int num6 = 0;
         uint[] array2 = new uint[4];
         int num7 = 0;
         int num8 = (int)this.tick;
         int[] array3 = new int[]
         {
             1,
             2,
             3
         };
         foreach (Body1 current2 in albody)
         {
             int num9 = 0;
             for (int k = 0; k < current2.alvi.Length; k++)
             {
                 array2[num7] = (uint)(current2.alvi[k] | num6 << 12 | k << 24);
                 num7 = (num7 + 1 & 3);
                 if (current2.alfl[k] == 32)
                 {
                     list.Add(array2[num7 - array3[num8 * 103 % 3] & 3]);
                     list.Add(array2[num7 - array3[(1 + num8 * 103) % 3] & 3]);
                     list.Add(array2[num7 - array3[(2 + num8 * 103) % 3] & 3]);
                     num9++;
                 }
                 else
                 {
                     if (current2.alfl[k] == 48)
                     {
                         list.Add(array2[num7 - array3[(num8 << 1) % 3] & 3]);
                         list.Add(array2[num7 - array3[(2 + (num8 << 1)) % 3] & 3]);
                         list.Add(array2[num7 - array3[(1 + (num8 << 1)) % 3] & 3]);
                         num9++;
                     }
                 }
             }
             list2.Add(new FormII.Sepa(num5, num9, current2.t, num6));
             num5 += 3 * num9;
             num6++;
         }
         ct.alsepa = list2.ToArray();
         ct.cntVert = list.Count;
         ct.cntPrimitives = 0;
         if (ct.cntVert != 0)
         {
             ct.vb = new VertexBuffer(this.device, 36 * ct.cntVert, Usage.None, ct.vf = (VertexFormat.Texture3 | VertexFormat.Position), Pool.Managed);
             DataStream dataStream = ct.vb.Lock(0, 0, LockFlags.None);
             try
             {
                 int count = list.Count;
                 for (int l = 0; l < count; l++)
                 {
                     uint num10 = list[l];
                     uint num11 = num10 & 4095u;
                     uint index = num10 >> 12 & 4095u;
                     uint num12 = num10 >> 24 & 4095u;
                     Body1 body = albody[(int)index];
                     PTex3 value = new PTex3(body.alvert[(int)((UIntPtr)num11)], new Vector2(body.aluv[(int)((UIntPtr)num12)].X, body.aluv[(int)((UIntPtr)num12)].Y));
                     dataStream.Write<PTex3>(value);
                 }
                 dataStream.Position = 0L;
             }
             finally
             {
                 ct.vb.Unlock();
             }
         }
     }
 }