Made a revision of the chunk structure. I quickly realized I wanted to read the data into a generic hierarchy structure, without worrying about what any of the data actually meant. Then I can go through the structure and turn it into real model data. This is something the .b3d format does not allow.
Here's my GMF node reader. It returns a TGMFNode, and then you can read each node's data to see what is actually contained:
Here's my GMF node reader. It returns a TGMFNode, and then you can read each node's data to see what is actually contained:
Type TGMFNode Field name:String Field size:Int Field data:TStream Field subnodes:TGMFNode[] Function Read:TGMFNode(stream:TStream,parent:TGMFNode=Null) Local node:TGMFNode Local subnodes:Int Local n Local bank:TBank If stream.Eof() Return node=New TGMFNode node.name=stream.ReadString(4) subnode_count=stream.ReadInt() Local subnodes_:TGMFNode[subnode_count] node.subnodes=subnodes_ node.size=stream.ReadInt() bank=CreateBank(node.size) stream.readbytes bank.buf(),node.size node.data=CreateBankStream(bank) For n=0 To subnode_count-1 node.subnodes[n]=Read(stream,node) Next Return node EndFunction Method Write(stream:TStream) stream.WriteString name stream.WriteInt subnodes.length stream.WriteInt data.size() CopyStream data,stream,data.size() EndMethod EndType Function LoadGMF:TGMFNode(url:Object) Local stream:TStream Local root:TGMFNode stream=ReadStream(url) If Not stream Return root=TGMFNode.Read(stream) stream.close() Return root EndFunction