public Model(string object_name, uint triangleCount, uint vertexCount, PassthroughGP passGP, TopologyIP topoIP, MaterialGroup matg, Object3D parent) : base(object_name, parent) { this.size = 0; // TODO: Get rid of all referring to things by section ID outside of read/write of model files so we don't have to do this. SectionId = (uint)object_name.GetHashCode(); this.version = 3; this.PassthroughGP = passGP; this.TopologyIP = topoIP; this.RenderAtoms = new List <RenderAtom>(); RenderAtom nmi = new RenderAtom { BaseVertex = 0, TriangleCount = triangleCount, BaseIndex = 0, GeometrySliceLength = vertexCount, MaterialId = 0 }; this.RenderAtoms.Add(nmi); //this.unknown9 = 0; this.MaterialGroup = matg; this.lightset_ID = 0; this.properties_bitmap = 0; this.BoundingRadius = 1; this.unknown13 = 6; this.SkinBones = null; }
public Model(BinaryReader instream, SectionHeader section) : base(instream) { this.RenderAtoms = new List <RenderAtom>(); this.size = section.size; SectionId = section.id; this.version = instream.ReadUInt32(); if (this.version == 6) { this.BoundsMin = instream.ReadVector3(); this.BoundsMax = instream.ReadVector3(); this.v6_unknown7 = instream.ReadSingle(); this.v6_unknown8 = instream.ReadUInt32(); } else { PostLoadRef <PassthroughGP>(instream.ReadUInt32(), i => PassthroughGP = i); PostLoadRef <TopologyIP>(instream.ReadUInt32(), i => TopologyIP = i); var renderAtomCount = instream.ReadUInt32(); for (int x = 0; x < renderAtomCount; x++) { RenderAtom item = new RenderAtom(); item.BaseVertex = instream.ReadUInt32(); item.TriangleCount = instream.ReadUInt32(); item.BaseIndex = instream.ReadUInt32(); item.GeometrySliceLength = instream.ReadUInt32(); item.MaterialId = instream.ReadUInt32(); this.RenderAtoms.Add(item); } //this.unknown9 = instream.ReadUInt32(); PostLoadRef <MaterialGroup>(instream.ReadUInt32(), i => MaterialGroup = i); this.lightset_ID = instream.ReadUInt32(); // this is a section id afaik // Bitmap that stores properties about the model // Bits: // 1: cast_shadows // 3: has_opacity this.properties_bitmap = instream.ReadUInt32(); this.BoundsMin = instream.ReadVector3(); this.BoundsMax = instream.ReadVector3(); this.BoundingRadius = instream.ReadSingle(); this.unknown13 = instream.ReadUInt32(); PostLoadRef <SkinBones>(instream.ReadUInt32(), i => SkinBones = i); } this.remaining_data = null; if ((section.offset + 12 + section.size) > instream.BaseStream.Position) { remaining_data = instream.ReadBytes((int)((section.offset + 12 + section.size) - instream.BaseStream.Position)); } }