public static SkiMaterial Read(BinaryReader r)
		{
			r.ReadBytes(10);
            SkiMaterial skiMaterial = new SkiMaterial
            {
                TrailZero = r.ReadByte(),
                MaterialParamsA = new float[4],
                MaterialParamsB = new float[4],
                MaterialParamsC = new float[4],
                MaterialParamsD = new float[4]
            };
            for (int i = 0; i < 4; i++)
			{
				skiMaterial.MaterialParamsA[i] = r.ReadSingle();
			}
			for (int j = 0; j < 4; j++)
			{
				skiMaterial.MaterialParamsB[j] = r.ReadSingle();
			}
			for (int k = 0; k < 4; k++)
			{
				skiMaterial.MaterialParamsC[k] = r.ReadSingle();
			}
			for (int l = 0; l < 4; l++)
			{
				skiMaterial.MaterialParamsD[l] = r.ReadSingle();
			}
			skiMaterial.Scale = r.ReadSingle();
			skiMaterial.Clothing = r.ReadByte();
			return skiMaterial;
		}
Example #2
0
 public SkiReader(byte[] file)
 {
     this.Bips     = new string[0];
     this.Textures = new string[0];
     using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(file)))
     {
         this.Signature = binaryReader.ReadBytes(8);
         if (this.Signature[0] == 77)
         {
             if (this.Signature[7] == 65)
             {
                 this.SkiType   = binaryReader.ReadUInt32();
                 this.MeshCount = new uint[4];
                 for (int i = 0; i < 4; i++)
                 {
                     this.MeshCount[i] = binaryReader.ReadUInt32();
                 }
                 this.TexturesCount  = binaryReader.ReadUInt32();
                 this.MaterialsCount = binaryReader.ReadUInt32();
                 this.NumBips        = binaryReader.ReadUInt32();
                 this.Unknow2        = binaryReader.ReadUInt32();
                 this.TypeMask       = binaryReader.ReadUInt32();
                 this.UnknowBytes    = binaryReader.ReadBytes(60);
                 if (this.SkiType == 9u)
                 {
                     this.Bips = new string[this.NumBips];
                     int num = 0;
                     while ((long)num < (long)((ulong)this.NumBips))
                     {
                         int    count = binaryReader.ReadInt32();
                         byte[] bytes = binaryReader.ReadBytes(count);
                         this.Bips[num] = Encoding.GetEncoding("GB2312").GetString(bytes);
                         num++;
                     }
                 }
                 this.Textures = new string[this.TexturesCount];
                 int num2 = 0;
                 while ((long)num2 < (long)((ulong)this.TexturesCount))
                 {
                     int    count2 = binaryReader.ReadInt32();
                     byte[] bytes2 = binaryReader.ReadBytes(count2);
                     this.Textures[num2] = Encoding.GetEncoding("GB2312").GetString(bytes2).Replace(".DDS", ".dds");
                     num2++;
                 }
                 this.Materials = new SkiMaterial[this.MaterialsCount];
                 int num3 = 0;
                 while ((long)num3 < (long)((ulong)this.MaterialsCount))
                 {
                     this.Materials[num3] = SkiMaterial.Read(binaryReader);
                     num3++;
                 }
                 if (this.MeshCount[0] != 0u)
                 {
                     this.Object = new MeshObject[this.MeshCount[0]];
                     int num4 = 0;
                     while ((long)num4 < (long)((ulong)this.MeshCount[0]))
                     {
                         this.Object[num4] = MeshObject.Read(binaryReader, 0);
                         num4++;
                     }
                 }
                 else
                 {
                     this.Object    = new MeshObject[1];
                     this.Object[0] = MeshObject.Read(binaryReader, 1);
                 }
                 return;
             }
         }
         throw new Exception("Its no ski format");
     }
 }