Пример #1
0
		/// <summary>
		/// Parse binary block.
		/// </summary>
		public Managed Parse(BinaryParser parser)
		{
			var material = this.context.Resolve<Material>();
			material.NameHash = parser.ConsumeUInt32();

			var isShort = parser.ConsumeBool();

			material.Flags = parser.ConsumeUInt32();

			if (!isShort)
			{
				material.ZDepthOfs = parser.ConsumeInt16();
				material.ZDepthOfsHW = parser.ConsumeInt16();
				material.ColEmissive = parser.ConsumeColor();
				material.ColAmbient = parser.ConsumeColor();
				material.ColDiffuse = parser.ConsumeColor();
				Color specular = parser.ConsumeColor();
				material.ColSpecular = specular;
				material.SpecularPower = specular.A;
				parser.Expect((uint)4);
			}
			material.Texture0.HashReference = parser.ConsumeUInt32();
			if (!isShort)
			{
				material.Texture1.HashReference = parser.ConsumeUInt32();
				material.Texture2.HashReference = parser.ConsumeUInt32();
				material.Texture3.HashReference = parser.ConsumeUInt32();

				var animated = parser.ConsumeBool();
				if (animated)
				{
					material.MatAnim = new MatAnim();
					parser.Expect(0);
					material.MatAnim.CelNum = parser.ConsumeByte();
					material.MatAnim.CelNumU = parser.ConsumeByte();
					material.MatAnim.CelW = parser.ConsumeByte();
					material.MatAnim.CelH = parser.ConsumeByte();
					material.MatAnim.CelPeriod = parser.ConsumeByte();
				}
				material.AlphaTestValue = parser.ConsumeByte();
				material.ShaderTechnique.HashReference = parser.ConsumeUInt32();
			}
			return material;
		}
Пример #2
0
		/// <summary>
		/// Parse binary block.
		/// </summary>
		public Managed Parse(BinaryParser parser)
		{
			var texture = this.context.Resolve<Texture>();
			texture.NameHash = parser.ConsumeUInt32();
			texture.Flags = parser.ConsumeUInt32();
			texture.FormatSW = (ImageFormat)parser.ConsumeByte();
			texture.FormatHW = (ImageFormat)parser.ConsumeByte();

			float x = parser.ConsumeFloat();
			float y = parser.ConsumeFloat();
			texture.UVScale = new Vector2(x, y);

			texture.Image = this.ParseImage(parser);

			var e = parser.ConsumeBool();
			//parser.Expect(false);

			return texture;
		}
Пример #3
0
		/// <summary>
		/// Parse binary block.
		/// </summary>
		public Managed Parse(BinaryParser parser)
		{
			var anim = this.context.Resolve<Anim>();
			anim.NameHash = parser.ConsumeUInt32();

			anim.Skeleton.HashReference = parser.ConsumeUInt32();
			var numBones = parser.ConsumeUInt32();
			var boneFlags = parser.ConsumeUInt32();

			for (var numFrames = parser.ConsumeUInt32(); numFrames > 0; --numFrames)
			{
				var frameId = parser.ConsumeUInt32();
				if (frameId == Hash.Get("CIwAnimKeyFrame"))
				{
					var frame = this.context.Resolve<AnimKeyFrame>();
					parser.Expect((uint)0x0);
					frame.Time = parser.ConsumeFloat();
					var type = parser.ConsumeByte();
					var someVec = parser.ConsumeVector3();
					parser.Expect(0x01);

					anim.AddFrame(frame);

					uint num;
					bool b;
					switch (type)
					{
						case 2:
							parser.ConsumeUInt32(); // 0x01FFFFF, 0x01FFFFE
							num = parser.ConsumeUInt32();
							b = parser.ConsumeBool();

							for (uint index = 0; index < num; ++index)
							{
								var bone = frame.Bones[(int)index];
								bone.BindingPos = parser.ConsumeVector3();
								bone.BindingRot = parser.ConsumeQuaternion();
							}
							break;
						case 3:
							parser.ConsumeUInt32(); // 0x00002000, 1
							num = parser.ConsumeUInt32();
							b = parser.ConsumeBool();
							for (uint index = 0; index < num; ++index)
							{
								parser.ConsumeQuaternion();
							}
							break;
						default:
							throw new NotImplementedException();
					}
					continue;
				}
				throw new NotImplementedException();

				//this.m_KeyFrames.Serialise(serialise);
			}
			anim.Duration = parser.ConsumeFloat();
			var aaa = parser.ConsumeUInt32();
			return anim;
			//throw new NotImplementedException();

			//serialise.Fixed(ref this.m_TransformPrecision);
			//serialise.ManagedHash(ref this.m_OfsAnim);
			//serialise.DebugWrite(256);
		}
Пример #4
0
		private void ParseModelBlockCols(BinaryParser parser, Model model, uint name, uint size, uint numItems, ushort flags)
		{
			var streamMesh = (model.Meshes[0]);
			int num = (int)numItems;
			streamMesh.Colors.Clear();
			streamMesh.Colors.Capacity = num;
			if (parser.ConsumeBool())
			{
				for (int i = 0; i < num; ++i)
				{
					byte b = parser.ConsumeByte();
					streamMesh.Colors.Add(Color.FromArgb(255, b, b, b));
				}
			}
			else
			{
				var c = parser.ConsumeByteArray(num * 4);
				for (int i = 0; i < num; ++i)
				{
					streamMesh.Colors.Add(Color.FromArgb(c[i + num * 3], c[i + num * 0], c[i + num * 1], c[i + num * 2]));
				}
			}
		}