

But we need to recurse the sections most importantlyįLenName=ReadByte f #unsigned - Length of object nameįStrName=readFixedStr f fLenName - get objNameįFileLen=ReadLong f - Length of FILE in bytes We need to recurse all of the FILES present in the package This is a 3D model, not shaders or an offset. Recurse until an instance of "FILE.shaders" or "FILE.offset" is found. For each new section, read PKG section data and recurse. Read the section data and take note of how many sections are present. For each instance of idFILE "FILE" beginning from 0x04, check the length of the objName, retrieve the objName (with 0x00 terminator) Oleg's source makes it really difficult to understand. of those to offset to fNstrips for next section. For each recursive search, determine what the header is, what the name is, then add the sum. Print ("I'm at 0x"+((bit.intAsHex(ftell f))as string)) MessageBox "PKG3 file detected" title:"File type"įSeek f 4 #seek_set - Make sure we're on address 0x04 Print "Angel Studios PacKaGe File Format V3" Str+= bit.intAsChar (ReadByte bstream #unsigned)

Here’s my MAXScript that I need help with (currently it has some bad looping functions, but there are some notes in there to give you an idea of what I need help with): f = fopen "C:\\Program Files (x86)\\Microsoft Games\\Midtown Madness 2\\geometry\\vpbug.pkg" "rb" If I remove my crappy recursive searching functions, it loads the mesh just fine. I can’t seem to get the recursive searching down, since there’s no terminator values and it just keeps reading until it hits the end of the file (which causes errors and results in no mesh). Basically, there’s a bunch of different “FILE” sections which is basically a container for each object for the vehicle (BODY_(H,M,L,VL, WHL(0,1,2,3), etc.).
MIDTOWN MADNESS 2 PKG CODE
I was able to get my basic loading code finished, but now I’ve run into a serious roadblock: Recursively searching. Without a terminator, it jumps straight to the first FILE and then reads everything from there. Basically the file starts out with an identifier, PKG3 (sometimes PKG2, seems to be deprecated for the most part). Since this format is well-documented, I was able to find pseudo-C format information about each FILE section: struct PKGFileData The models, unfortunately, are split into “Sections” or “Strips”, meaning the faces were detached to give them a crisp look in game (since the game doesn’t support anything like smoothing groups). Now here’s where my problem comes in: The PKG file format is what contains 3D models and shaders (information about textures to apply to the object). I capture the vertices and faces into an array and put those into BuildTVFaces to get a basic mesh. It’s well documented and the vertex format is simple enough to understand.

I’m starting out small and working with an older game, Midtown Madness 2. I’d like to start out by saying that I’m very interesting in programming and using languages such as MAXScript to do cool things.
