protected internal override object Read(ContentReader input) { builder.Begin(); // Vertex stride builder.SetVertexStride(input.ReadUInt32()); // Element count var elementCount = input.ReadUInt32(); builder.SetElementCount(elementCount); builder.BeginElements(); // Repeat <element count> for (int i = 0; i < elementCount; i++) { builder.BeginElement(i); // Offset builder.SetElementOffset(input.ReadUInt32()); // Element format builder.SetElementFormat(input.ReadInt32()); // Element usage builder.SetElementUsage(input.ReadInt32()); // Usage index builder.SetElementUsageIndex(input.ReadUInt32()); builder.EndElement(); } builder.EndElements(); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Texture builder.SetTexture(input.ReadString()); // Diffuse color builder.SetDiffuseColor(vector3Reader.Read(input)); // Emissive color builder.SetEmissiveColor(vector3Reader.Read(input)); // Specular color builder.SetSpecularColor(vector3Reader.Read(input)); // Specular power builder.SetSpecularPower(input.ReadSingle()); // Alpha builder.SetAlpha(input.ReadSingle()); // Vertex color enabled builder.SetVertexColorEnabled(input.ReadBoolean()); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Format size var formatSize = input.ReadUInt32(); builder.SetFormatSize(formatSize); // Format builder.SetFormat(input.ReadBytes((int) formatSize)); // Data size var dataSize = input.ReadUInt32(); builder.SetDataSize(dataSize); // Data builder.SetData(input.ReadBytes((int) dataSize)); // Loop start builder.SetLoopStart(input.ReadInt32()); // Loop length builder.SetLoopLength(input.ReadInt32()); // Duration builder.SetDuration(input.ReadInt32()); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); builder.SetValues( input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle(), input.ReadSingle()); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Center builder.SetCenter(vector3Reader.Read(input)); // Radius builder.SetRadius(input.ReadSingle()); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Is 16 bit builder.SetIsSixteenBits(input.ReadBoolean()); // Data size var dataSize = input.ReadUInt32(); builder.SetDataSize(dataSize); // Index data builder.SetIndexData(input.ReadBytes((int) dataSize)); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Count var count = input.ReadUInt32(); builder.SetCount(count); // Repeat <count> for (int i = 0; i < count; i++) { builder.Add(itemReader.Read(input)); } return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Vertex declaration builder.SetVertexDeclaration(vertexDeclarationReader.Read(input)); // Vertex count var vertexCount = input.ReadUInt32(); builder.SetVertexCount(vertexCount); int vertexLength = (int) (vertexCount * builder.GetVertexStride()); // Vertex data builder.SetVertexData(input.ReadBytes(vertexLength)); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Surface format builder.SetSurfaceFormat(input.ReadInt32()); // Witdh builder.SetWidth(input.ReadUInt32()); // Height builder.SetHeight(input.ReadUInt32()); // Mip count var mipCount = input.ReadUInt32(); builder.SetMipCount(mipCount); builder.BeginMips(); // Repeat <mip count> for (int i = 0; i < mipCount; i++) { builder.BeginMip(i); // Data size var dataSize = input.ReadUInt32(); builder.SetMipDataSize(dataSize); // Image data builder.SetMipImageData(input.ReadBytes((int) dataSize)); builder.EndMip(); } builder.EndMips(); return builder.End(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Texture builder.SetTexture(input.ReadObject()); // Glyphs builder.SetGlyphs(input.ReadObject()); // Cropping builder.SetCropping(input.ReadObject()); // Character map builder.SetCharacterMap(input.ReadObject()); // Vertical line spacing builder.SetVerticalLineSpacing(input.ReadInt32()); // Horizontal spacing builder.SetHorizontalSpacing(input.ReadSingle()); // Kerning builder.SetKering(input.ReadObject()); // Default character if (input.ReadBoolean()) { builder.SetDefaultCharacter(input.ReadChar()); } else { builder.SetDefaultCharacter(null); } return builder.End(); }
protected internal override object Read(ContentReader input) { return input.ReadChar(); }
protected internal override object Read(ContentReader input) { builder.Begin(); // Bone count var boneCount = input.ReadUInt32(); builder.SetBoneCount(boneCount); builder.BeginBones(); // Repeat <bone count> for (int i = 0; i < boneCount; i++) { builder.BeginBone(i); // Name builder.SetBoneName(input.ReadObject() as string); // Transform builder.SetBoneTransform(matrixReader.Read(input)); builder.EndBone(); } builder.EndBones(); builder.BeginBoneHierarchies(); // Repeat <bone count>: hierarchy for (int i = 0; i < boneCount; i++) { builder.BeginBoneHierarchy(i); // Parent bone builder.SetBoneHierarchyParentBone(ReadBoneReference(input, (int) boneCount)); // Child bone count var childCount = input.ReadUInt32(); builder.SetBoneHierarchyChildBoneCount(childCount); if (childCount != 0) { builder.BeginBoneHierarchyChildBones(); for (int j = 0; j < childCount; j++) { builder.BeginBoneHierarchyChildBone(j); // Child bone builder.SetBoneHierarchyChildBone(ReadBoneReference(input, (int) boneCount)); builder.EndBoneHierarchyChildBone(); } builder.EndBoneHierarchyChildBones(); } builder.EndBoneHierarchy(); } builder.EndBoneHierarchies(); // Mesh count var meshCount = input.ReadUInt32(); builder.SetMeshCount(meshCount); builder.BeginMeshes(); // Repeat <mesh count> for (int i = 0; i < meshCount; i++) { builder.BeginMesh(i); // Name builder.SetMeshName(input.ReadObject() as string); // Parent bone builder.SetMeshParentBone(ReadBoneReference(input, (int) boneCount)); // BoundingSphere builder.SetMeshBoundingSphere(boundingSphereReader.Read(input)); // Tag builder.SetMeshTag(input.ReadObject()); // Mesh part count var partCount = input.ReadUInt32(); builder.SetMeshPartCount(partCount); builder.BeginMeshParts(); // Repeat <mesh part count> for (int j = 0; j < partCount; j++) { builder.BeginMeshPart(j); // Vertex offset builder.SetMeshPartVertexOffset(input.ReadUInt32()); // Num vertices builder.SetMeshPartNumVertices(input.ReadUInt32()); // Start index builder.SetMeshPartStartIndex(input.ReadUInt32()); // Primitive count builder.SetMeshPartPrimitiveCount(input.ReadUInt32()); // Tag builder.SetMeshPartTag(input.ReadObject()); // Vertex buffer var vertexBufferId = input.ReadSharedResource(builder.GetMeshPartVertexBufferCallback()); builder.SetMeshPartVertexBuffer(vertexBufferId); // Index buffer var indexBufferId = input.ReadSharedResource(builder.GetMeshPartIndexBufferCallback()); builder.SetMeshPartIndexBuffer(indexBufferId); // Effect var effectId = input.ReadSharedResource(builder.GetMeshPartEffectCallback()); builder.SetMeshPartEffect(effectId); builder.EndMeshPart(); } builder.EndMeshParts(); builder.EndMesh(); } builder.EndMeshes(); // Root bone builder.SetRootBone(ReadBoneReference(input, (int) boneCount)); // Tag builder.SetTag(input.ReadObject()); return builder.End(); }
int ReadBoneReference(ContentReader input, int boneCount) { if (boneCount < 255) { return input.ReadByte(); } else { return (int) input.ReadUInt32(); } }
protected internal abstract object Read(ContentReader input);
protected internal override object Read(ContentReader input) { builder.Begin(); // Bone count var boneCount = input.ReadUInt32(); builder.SetBoneCount(boneCount); builder.BeginBones(); // Repeat <bone count> for (int i = 0; i < boneCount; i++) { builder.BeginBone(i); // Name builder.SetBoneName(input.ReadObject() as string); // Transform builder.SetBoneTransform(matrixReader.Read(input)); builder.EndBone(); } builder.EndBones(); builder.BeginBoneHierarchies(); // Repeat <bone count>: hierarchy for (int i = 0; i < boneCount; i++) { builder.BeginBoneHierarchy(i); // Parent bone builder.SetBoneHierarchyParentBone(ReadBoneReference(input, (int)boneCount)); // Child bone count var childCount = input.ReadUInt32(); builder.SetBoneHierarchyChildBoneCount(childCount); if (childCount != 0) { builder.BeginBoneHierarchyChildBones(); for (int j = 0; j < childCount; j++) { builder.BeginBoneHierarchyChildBone(j); // Child bone builder.SetBoneHierarchyChildBone(ReadBoneReference(input, (int)boneCount)); builder.EndBoneHierarchyChildBone(); } builder.EndBoneHierarchyChildBones(); } builder.EndBoneHierarchy(); } builder.EndBoneHierarchies(); // Mesh count var meshCount = input.ReadUInt32(); builder.SetMeshCount(meshCount); builder.BeginMeshes(); // Repeat <mesh count> for (int i = 0; i < meshCount; i++) { builder.BeginMesh(i); // Name builder.SetMeshName(input.ReadObject() as string); // Parent bone builder.SetMeshParentBone(ReadBoneReference(input, (int)boneCount)); // BoundingSphere builder.SetMeshBoundingSphere(boundingSphereReader.Read(input)); // Tag builder.SetMeshTag(input.ReadObject()); // Mesh part count var partCount = input.ReadUInt32(); builder.SetMeshPartCount(partCount); builder.BeginMeshParts(); // Repeat <mesh part count> for (int j = 0; j < partCount; j++) { builder.BeginMeshPart(j); // Vertex offset builder.SetMeshPartVertexOffset(input.ReadUInt32()); // Num vertices builder.SetMeshPartNumVertices(input.ReadUInt32()); // Start index builder.SetMeshPartStartIndex(input.ReadUInt32()); // Primitive count builder.SetMeshPartPrimitiveCount(input.ReadUInt32()); // Tag builder.SetMeshPartTag(input.ReadObject()); // Vertex buffer var vertexBufferId = input.ReadSharedResource(builder.GetMeshPartVertexBufferCallback()); builder.SetMeshPartVertexBuffer(vertexBufferId); // Index buffer var indexBufferId = input.ReadSharedResource(builder.GetMeshPartIndexBufferCallback()); builder.SetMeshPartIndexBuffer(indexBufferId); // Effect var effectId = input.ReadSharedResource(builder.GetMeshPartEffectCallback()); builder.SetMeshPartEffect(effectId); builder.EndMeshPart(); } builder.EndMeshParts(); builder.EndMesh(); } builder.EndMeshes(); // Root bone builder.SetRootBone(ReadBoneReference(input, (int)boneCount)); // Tag builder.SetTag(input.ReadObject()); return(builder.End()); }