diff --git a/code/nel/tools/pipeline/max_dump/info.txt b/code/nel/tools/pipeline/max_dump/info.txt index 5e08801e4..54a3e0e80 100644 --- a/code/nel/tools/pipeline/max_dump/info.txt +++ b/code/nel/tools/pipeline/max_dump/info.txt @@ -151,5 +151,185 @@ SKIPPED: 0 +Chunk Header +As follows: +2 bytes ID, interpretation context (parent) dependent, often refers to a class or version configuration used to parse this chunk +4 bytes Size, most significant bit flags whether the chunk is a container +if Size is 0: 8 bytes Size64, idem meaning Size, support for large files +Scene + + +The Scene stream contains 1 root chunk, with as ID the version that the max file is stored in. +0x2004 3 +0x2006 4 +0x2008 5 +0x2009 6 +? 7 +? 8 +0x200E 9 +0x200F 2008 (10) +? 2009 (11) +0x2012 2010 (12) +? 2011 (13) +? 2012 (14) +? 2013 (15) +The size of this chunk, including the header size, is equal to the size of the Scene stream. + + + + + +max 3 + 0 | 04 20 (id version) + 25 f4 20 80 (size + containerflag) + 00 00 (id) + 40 00 00 80 (size + containerflag) + 35 20 + 0a 00 | ..%.....@...5... + 10 | 00 00 02 00 00 00 01 25 0a 00 00 00 00 00 80 3f | .......%.......? + 20 | 00 25 0e 00 00 00 00 00 00 80 00 00 00 80 02 30 | .%.............0 + 30 | 0a 00 00 00 00 00 00 00 03 30 0e 00 00 00 00 00 | .........0...... + 40 | 00 80 00 00 00 80 01 00 b8 01 00 80 01 00 0a 00 | ................ + 50 | 00 00 0d 00 00 00 05 00 08 00 00 00 06 00 02 00 | ................ + 60 | 20 00 00 80 03 00 0a 00 00 00 00 00 00 00 04 00 | ................ + 70 | 06 00 00 00 00 01 0a 00 00 00 00 00 00 00 02 00 | ................ + 80 | 20 00 00 80 03 00 0a 00 00 00 01 00 00 00 04 00 | ................ + 90 | 06 00 00 00 00 01 0a 00 00 00 00 00 00 00 02 00 | ................ + a0 | 20 00 00 80 03 00 0a 00 00 00 02 00 00 00 04 00 | ................ + b0 | 06 00 00 00 00 01 0a 00 00 00 00 00 80 3f 02 00 | .............?.. + c0 | 20 00 00 80 03 00 0a 00 00 00 03 00 00 00 04 00 | ................ + d0 | 06 00 00 00 00 01 0a 00 00 00 00 00 80 3f 02 00 | .............?.. + e0 | 20 00 00 80 03 00 0a 00 00 00 04 00 00 00 04 00 | ................ + f0 | 06 00 00 00 00 01 0a 00 00 00 00 00 00 00 02 00 | ................ + 100 | 20 00 00 80 03 00 0a 00 00 00 05 00 00 00 04 00 | ................ + 110 | 06 00 00 00 00 01 0a 00 00 00 00 00 00 00 02 00 | ................ + 120 | 20 00 00 80 03 00 0a 00 00 00 06 00 00 00 04 00 | ................ + 130 | 06 00 00 00 00 01 0a 00 00 00 00 00 00 00 02 00 | ................ + 140 | 20 00 00 80 03 00 0a 00 00 00 07 00 00 00 04 00 | ................ + 150 | 06 00 00 00 00 01 0a 00 00 00 00 00 80 3f 02 00 | .............?.. + 160 | 20 00 00 80 03 00 0a 00 00 00 08 00 00 00 04 00 | ................ + + + + + +max 9 (stored under wine) +Scene: + 0 | 0e 20 (id version) + 00 00 00 00 (missing size) + 01 49 + 40 00 00 00 00 80 00 00 | .......I@....... + 10 | 00 00 00 00 d0 00 00 00 00 00 00 80 0b 00 00 00 | ................ + 20 | 00 00 26 00 00 00 00 00 00 00 3c 29 06 5a 1e 0c | ..&.......<).Z.. + 30 | 42 30 60 11 00 00 00 00 00 15 28 23 04 00 01 00 | B0`.......(#.... + 40 | 00 00 0e 00 00 00 00 00 21 00 00 00 00 00 00 00 | ........!....... + 50 | 00 00 04 00 00 00 00 00 82 00 00 00 00 00 40 00 | ..............@. + 60 | 00 00 00 0e 00 00 00 00 00 21 00 00 00 00 00 00 | .........!...... + 70 | 00 01 00 01 00 00 00 00 00 82 00 00 00 00 00 40 | ...............@ + 80 | 00 00 00 00 0e 00 00 00 00 00 21 00 00 00 00 00 | ..........!..... + 90 | 00 00 02 00 04 00 00 00 00 00 82 00 00 00 00 00 | ................ + a0 | 40 00 00 00 00 0e 00 00 00 00 00 21 00 00 00 00 | @..........!.... + b0 | 00 00 00 04 00 09 00 00 00 00 00 + 80 06 00 00 00 | ................ + c0 | 00 40 ff ff ff ff + 0c 00 00 00 00 00 18 00 00 00 | .@.............. + d0 | 00 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 | ................ + e0 | 00 00 00 00 ac 00 00 00 00 00 00 80 34 20 00 00 | ............4... + f0 | 00 00 16 00 00 00 00 00 00 00 00 00 00 00 ff ff | ................ + 100 | ff ff 45 20 00 00 00 00 12 00 00 00 00 00 00 00 | ..E............. + 110 | 00 00 00 00 47 20 00 00 00 00 64 00 00 00 00 00 | ....G.....d..... + 120 | 00 80 48 20 00 00 00 00 24 00 00 00 00 00 00 80 | ..H.....$....... + 130 | 00 27 00 00 00 00 16 00 00 00 00 00 00 00 02 00 | .'.............. + 140 | 00 00 00 00 00 00 49 20 00 00 00 00 24 00 00 00 | ......I.....$... + 150 | 00 00 00 80 00 27 00 00 00 00 16 00 00 00 00 00 | .....'.......... + 160 | 00 00 02 00 00 00 01 00 00 00 4a 20 00 00 00 00 | ..........J..... + 170 | 0e 00 00 00 00 00 00 00 00 10 00 00 00 00 12 00 | ................ + 180 | 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 | ................ + + + +max 2008 (stored under wine) +Scene: + 0 | 0f 20 (id version) + 00 00 00 00 (missing size) + 17 fe 01 00 00 00 00 80 (unknown 64 bits) + 00 00 | ................ + 10 | 00 00 00 00 d0 00 00 00 00 00 00 80 + 0b 00 (id) + 00 00 | ................ + 20 | 00 00 (missing size) + 26 00 00 00 00 00 00 00 (unknown 64 bits) + 3c 29 06 5a 1e 0c | ..&.......<).Z.. + 30 | 42 30 60 11 00 00 00 00 00 17 10 27 04 00 01 00 | B0`........'.... + 40 | 00 00 + 0e 00 00 00 00 00 + 21 00 00 00 00 00 00 00 | ........!....... + 50 | 00 00 04 00 00 00 00 00 82 00 00 00 00 00 40 00 | ..............@. + 60 | 00 00 00 + 0e 00 00 00 00 00 + 21 00 00 00 00 00 00 | .........!...... + 70 | 00 01 00 01 00 00 00 00 00 82 00 00 00 00 00 40 | ...............@ + 80 | 00 00 00 00 + 0e 00 00 00 00 00 + 21 00 00 00 00 00 | ..........!..... + 90 | 00 00 02 00 04 00 00 00 00 00 82 00 00 00 00 00 | ................ + a0 | 40 00 00 00 00 + 0e 00 00 00 00 00 + 21 00 00 00 00 | @..........!.... + b0 | 00 00 00 04 00 09 00 00 00 00 00 + 80 06 00 00 00 | ................ + c0 | 00 40 ff ff ff ff + 0c 00 00 00 00 00 18 00 00 00 | .@.............. + d0 | 00 00 00 00 01 00 00 00 01 00 00 00 11 00 01 00 | ................ + e0 | 00 00 00 00 45 00 00 00 00 00 00 80 34 20 00 00 | ....E.......4... + f0 | 00 00 16 00 00 00 00 00 00 00 00 00 00 00 ff ff | ................ + 100 | ff ff 4b 20 00 00 00 00 0f 00 00 00 00 00 00 00 | ..K............. + 110 | 2e 00 10 00 00 00 00 12 00 00 00 00 00 00 00 00 | ................ + +max 2010 +Scene: + 0 | 12 20 (id version) + 1e 3f 02 80 (size+containerflag) + 00 00 (id) + 98 00 00 80 (size+containerflag) + 0b 00 (id) + 1e 00 | ...?............ + 10 | 00 00 (size 30-6=24) + 3c 29 06 5a 1e 0c 42 30 60 11 00 00 00 00 | ..<).Z..B0`..... + 20 | 00 21 e0 2e 04 00 01 00 00 00 + 0e 00 (id) + 19 00 00 00 (size 25-6=19) + | .!.............. + 30 | 00 00 04 00 00 00 00 00 82 00 00 00 00 00 40 00 | ..............@. + 40 | 00 00 00 + 0e 00 19 00 00 00 + 01 00 01 00 00 00 00 | ................ + 50 | 00 82 00 00 00 00 00 40 00 00 00 00 0e 00 19 00 | .......@........ + 60 | 00 00 02 00 04 00 00 00 00 00 82 00 00 00 00 00 | ................ + 70 | 40 00 00 00 00 + 0e 00 19 00 00 00 + 04 00 09 00 00 | @............... + 80 | 00 00 00 + 80 06 00 00 00 00 40 ff ff ff ff + 0c 00 | .........@...... + 90 | 10 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 | ................ + a0 | 25 00 00 80 34 20 0e 00 00 00 00 00 00 00 ff ff | %...4........... + b0 | ff ff 4b 20 07 00 00 00 2e 00 10 0a 00 00 00 00 | ..K............. + c0 | 00 00 00 00 00 be 03 00 80 35 20 0a 00 00 00 09 | .........5...... + d0 | 00 00 00 4b 20 07 00 00 00 2e 0b 00 1e 00 00 00 | ...K............ + e0 | 59 b4 8a 21 80 89 dc 25 60 11 00 00 00 00 00 21 | Y..!...%`......! + f0 | e0 2e 25 00 03 00 00 00 0e 00 19 00 00 00 00 00 | ..%............. + 100 | 04 00 00 00 01 00 82 00 00 00 00 00 c0 00 00 00 | ................ + 110 | 00 0e 00 15 00 00 00 01 00 0f 00 00 00 40 20 81 | .............@.. + 120 | 10 00 00 00 00 40 0e 00 15 00 00 00 02 00 0f 00 | .....@.......... + 130 | 00 00 40 20 81 10 00 00 00 00 40 0e 00 15 00 00 | ..@.......@..... + 140 | 00 03 00 0f 00 00 00 40 20 81 10 00 00 00 00 40 | .......@.......@ + 150 | 0e 00 15 00 00 00 04 00 0f 00 00 00 40 00 81 10 | ............@... + 160 | 00 00 00 00 40 0e 00 15 00 00 00 05 00 0f 00 00 | ....@........... + 170 | 00 40 00 81 10 00 00 00 00 40 0e 00 15 00 00 00 | .@.......@...... + 180 | 06 00 0f 00 00 00 40 00 81 10 00 00 00 00 40 0e | ......@.......@. + 190 | 00 15 00 00 00 07 00 0f 00 00 00 40 20 81 10 00 | ...........@.... + 1a0 | 00 00 00 40 0e 00 15 00 00 00 08 00 0f 00 00 00 | ...@............ + 1b0 | 40 00 81 10 00 00 00 00 40 0e 00 15 00 00 00 09 | @.......@....... diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 7d5ba3151..9443c4561 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -18,8 +18,10 @@ #include "storage_stream.h" //static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max"; -static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max"; -static const char *streamname = "ClassDirectory3"; +//static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max"; +static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max"; +//static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max"; +static const char *streamname = "Scene"; inline uint8 cleanChar(uint8 c) { @@ -382,10 +384,10 @@ int main(int argc, char **argv) GsfInput *input = gsf_infile_child_by_name(infile, streamname); //gsf_input_dump(input, 1); // just a regular hex dump of this input stream PIPELINE::CStorageStream *instream = new PIPELINE::CStorageStream(input); - //dumpContainer(instream, ""); - PIPELINE::MAX::CStorageContainer ctr; - ctr.serial(instream); - ctr.dump(""); + dumpContainer(instream, ""); + //PIPELINE::MAX::CStorageContainer ctr; + //ctr.serial(instream); + //ctr.dump(""); delete instream; g_object_unref(input); diff --git a/code/nel/tools/pipeline/max_dump/storage_stream.cpp b/code/nel/tools/pipeline/max_dump/storage_stream.cpp index 92d0daecc..e6bfab12e 100644 --- a/code/nel/tools/pipeline/max_dump/storage_stream.cpp +++ b/code/nel/tools/pipeline/max_dump/storage_stream.cpp @@ -122,6 +122,21 @@ bool CStorageStream::enterChunk() chunk->OffsetBegin = CStorageStream::getPos(); serial(chunk->Id); serial(chunk->Size); + chunk->HeaderSize = 6; + if (chunk->Size == 0) + { + // this is a 64bit chunk + uint64 size64; + serial(size64); + chunk->HeaderSize += 8; + bool iscont = (size64 & 0x8000000000000000) == 0x8000000000000000; + size64 &= 0x7FFFFFFFFFFFFFFF; + if (size64 >= 2147483647L) + throw NLMISC::EStream("64bit chunks not supported"); + // downgrade to 32 bit chunk + chunk->Size = (uint32)size64; + if (iscont) chunk->Size |= 0x80000000; + } chunk->Parent = m_CurrentChunk; { // temp memleak fix diff --git a/code/nel/tools/pipeline/max_dump/storage_stream.h b/code/nel/tools/pipeline/max_dump/storage_stream.h index 2e3149583..adf3c5968 100644 --- a/code/nel/tools/pipeline/max_dump/storage_stream.h +++ b/code/nel/tools/pipeline/max_dump/storage_stream.h @@ -54,6 +54,8 @@ struct CChunk CChunk *Parent; std::map Children; + // Size of the chunk header, 6 for 32 bit, 14 for 64 bit + uint8 HeaderSize; // Where the header starts sint32 OffsetBegin; @@ -63,10 +65,10 @@ struct CChunk uint32 Size; inline sint32 getSizeWithHeader() { return (sint32)(Size & 0x7FFFFFFF); } - inline sint32 getSize() { return getSizeWithHeader() - 6; } + inline sint32 getSize() { return getSizeWithHeader() - (sint32)HeaderSize; } inline bool isContainer() { return (Size & 0x80000000) == 0x80000000; } inline sint32 endOfChunk() { return OffsetBegin + getSizeWithHeader(); } - inline sint32 getDataBegin() { return OffsetBegin + 6; } + inline sint32 getDataBegin() { return OffsetBegin + (sint32)HeaderSize; } }; /**