public FoamModel(string Name, FoamFlags Flags, FoamMesh[] Meshes, FoamBone[] Bones, FoamAnimation[] Animations, FoamMaterial[] Materials) { Magic = MAGIC; Version = VERSION; this.Name = Name; this.Flags = Flags; this.Meshes = Meshes; this.Bones = Bones; this.Animations = Animations; this.Materials = Materials; }
public void Read(BinaryReader Reader) { Magic = Reader.ReadInt32(); if (Magic != MAGIC) { throw new Exception("Invalid foam file "); } Version = Reader.ReadInt32(); if (Version != VERSION) { throw new Exception("Unsupported foam version " + Version); } Name = Reader.ReadUTF8String(); Flags = (FoamFlags)Reader.ReadInt32(); Meshes = new FoamMesh[Reader.ReadInt32()]; for (int i = 0; i < Meshes.Length; i++) { Meshes[i] = new FoamMesh(); Meshes[i].Read(Reader); } if (Meshes.Length == 0) { Meshes = null; } // Bones Bones = new FoamBone[Reader.ReadInt32()]; for (int i = 0; i < Bones.Length; i++) { Bones[i].Read(Reader); } if (Bones.Length == 0) { Bones = null; } // Animations Animations = new FoamAnimation[Reader.ReadInt32()]; for (int i = 0; i < Animations.Length; i++) { Animations[i] = new FoamAnimation(); Animations[i].Read(Reader); } if (Animations.Length == 0) { Animations = null; } // Materials Materials = new FoamMaterial[Reader.ReadInt32()]; for (int i = 0; i < Materials.Length; i++) { Materials[i].Read(Reader); } if (Materials.Length == 0) { Materials = null; } // Extensions Extensions = new FoamExtension[Reader.ReadInt32()]; for (int i = 0; i < Extensions.Length; i++) { Extensions[i].Read(Reader); } if (Extensions.Length == 0) { Extensions = null; } }