示例#1
0
 public static Body1e Sima(VU1Mem vu1mem, Matrix[] Ma, int tops, int top2, int tsel, int[] alaxi, Matrix Mv)
 {
     MemoryStream memoryStream = new MemoryStream(vu1mem.vumem, true);
     BinaryReader binaryReader = new BinaryReader(memoryStream);
     memoryStream.Position = (long)(16 * tops);
     int num = binaryReader.ReadInt32();
     if (num != 1 && num != 2)
     {
         throw new ProtInvalidTypeException();
     }
     binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     int num2 = binaryReader.ReadInt32();
     int num3 = binaryReader.ReadInt32();
     int num4 = binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     if (num == 1)
     {
         binaryReader.ReadInt32();
     }
     if (num == 1)
     {
         binaryReader.ReadInt32();
     }
     int num5 = (num == 1) ? binaryReader.ReadInt32() : 0;
     int num6 = (num == 1) ? binaryReader.ReadInt32() : 0;
     int num7 = binaryReader.ReadInt32();
     int num8 = binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     int num9 = binaryReader.ReadInt32();
     memoryStream.Position = (long)(16 * (tops + num4));
     int[] array = new int[num9];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = binaryReader.ReadInt32();
     }
     Body1e body1e = new Body1e();
     body1e.t = tsel;
     body1e.alvertraw = new Vector4[num7];
     body1e.avail = (num5 == 0 && num == 1);
     body1e.alalni = new MJ1[num7][];
     MJ1[] array2 = new MJ1[num7];
     int num10 = 0;
     memoryStream.Position = (long)(16 * (tops + num8));
     for (int j = 0; j < array.Length; j++)
     {
         int num11 = array[j];
         int k = 0;
         while (k < num11)
         {
             float x = binaryReader.ReadSingle();
             float y = binaryReader.ReadSingle();
             float z = binaryReader.ReadSingle();
             float num12 = binaryReader.ReadSingle();
             Vector4 vector = new Vector4(x, y, z, num12);
             body1e.alvertraw[num10] = Vector4.Transform(vector, Mv);
             body1e.alalni[num10] = new MJ1[]
             {
                 array2[num10] = new MJ1(alaxi[j], num10, num12)
             };
             k++;
             num10++;
         }
     }
     body1e.aluv = new Vector2[num2];
     body1e.alvi = new int[num2];
     body1e.alfl = new int[num2];
     int num13 = 2147483647;
     int num14 = -2147483648;
     memoryStream.Position = (long)(16 * (tops + num3));
     for (int l = 0; l < num2; l++)
     {
         int num15 = (int)(binaryReader.ReadUInt16() / 16);
         binaryReader.ReadUInt16();
         int num16 = (int)(binaryReader.ReadUInt16() / 16);
         binaryReader.ReadUInt16();
         body1e.aluv[l] = new Vector2((float)num15 / 256f, (float)num16 / 256f);
         int val = body1e.alvi[l] = (int)binaryReader.ReadUInt16();
         binaryReader.ReadUInt16();
         body1e.alfl[l] = (int)binaryReader.ReadUInt16();
         binaryReader.ReadUInt16();
         num13 = Math.Min(num13, val);
         num14 = Math.Max(num14, val);
     }
     if (num5 != 0)
     {
         memoryStream.Position = (long)(16 * (tops + num6));
         int num17 = binaryReader.ReadInt32();
         int num18 = binaryReader.ReadInt32();
         int num19 = binaryReader.ReadInt32();
         int num20 = binaryReader.ReadInt32();
         int num21 = 0;
         if (num5 >= 5)
         {
             num21 = binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
         }
         MJ1[][] array3 = new MJ1[num7][];
         int m;
         for (m = 0; m < num17; m++)
         {
             int num22 = binaryReader.ReadInt32();
             array3[m] = new MJ1[]
             {
                 array2[num22]
             };
         }
         if (num5 >= 2)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int n = 0;
             while (n < num18)
             {
                 int num23 = binaryReader.ReadInt32();
                 int num24 = binaryReader.ReadInt32();
                 array3[m] = new MJ1[]
                 {
                     array2[num23],
                     array2[num24]
                 };
                 n++;
                 m++;
             }
         }
         if (num5 >= 3)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int num25 = 0;
             while (num25 < num19)
             {
                 int num26 = binaryReader.ReadInt32();
                 int num27 = binaryReader.ReadInt32();
                 int num28 = binaryReader.ReadInt32();
                 array3[m] = new MJ1[]
                 {
                     array2[num26],
                     array2[num27],
                     array2[num28]
                 };
                 num25++;
                 m++;
             }
         }
         if (num5 >= 4)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int num29 = 0;
             while (num29 < num20)
             {
                 int num30 = binaryReader.ReadInt32();
                 int num31 = binaryReader.ReadInt32();
                 int num32 = binaryReader.ReadInt32();
                 int num33 = binaryReader.ReadInt32();
                 array3[m] = new MJ1[]
                 {
                     array2[num30],
                     array2[num31],
                     array2[num32],
                     array2[num33]
                 };
                 num29++;
                 m++;
             }
         }
         if (num5 >= 5)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int num34 = 0;
             while (num34 < num21)
             {
                 int num35 = binaryReader.ReadInt32();
                 int num36 = binaryReader.ReadInt32();
                 int num37 = binaryReader.ReadInt32();
                 int num38 = binaryReader.ReadInt32();
                 int num39 = binaryReader.ReadInt32();
                 array3[m] = new MJ1[]
                 {
                     array2[num35],
                     array2[num36],
                     array2[num37],
                     array2[num38],
                     array2[num39]
                 };
                 num34++;
                 m++;
             }
         }
         for (int num40 = num13; num40 <= num14; num40++)
         {
         }
         body1e.alalni = array3;
     }
     return body1e;
 }
示例#2
0
 public ParseVIF1(VU1Mem vu1)
 {
     this.vu1 = vu1;
 }
示例#3
0
 public ParseVIF1(VU1Mem vu1)
 {
     this.vu1 = vu1;
 }
示例#4
0
文件: FormII.cs 项目: Truthkey/OpenKH
 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();
             }
         }
     }
 }
示例#5
0
 public static Body1 Sima(VU1Mem vu1mem, Matrix[] Ma, int tops, int top2, int tsel, int[] alaxi, Matrix Mv)
 {
     var memoryStream = new MemoryStream(vu1mem.vumem, true);
     var binaryReader = new BinaryReader(memoryStream);
     memoryStream.Position = 16*tops;
     int num = binaryReader.ReadInt32();
     if (num != 1 && num != 2)
     {
         throw new ProtInvalidTypeException();
     }
     binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     int num2 = binaryReader.ReadInt32();
     int num3 = binaryReader.ReadInt32();
     int num4 = binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     if (num == 1)
     {
         binaryReader.ReadInt32();
     }
     if (num == 1)
     {
         binaryReader.ReadInt32();
     }
     int num5 = (num == 1) ? binaryReader.ReadInt32() : 0;
     int num6 = (num == 1) ? binaryReader.ReadInt32() : 0;
     int num7 = binaryReader.ReadInt32();
     int num8 = binaryReader.ReadInt32();
     binaryReader.ReadInt32();
     int num9 = binaryReader.ReadInt32();
     memoryStream.Position = 16*(tops + num4);
     var array = new int[num9];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = binaryReader.ReadInt32();
     }
     var body = new Body1();
     body.t = tsel;
     body.alvert = new Vector3[num7];
     body.avail = (num5 == 0 && num == 1);
     var array2 = new Vector3[num7];
     int num10 = 0;
     memoryStream.Position = 16*(tops + num8);
     for (int j = 0; j < array.Length; j++)
     {
         Matrix transformation = Ma[alaxi[j]]*Mv;
         int num11 = array[j];
         int k = 0;
         while (k < num11)
         {
             float x = binaryReader.ReadSingle();
             float y = binaryReader.ReadSingle();
             float z = binaryReader.ReadSingle();
             float w = binaryReader.ReadSingle();
             var coordinate = new Vector3(x, y, z);
             Vector3 vector = Vector3.TransformCoordinate(coordinate, transformation);
             body.alvert[num10] = vector;
             var vector2 = new Vector4(x, y, z, w);
             Vector4 vector3 = Vector4.Transform(vector2, transformation);
             array2[num10] = new Vector3(vector3.X, vector3.Y, vector3.Z);
             k++;
             num10++;
         }
     }
     body.aluv = new Vector2[num2];
     body.alvi = new int[num2];
     body.alfl = new int[num2];
     memoryStream.Position = 16*(tops + num3);
     for (int l = 0; l < num2; l++)
     {
         int num12 = binaryReader.ReadUInt16()/16;
         binaryReader.ReadUInt16();
         int num13 = binaryReader.ReadUInt16()/16;
         binaryReader.ReadUInt16();
         body.aluv[l] = new Vector2(num12/256f, num13/256f);
         body.alvi[l] = binaryReader.ReadUInt16();
         binaryReader.ReadUInt16();
         body.alfl[l] = binaryReader.ReadUInt16();
         binaryReader.ReadUInt16();
     }
     if (num5 != 0)
     {
         memoryStream.Position = 16*(tops + num6);
         int num14 = binaryReader.ReadInt32();
         int num15 = binaryReader.ReadInt32();
         int num16 = binaryReader.ReadInt32();
         int num17 = binaryReader.ReadInt32();
         int num18 = 0;
         if (num5 >= 5)
         {
             num18 = binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
         }
         var array3 = new Vector3[num7];
         int m;
         for (m = 0; m < num14; m++)
         {
             int num19 = binaryReader.ReadInt32();
             array3[m] = body.alvert[num19];
         }
         if (num5 >= 2)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int n = 0;
             while (n < num15)
             {
                 int num20 = binaryReader.ReadInt32();
                 int num21 = binaryReader.ReadInt32();
                 array3[m] = array2[num20] + array2[num21];
                 n++;
                 m++;
             }
         }
         if (num5 >= 3)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int num22 = 0;
             while (num22 < num16)
             {
                 int num23 = binaryReader.ReadInt32();
                 int num24 = binaryReader.ReadInt32();
                 int num25 = binaryReader.ReadInt32();
                 array3[m] = array2[num23] + array2[num24] + array2[num25];
                 num22++;
                 m++;
             }
         }
         if (num5 >= 4)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int num26 = 0;
             while (num26 < num17)
             {
                 int num27 = binaryReader.ReadInt32();
                 int num28 = binaryReader.ReadInt32();
                 int num29 = binaryReader.ReadInt32();
                 int num30 = binaryReader.ReadInt32();
                 array3[m] = array2[num27] + array2[num28] + array2[num29] + array2[num30];
                 num26++;
                 m++;
             }
         }
         if (num5 >= 5)
         {
             memoryStream.Position = (memoryStream.Position + 15L & -16L);
             int num31 = 0;
             while (num31 < num18)
             {
                 int num32 = binaryReader.ReadInt32();
                 int num33 = binaryReader.ReadInt32();
                 int num34 = binaryReader.ReadInt32();
                 int num35 = binaryReader.ReadInt32();
                 int num36 = binaryReader.ReadInt32();
                 array3[m] = array2[num32] + array2[num33] + array2[num34] + array2[num35] + array2[num36];
                 num31++;
                 m++;
             }
         }
         body.alvert = array3;
     }
     return body;
 }
示例#6
0
文件: Visf.cs 项目: Truthkey/OpenKH
 private void p1_Load(object sender, EventArgs e)
 {
     this.p3D = new Direct3D();
     this.alDeleter.Add(this.p3D);
     this.device = new Device(this.p3D, 0, DeviceType.Hardware, this.p1.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[]
     {
         this.PP
     });
     this.alDeleter.Add(this.device);
     this.device.SetRenderState(RenderState.Lighting, false);
     this.device.SetRenderState(RenderState.ZEnable, true);
     this.device.SetRenderState(RenderState.AlphaTestEnable, true);
     this.device.SetRenderState(RenderState.AlphaRef, 2);
     this.device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.GreaterEqual);
     this.device.SetRenderState(RenderState.AlphaBlendEnable, true);
     this.device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
     this.device.SetRenderState<Blend>(RenderState.SourceBlendAlpha, Blend.SourceAlpha);
     this.device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
     this.device.SetRenderState<Blend>(RenderState.DestinationBlendAlpha, Blend.InverseSourceAlpha);
     this.device.SetRenderState<Cull>(RenderState.CullMode, Cull.Counterclockwise);
     this.device.SetRenderState(RenderState.FogColor, this.p1.BackColor.ToArgb());
     this.device.SetRenderState(RenderState.FogStart, 5f);
     this.device.SetRenderState(RenderState.FogEnd, 30000f);
     this.device.SetRenderState(RenderState.FogDensity, 0.0001f);
     this.device.SetRenderState<FogMode>(RenderState.FogVertexMode, FogMode.Exponential);
     this.p1.MouseWheel += new MouseEventHandler(this.p1_MouseWheel);
     List<CustomVertex.PositionColoredTextured> list = new List<CustomVertex.PositionColoredTextured>();
     foreach (DC current in this.aldc)
     {
         ToolStripButton toolStripButton = new ToolStripButton("Show " + current.name);
         toolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Text;
         toolStripButton.CheckOnClick = true;
         toolStripButton.Tag = current.dcId;
         toolStripButton.Checked = true;
         toolStripButton.CheckedChanged += new EventHandler(this.tsiIfRender_CheckedChanged);
         this.toolStrip1.Items.Insert(this.toolStrip1.Items.IndexOf(this.tsbShowColl), toolStripButton);
     }
     this.alci.Clear();
     this.altex.Clear();
     int[] array = new int[4];
     int num = 0;
     foreach (DC current2 in this.aldc)
     {
         int count = this.altex.Count;
         Bitmap[] pics = current2.o7.pics;
         for (int i = 0; i < pics.Length; i++)
         {
             Bitmap bitmap = pics[i];
             MemoryStream memoryStream = new MemoryStream();
             bitmap.Save(memoryStream, ImageFormat.Png);
             memoryStream.Position = 0L;
             Texture item;
             this.altex.Add(item = Texture.FromStream(this.device, memoryStream));
             this.alDeleter.Add(item);
         }
         if (current2.o4Mdlx != null)
         {
             using (SortedDictionary<int, Parse4Mdlx.Model>.Enumerator enumerator3 = current2.o4Mdlx.dictModel.GetEnumerator())
             {
                 while (enumerator3.MoveNext())
                 {
                     KeyValuePair<int, Parse4Mdlx.Model> current3 = enumerator3.Current;
                     Visf.CI cI = new Visf.CI();
                     int count2 = list.Count;
                     Parse4Mdlx.Model value = current3.Value;
                     list.AddRange(value.alv);
                     List<uint> list2 = new List<uint>();
                     for (int j = 0; j < value.alv.Count; j++)
                     {
                         list2.Add((uint)(count2 + j));
                     }
                     cI.ali = list2.ToArray();
                     cI.texi = count + current3.Key;
                     cI.vifi = 0;
                     this.alci.Add(cI);
                 }
                 goto IL_75D;
             }
             goto IL_3C9;
         }
         goto IL_3C9;
         IL_75D:
         this.alalci.Add(this.alci.ToArray());
         this.alci.Clear();
         continue;
         IL_3C9:
         if (current2.o4Map != null)
         {
             for (int k = 0; k < current2.o4Map.alvifpkt.Count; k++)
             {
                 Vifpli vifpli = current2.o4Map.alvifpkt[k];
                 byte[] vifpkt = vifpli.vifpkt;
                 VU1Mem vu = new VU1Mem();
                 ParseVIF1 parseVIF = new ParseVIF1(vu);
                 parseVIF.Parse(new MemoryStream(vifpkt, false), 0);
                 foreach (byte[] current4 in parseVIF.almsmem)
                 {
                     Visf.CI cI2 = new Visf.CI();
                     MemoryStream memoryStream2 = new MemoryStream(current4, false);
                     BinaryReader binaryReader = new BinaryReader(memoryStream2);
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     int num2 = binaryReader.ReadInt32();
                     int num3 = binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     int num4 = binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     int num5 = binaryReader.ReadInt32();
                     List<uint> list3 = new List<uint>();
                     int count3 = list.Count;
                     for (int l = 0; l < num2; l++)
                     {
                         memoryStream2.Position = (long)(16 * (num3 + l));
                         int num6 = (int)binaryReader.ReadInt16();
                         binaryReader.ReadInt16();
                         int num7 = (int)binaryReader.ReadInt16();
                         binaryReader.ReadInt16();
                         int num8 = (int)binaryReader.ReadInt16();
                         binaryReader.ReadInt16();
                         int num9 = (int)binaryReader.ReadInt16();
                         binaryReader.ReadInt16();
                         memoryStream2.Position = (long)(16 * (num5 + num8));
                         Vector3 v;
                         v.X = -binaryReader.ReadSingle();
                         v.Y = binaryReader.ReadSingle();
                         v.Z = binaryReader.ReadSingle();
                         memoryStream2.Position = (long)(16 * (num4 + l));
                         int num10 = (int)((byte)binaryReader.ReadUInt32());
                         int num11 = (int)((byte)binaryReader.ReadUInt32());
                         int num12 = (int)((byte)binaryReader.ReadUInt32());
                         int num13 = (int)((byte)binaryReader.ReadUInt32());
                         if (num4 == 0)
                         {
                             num10 = 255;
                             num11 = 255;
                             num12 = 255;
                             num13 = 255;
                         }
                         array[num & 3] = count3 + l;
                         num++;
                         if (num9 != 0 && num9 != 16)
                         {
                             if (num9 == 32)
                             {
                                 list3.Add(Convert.ToUInt32(array[num - 1 & 3]));
                                 list3.Add(Convert.ToUInt32(array[num - 2 & 3]));
                                 list3.Add(Convert.ToUInt32(array[num - 3 & 3]));
                             }
                             else
                             {
                                 if (num9 == 48)
                                 {
                                     list3.Add(Convert.ToUInt32(array[num - 1 & 3]));
                                     list3.Add(Convert.ToUInt32(array[num - 3 & 3]));
                                     list3.Add(Convert.ToUInt32(array[num - 2 & 3]));
                                 }
                             }
                         }
                         Color color = Color.FromArgb((int)this.lm.al[num13], (int)this.lm.al[num10], (int)this.lm.al[num11], (int)this.lm.al[num12]);
                         CustomVertex.PositionColoredTextured item2 = new CustomVertex.PositionColoredTextured(v, color.ToArgb(), (float)num6 / 16f / 256f, (float)num7 / 16f / 256f);
                         list.Add(item2);
                     }
                     cI2.ali = list3.ToArray();
                     cI2.texi = count + vifpli.texi;
                     cI2.vifi = k;
                     this.alci.Add(cI2);
                 }
             }
             goto IL_75D;
         }
         goto IL_75D;
     }
     if (this.alalci.Count != 0)
     {
         this.alci.Clear();
         this.alci.AddRange(this.alalci[0]);
     }
     if (list.Count == 0)
     {
         list.Add(default(CustomVertex.PositionColoredTextured));
     }
     this.vb = new VertexBuffer(this.device, (this.cntVerts = list.Count) * CustomVertex.PositionColoredTextured.Size, Usage.Points, CustomVertex.PositionColoredTextured.Format, Pool.Managed);
     this.alDeleter.Add(this.vb);
     DataStream dataStream = this.vb.Lock(0, 0, LockFlags.None);
     try
     {
         foreach (CustomVertex.PositionColoredTextured current5 in list)
         {
             dataStream.Write<CustomVertex.PositionColoredTextured>(current5);
         }
     }
     finally
     {
         this.vb.Unlock();
     }
     this.lCntVert.Text = this.cntVerts.ToString("#,##0");
     int num14 = 0;
     this.alib.Clear();
     int num15 = 0;
     foreach (Visf.CI[] current6 in this.alalci)
     {
         Visf.CI[] array2 = current6;
         for (int i = 0; i < array2.Length; i++)
         {
             Visf.CI cI3 = array2[i];
             if (cI3.ali.Length != 0)
             {
                 IndexBuffer indexBuffer = new IndexBuffer(this.device, 4 * cI3.ali.Length, Usage.None, Pool.Managed, false);
                 num14 += cI3.ali.Length;
                 this.alDeleter.Add(indexBuffer);
                 DataStream dataStream2 = indexBuffer.Lock(0, 0, LockFlags.None);
                 try
                 {
                     uint[] ali = cI3.ali;
                     for (int m = 0; m < ali.Length; m++)
                     {
                         uint value2 = ali[m];
                         dataStream2.Write<uint>(value2);
                     }
                 }
                 finally
                 {
                     indexBuffer.Unlock();
                 }
                 Visf.RIB rIB = new Visf.RIB();
                 rIB.ib = indexBuffer;
                 rIB.cnt = cI3.ali.Length;
                 rIB.texi = cI3.texi;
                 rIB.vifi = cI3.vifi;
                 rIB.name = this.aldc[num15].name;
                 rIB.dcId = this.aldc[num15].dcId;
                 this.alib.Add(rIB);
             }
             else
             {
                 Visf.RIB rIB2 = new Visf.RIB();
                 rIB2.ib = null;
                 rIB2.cnt = 0;
                 rIB2.texi = cI3.texi;
                 rIB2.vifi = cI3.vifi;
                 rIB2.name = this.aldc[num15].name;
                 rIB2.dcId = this.aldc[num15].dcId;
                 this.alib.Add(rIB2);
             }
         }
         num15++;
     }
     this.lCntTris.Text = (num14 / 3).ToString("#,##0");
     foreach (Co2 current7 in this.coll.alCo2)
     {
         this.alpf.Add(this.putb.Add(current7));
     }
     if (this.putb.alv.Count != 0)
     {
         this.pvi = new Putvi(this.putb, this.device);
     }
     Console.Write("");
 }