3D-Studio File Format (.3ds) Autodesk Ltd. Document Revision 0.93 - January 1997 Rewritten by Martin van Velsen (email: vvelsen@ronix.ptf.hro.nl ) and Robin Fercoq ( 3ds-bin + mli )(email: robin@msrwww.fc-net.fr) Based on documentation by Jim Pitts ( email: jim@micronetics.com ) Source update provided by: Albert Szilvasy (email: szilvasy@almos.vein.hu ) A lot of the chunks are still undocumented if you know what they do please email me Martin van Velsen, Robin Feroq or Jimm Pitts. As I get more information on the file format, I will document it for everyone to see. I will post this regurlarly to alt.3d and alt.3d-studio and I can be contacted there if my email does not work. (Also see the 3d-studio material .mli documentation by Robin Feroq.) Disclaimer. This document describes the file format of the 3ds files generated by 3d-studio by Autodesk. By using the information contained within, you agree not to hold any of the authors liable if, from its use, you f^Hmuck something up. OK? Autodesk has at not yet released the offical specifications of the 3d-studio formats. You will therefor receive NO support from Autodesk or any company related to Autodesk concerning the nature and contents of the 3d-studio binary .3ds and .mli formats. A warning beforehand. This docs describes the format of 3ds files produced by version 3.0 and higher of 3d-studio. You can find this version information at byte 29 in the binary file. This document can be found on the regular newsgroups: alt.3d and alt.3d-studio It can also be found at: "http://www.mediatel.lu" ------------------------------------------------------------------------- Contents 1. Introduction 2. Chunks anyone ? 3. 3D Editor chunks 4. Keyframer chunks 5. CODE 1. Introduction ====================== The 3ds file format is made up of chunks. They describe what information is to follow and what it is made up of, it's ID and the location of the next block. If you don't understand a chunk you can quite simply skip it. The next chunk pointer is relative to the start of the current chunk and in bytes. The binary information in the 3ds file is written in a special kind of way. Namely the lest significant byte comes first in an int. For example: 4A 5C (2 bytes in hex) would be 5C high byte and 4A low byte. In a long it is: 4A 5C 3B 8F where 5C4A is the low word and 8F 3B is the high word. And now for the chunks. A chunk is defined as: start end size name 0 1 2 Chunk ID 2 5 4 Pointer to next chunk relative to the place where Chunk ID is, in other words the length of the chunk Chunks have a hierarchy imposed on them that is identified byt it's ID. A 3ds file has the Primary chunk ID 4D4Dh. This is always the first chunk of the file. Within the primary chunk are the main chunks. to give you a preview and a reference to the hierarchy of chunks, below is a diagram to show the diffrent chunk ID's and their place in the file. The chunks are given a name because below the diagram is a list which defines the names to the actual chunk id's. This makes it easier to put it in some source code ( how convenient that some sample code is included ) MAIN3DS (0x4D4D) | +--EDIT3DS (0x3D3D) | | | +--EDIT_MATERIAL (0xAFFF) | | | | | +--MAT_NAME01 (0xA000) (See mli Doc) | | | +--EDIT_CONFIG1 (0x0100) | +--EDIT_CONFIG2 (0x3E3D) | +--EDIT_VIEW_P1 (0x7012) | | | | | +--TOP (0x0001) | | +--BOTTOM (0x0002) | | +--LEFT (0x0003) | | +--RIGHT (0x0004) | | +--FRONT (0x0005) | | +--BACK (0x0006) | | +--USER (0x0007) | | +--CAMERA (0xFFFF) | | +--LIGHT (0x0009) | | +--DISABLED (0x0010) | | +--BOGUS (0x0011) | | | +--EDIT_VIEW_P2 (0x7011) | | | | | +--TOP (0x0001) | | +--BOTTOM (0x0002) | | +--LEFT (0x0003) | | +--RIGHT (0x0004) | | +--FRONT (0x0005) | | +--BACK (0x0006) | | +--USER (0x0007) | | +--CAMERA (0xFFFF) | | +--LIGHT (0x0009) | | +--DISABLED (0x0010) | | +--BOGUS (0x0011) | | | +--EDIT_VIEW_P3 (0x7020) | +--EDIT_VIEW1 (0x7001) | +--EDIT_BACKGR (0x1200) | +--EDIT_AMBIENT (0x2100) | +--EDIT_OBJECT (0x4000) | | | | | +--OBJ_TRIMESH (0x4100) | | | | | | | +--TRI_VERTEXL (0x4110) | | | +--TRI_VERTEXOPTIONS (0x4111) | | | +--TRI_MAPPINGCOORS (0x4140) | | | +--TRI_MAPPINGSTANDARD (0x4170) | | | +--TRI_FACEL1 (0x4120) | | | | | | | | | +--TRI_SMOOTH (0x4150) | | | | +--TRI_MATERIAL (0x4130) | | | | | | | +--TRI_LOCAL (0x4160) | | | +--TRI_VISIBLE (0x4165) | | | | | +--OBJ_LIGHT (0x4600) | | | | | | | +--LIT_OFF (0x4620) | | | +--LIT_SPOT (0x4610) | | | +--LIT_UNKNWN01 (0x465A) | | | | | +--OBJ_CAMERA (0x4700) | | | | | | | +--CAM_UNKNWN01 (0x4710) | | | +--CAM_UNKNWN02 (0x4720) | | | | | +--OBJ_UNKNWN01 (0x4710) | | +--OBJ_UNKNWN02 (0x4720) | | | +--EDIT_UNKNW01 (0x1100) | +--EDIT_UNKNW02 (0x1201) | +--EDIT_UNKNW03 (0x1300) | +--EDIT_UNKNW04 (0x1400) | +--EDIT_UNKNW05 (0x1420) | +--EDIT_UNKNW06 (0x1450) | +--EDIT_UNKNW07 (0x1500) | +--EDIT_UNKNW08 (0x2200) | +--EDIT_UNKNW09 (0x2201) | +--EDIT_UNKNW10 (0x2210) | +--EDIT_UNKNW11 (0x2300) | +--EDIT_UNKNW12 (0x2302) | +--EDIT_UNKNW13 (0x2000) | +--EDIT_UNKNW14 (0xAFFF) | +--KEYF3DS (0xB000) | +--KEYF_UNKNWN01 (0xB00A) +--............. (0x7001) ( viewport, same as editor ) +--KEYF_FRAMES (0xB008) +--KEYF_UNKNWN02 (0xB009) +--KEYF_OBJDES (0xB002) | +--KEYF_OBJHIERARCH (0xB010) +--KEYF_OBJDUMMYNAME (0xB011) +--KEYF_OBJUNKNWN01 (0xB013) +--KEYF_OBJUNKNWN02 (0xB014) +--KEYF_OBJUNKNWN03 (0xB015) +--KEYF_OBJPIVOT (0xB020) +--KEYF_OBJUNKNWN04 (0xB021) +--KEYF_OBJUNKNWN05 (0xB022) A chunk type which you can find all through the file are the color chunks which are called: COL_RGB COL_TRU COL_UNK 2. Chunks anyone ? ========================= Now for the actual numbers, as you will see I used the define, because I ripped that part right out of my code. Be carefull however because there are a lot of new chunk types which were not documented in the original paper by Jim Pitts. //>------ Primary chunk #define MAIN3DS 0x4D4D //>------ Main Chunks #define EDIT3DS 0x3D3D // this is the start of the editor config #define KEYF3DS 0xB000 // this is the start of the keyframer config //>------ sub defines of EDIT3DS #define EDIT_MATERIAL 0xAFFF #define EDIT_CONFIG1 0x0100 #define EDIT_CONFIG2 0x3E3D #define EDIT_VIEW_P1 0x7012 #define EDIT_VIEW_P2 0x7011 #define EDIT_VIEW_P3 0x7020 #define EDIT_VIEW1 0x7001 #define EDIT_BACKGR 0x1200 #define EDIT_AMBIENT 0x2100 #define EDIT_OBJECT 0x4000 #define EDIT_UNKNW01 0x1100 #define EDIT_UNKNW02 0x1201 #define EDIT_UNKNW03 0x1300 #define EDIT_UNKNW04 0x1400 #define EDIT_UNKNW05 0x1420 #define EDIT_UNKNW06 0x1450 #define EDIT_UNKNW07 0x1500 #define EDIT_UNKNW08...
Amiga78