Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

3ds-Object

A program for displaying 3ds/obj objects and for creating individual bitmap frames.

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

3ds-Object

</br>

Compiler
Components
Description
Last Update

</br>

3ds

3DS is one of the file formats used by the Autodesk 3ds Max 3D modeling, animation and rendering software.

It was the native file format of the old Autodesk 3D Studio DOS (releases 1 to 4), which was popular until its successor (3D Studio MAX 1.0) replaced it in April 1996. Having been around since 1990 (when the first version of 3D Studio DOS was launched), it has grown to become a de facto industry standard for transferring models between 3D programs, or for storing models for 3D resource catalogs (along with OBJ, which is more frequently used as a model archiving file format).

</br>

</br> </br>

While the 3DS format aims to provide an import/export format, retaining only essential geometry, texture and lighting data, the related MAX format (now superseded by the PRJ format) also contains extra information specific to Autodesk 3ds Max, to allow a scene to be completely saved/loaded.

Structure

3ds is a binary file format.

The format is based in chunks, where each section of data is embedded in a block that contains a chunk identifier and the length of the data (to provide the location of the next main block), as well as the data itself. This allows parsers to skip chunks they don't recognize, and allows for extensions to the format.

The chunks form a hierarchical structure, similar to an xml DOM tree. The first two bytes of the chunk are its ID. From that value the parser can identify the chunk and decide whether it will parse it or skip it. The next four bytes contain a little-endian integer that is the length of the chunk, including its data, the length of its sub-blocks and the 6-byte header. The next bytes are the chunk's data, followed by the sub-chunks, in a structure that may extend to several levels deep.

Below is a list of the most common IDs for chunks, represented in a hierarchical fashion depicting their dependencies:

pascal
0x4D4D // Main Chunk
?????? 0x0002 // M3D Version
?????? 0x3D3D // 3D Editor Chunk
???  ?????? 0x4000 // Object Block
???  ???  ?????? 0x4100 // Triangular Mesh
???  ???  ???  ?????? 0x4110 // Vertices List
???  ???  ???  ?????? 0x4120 // Faces Description
???  ???  ???  ???  ?????? 0x4130 // Faces Material
???  ???  ???  ???  ?????? 0x4150 // Smoothing Group List
???  ???  ???  ?????? 0x4140 // Mapping Coordinates List
???  ???  ???  ?????? 0x4160 // Local Coordinates System
???  ???  ?????? 0x4600 // Light
???  ???  ???  ?????? 0x4610 // Spotlight
???  ???  ?????? 0x4700 // Camera
???  ?????? 0xAFFF // Material Block
???     ?????? 0xA000 // Material Name
???     ?????? 0xA010 // Ambient Color
???     ?????? 0xA020 // Diffuse Color
???     ?????? 0xA030 // Specular Color
???     ?????? 0xA200 // Texture Map 1
???     ?????? 0xA230 // Bump Map
???     ?????? 0xA220 // Reflection Map
???        ???  /* Sub Chunks For Each Map */
???        ?????? 0xA300 // Mapping Filename
???        ?????? 0xA351 // Mapping Parameters
?????? 0xB000 // Keyframer Chunk
   ?????? 0xB002 // Mesh Information Block
   ?????? 0xB007 // Spot Light Information Block
   ?????? 0xB008 // Frames (Start and End)
      ?????? 0xB010 // Object Name
      ?????? 0xB013 // Object Pivot Point
      ?????? 0xB020 // Position Track
      ?????? 0xB021 // Rotation Track
      ?????? 0xB022 // Scale Track
      ?????? 0xB030 // Hierarchy Position

</br>

obj

OBJ (or .OBJ) is a geometry definition file format first developed by Wavefront Technologies for The Advanced Visualizer animation package. It is an open file format and has been adopted by other 3D computer graphics application vendors.

The OBJ file format is a simple data-format that represents 3D geometry alone – namely, the position of each vertex, the UV position of each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of vertices, and texture vertices. Vertices are stored in a counter-clockwise order by default, making explicit declaration of face normals unnecessary. OBJ coordinates have no units, but OBJ files can contain scale information in a human readable comment line.

Structure

An OBJ file may contain vertex data, free-form curve/surface attributes, elements, free-form curve/surface body statements, connectivity between free-form surfaces, grouping and display/render attribute information. The most common elements are geometric vertices, texture coordinates, vertex normals and polygonal faces:

</br>

pascal
# List of geometric vertices, with (x, y, z, [w]) coordinates, w is optional and defaults to 1.0.
v 0.123 0.234 0.345 1.0
v ...
...
# List of texture coordinates, in (u, [v, w]) coordinates, these will vary between 0 and 1. v, w are optional and default to 0.
vt 0.500 1 [0]
vt ...
...
# List of vertex normals in (x,y,z) form; normals might not be unit vectors.
vn 0.707 0.000 0.707
vn ...
...
# Parameter space vertices in (u, [v, w]) form; free form geometry statement (see below)
vp 0.310000 3.210000 2.100000
vp ...
...
# Polygonal face element (see below)
f 1 2 3
f 3/1 4/2 5/3
f 6/4/1 3/5/3 7/6/5
f 7//1 8//2 9//3
f ...
...
# Line element (see below)
l 5 8 1 2 4 9

</br>

md2

The MD2 model file format was introduced by id Software when releasing Quake 2 in November 1997. It's a file format quite simple to use and understand. MD2 models' characteristics are these:

  • Model's geometric data (triangles);
  • Frame-by-frame animations;
  • Structured data for drawing the model using GL_TRIANGLE_FAN and GL_TRIANGLE_STRIP primitives (called “OpenGL commands”).

Model's texture is in a separate file. One MD2 model can have only one texture at the same time.

MD2 model file's extension is “md2”. A MD2 file is a binary file divided in two part: the header dans the data. The header contains all information needed to use and manipulate the data.

Variable types used in this document have those sizes:

  • char: 1 byte
  • short: 2 bytes
  • int: 4 bytes
  • float: 4 bytes

They correspond to C type sizes on the x86 architecture. Ensure that type sizes correspond to these ones if you're compiling for another architecture.

Since the MD2 file format is a binary format, you'll have to deal with endianess. MD2 files are stored in little-endian (x86). If you're targetting a big-endian architecture (PowerPC, SPARC, ...), or simply want your program to be portable, you'll have to perform proper conversions for each word or double word read from the file.

Header:

The header is a structure which comes at the beginning of the file:

</br>

cpp
/* MD2 header */
struct md2_header_t
{
  int ident;                  /* magic number: "IDP2" */
  int version;                /* version: must be 8 */

  int skinwidth;              /* texture width */
  int skinheight;             /* texture height */

  int framesize;              /* size in bytes of a frame */

  int num_skins;              /* number of skins */
  int num_vertices;           /* number of vertices per frame */
  int num_st;                 /* number of texture coordinates */
  int num_tris;               /* number of triangles */
  int num_glcmds;             /* number of opengl commands */
  int num_frames;             /* number of frames */

  int offset_skins;           /* offset skin data */
  int offset_st;              /* offset texture coordinate data */
  int offset_tris;            /* offset triangle data */
  int offset_frames;          /* offset frame data */
  int offset_glcmds;          /* offset OpenGL command data */
  int offset_end;             /* offset end of file */
};

</br>

ident is the magic number of the file. It is used to identify the file type. ident must be equal to 844121161 or to the string “IDP2”. We can obtain this number with the expression (('2'<<24) + ('P'<<16) + ('D'<<8) + 'I').

Export Frames

The frames can be exported in various formats. Exactly 360 images are generated for a full rotation to ensure uninterrupted animation.

Formats : BMP, JPG, GIF

Download Free Models:

The project contains over 200 free models that can be used. For more, please refer to the website.

</br>

3ds Viewer :

The 3ds file format is made up of chunks. They describe what information is to follow and what it is made up of, its 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:

pascal
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 by its 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.

functions

  • Export Bitmap
  • Load Texture (Shperical, Mapping)
  • Get Model Data
  • Get Material Data
  • Get Data Errors
  • Edit Ambient Color
  • Edit Diffuse Color
  • Edit Specular Color
  • Edit Background Color
  • Viewing individual parts
  • Shoe Smooth, Flat, Fog

</br>

</br>
</br>

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 )

</br>

pascal
 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)

A chunk type which you can find all through the file are the color chunks which are called:

pascal
   COL_RGB
   COL_TRU
   COL_UNK

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.

pascal
//>------ 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  0x2200
 #define EDIT_UNKNW09  0x2201
 #define EDIT_UNKNW10  0x2210
 #define EDIT_UNKNW11  0x2300
 #define EDIT_UNKNW12  0x2302 
 #define EDIT_UNKNW13  0x3000
 #define EDIT_UNKNW14  0xAFFF

 //>------ sub defines of EDIT_OBJECT
 #define OBJ_TRIMESH   0x4100
 #define OBJ_LIGHT     0x4600
 #define OBJ_CAMERA    0x4700

 #define OBJ_UNKNWN01  0x4010
 #define OBJ_UNKNWN02  0x4012 //>>---- Could be shadow

 //>------ sub defines of OBJ_CAMERA
 #define CAM_UNKNWN01  0x4710 
 #define CAM_UNKNWN02  0x4720 

 //>------ sub defines of OBJ_LIGHT
 #define LIT_OFF       0x4620
 #define LIT_SPOT      0x4610
 #define LIT_UNKNWN01  0x465A

 //>------ sub defines of OBJ_TRIMESH
 #define TRI_VERTEXL   0x4110
 #define TRI_FACEL2    0x4111 
 #define TRI_FACEL1    0x4120
 #define TRI_SMOOTH    0x4150
 #define TRI_LOCAL     0x4160
 #define TRI_VISIBLE   0x4165

 //>>------ sub defs of KEYF3DS

 #define KEYF_UNKNWN01 0xB009
 #define KEYF_UNKNWN02 0xB00A
 #define KEYF_FRAMES   0xB008
 #define KEYF_OBJDES   0xB002

 //>>------  these define the different color chunk types
 #define COL_RGB  0x0010
 #define COL_TRU  0x0011
 #define COL_UNK  0x0013

 //>>------ defines for viewport chunks

 #define TOP           0x0001
 #define BOTTOM        0x0002
 #define LEFT          0x0003
 #define RIGHT         0x0004
 #define FRONT         0x0005
 #define BACK          0x0006
 #define USER          0x0007
 #define CAMERA        0x0008 // 0xFFFF is the actual code read from file
 #define LIGHT         0x0009
 #define DISABLED      0x0010
 #define BOGUS         0x0011

So far for the quick stuff now the more detailed info.

  • Main chunks

  • id

    3D3D Start of Editor data ( this is also the place where the objects are )
    B000 Start of Keyframer data

Directly after a Main chunk is another chunk. This could be any other type of chunk allowable within its main chunks scope. ( see diagram )

  • Subchunks of 3D3D
pascal
 id   Description
 0100  Part of configuration
 1100  unknown
 1200  Background Color
 1201  unknown
 1300  unknown
 1400  unknown
 1420  unknown
 1450  unknown
 1500  unknown
 2100  Ambient Color Block
 2200  fog ?
 2201  fog ?
 2210  fog ?
 2300  unknown
 3000  unknown
 3D3E  Editor configuration main block
 4000  Definition of an Object
 AFFF  Start of material list
  • Subchunks of AFFF - Start of material list
    • Not much is known as of yet, only one chunk can be defined
pascal
id      Description
 A000    Materials name
 A010    unknown
 A020    unknown
 A030    unknown
 A040    unknown
 A041    unknown
 A050    unknown
 A052    unknown
 A053    unknown
 A100    unknown
 A084    unknown
 A087    unknown

A000 - material name

This chunk contains the name of the material which is an ASCIIZ string

  • Subchunks of 3D3E - Editor configuration
pascal
id   Description
 7001  Start of viewport indicator
 7011  Viewport definition ( type 2 )
 7012  Viewport definition ( type 1 )
 7020  Viewport definition ( type 3 )

The 3D3E chunk is a curious one because it contains a lot of redundant data. ( or so it seems ) The most important chunk is 7020. this chunk describes the 4 viewports wich are active in the editor. I assume that U are using the 4 normal viewport layout, because I have not tested it with other configurations. The editor confid will contain 5x chunk 7020 and 5x chunk 7011. only the first 4 7020 chunks are important for how the viewports look like. I guess that the other chunks only give additional info, but I am not sure. The things you are looking for in these chunks is at byte: 6 & 7 ( as offset from the first 6 bytes chunk header and pointer ) these bytes ( unsigned int ) contain the info at to what view is used, with the following id's:

pascal
id    Description
 0001   Top
 0002   Bottom
 0003   Left
 0004   Right
 0005   Front
 0006   Back
 0007   User
 FFFF   Camera
 0009   Light
 0010   Disabled
  • Subchunks of 4000 - Object description Block
    • first item of Subchunk 4000 is an ASCIIZ string of the objects name. ASCIIZ means a string of charakters ended by a zero.
  • Remember an Object can be a Camera a Light or a mesh
pascal
id      Description
 4010     unknown
 4012     shadow ?
 4100     Triangular Polygon List ( Contains only subchunks )
 4600     Light
 4700     Camera

( Mapping:

These chunks are optional. They stand just after the vertex list when the object is mapped. )

  • Subchunks of 4100 - Triangular Polygon List
pascal
 id      Description
 4110     Vertex List
 4111     Vertex Options
 4120     Face List
 4130     Face Material
 4140     Mapping Coordinates
 4150     Face smoothing group
 4160     Translation Matrix
 4165     Object visible/invisble
 4170     Standard Mapping
  • 4110 - Vertex List
pascal
   start end size type          name
   0     1    2   unsigned int  Total vertices in object
   2     5    4   float         X-value
   6     9    4   float         Y-value
  10    13    4   float         Z-value
  • bytes 2..13 are repeated times the total amount of vertices in the object
    • 4111 - Vertex Options
  • First 2 bytes: number of vertices.
  • Then a short int for each vertex:
pascal
 bit 0-7    0
 bit 8-10   x
 bit 11-12  0
 bit 13   vertex selected in selection 3
 bit 14   vertex selected in selection 2
 bit 15   vertex selected in selection 1

bit 8-10 are just like random. From a save to another of the same scene it may change.

Other bits (0-7 and 11-12) have effects on visibility of vertex.

The 4111 chunk can be deleted without much influence, 3ds will still load the file all right.

  • 4120 - Face list
pascal
start end size type          name
 0     1    2   unsigned int  total polygons in object (numpoly)

 2     3    2   unsigned int  number of vertex A
 4     5    2   unsigned int  number of vertex B
 6     7    2   unsigned int  number of vertex C
 8     9    2   unsigned int  face info (*)

repeats 'numpoly' times for each polygon.

The first three ints are the three vertices of the face. 0 stands for the first vertex defined in the vertex list. The order has a purpose: to give the direction for the normal of each face. If you turn a screw (standard screw) in the way the vertices indicate you will find the normal. If vertices given in order are A B C:

pascal
C
^
|
pascal
A----->B

This means unscrewing => the normal points out of the screen.

(*) this number is is a binary number which expands to 3 values. for example 0x0006 would expand to 110 binary. The value should be read as 1 1 0 .This value can be found in 3d-studio ascii files as AB:1 BC:1 AC:0 .Which probably indicated the order of the vertices. For example AB:1 would be a normal line from A to B. But AB:0 would mean a line from B to A.

pascal
     bit 0       AC visibility
     bit 1       BC visibility
     bit 2       AB visibility
     bit 3       Mapping (if there is mapping for this face)
     bit 4-8   0 (not used ?)
     bit 9-10  x (chaotic ???)
     bit 11-12 0 (not used ?)
     bit 13      face selected in selection 3
     bit 14      face selected in selection 2
     bit 15      face selected in selection 1
  • 4130 - Face Material Chunk

If the object is all default material there is no 4130 chunk. In fact, there is one 4130 chunk for each material present on the object.

Each 4130 face material chunks begins with an asciiz of a material, then after the null character is a short int that gives the number of faces of the object concerned by this material, then there is the list itself of these faces. 0000 means the first face of the (4120) face list.

************ Read the Doc on MLI files for more info on **************
************ Mapping and Materials **************

  • 4140 Mapping coordinates.

First 2 bytes: number of vertices.

Then, for each vertex 2 floats that give the mapping coordinates. That is, if a point is at the center of the map it will have 0.5 0.5 as mapping coordinates.

  • 4150 - Face Smoothing Group

nfaces*4bytes

If read as long int, the nth bit indicate if the face belongs or not to the nth smoothing group.

  • 4160 Local axis

Local axis info. The three first blocks of three floats are the definition (in the absolute axis) of the local axis X Y Z of the object. And the last block of three floats is the local center of the object.

  • 4170 Standard mapping

First 2 bytes: type of mapping 0 => plannar or specific (in this case, like mapping from the lofter, the information of this chunk is irrelevant) 1 => cylindrical 2 => spherical

then come 21 floats that describe the mapping.

  • 4600 - Light
pascal
   start end size type   name
   0      3    4  float  Light pos X
   4      7    4  float  Light pos Y
   8     11    4  float  Light pos Z

after this structure check for more chunks.

pascal
   id      Description ( full description later )
  0010     RGB color
  0011     24 bit color
  4610     Light is a Spot light
  4620     Light is off/on ( Boolean )
  • 4610 - Spot Light
pascal
  start end size type   name
   0     3    4  float  Target pos X
   4     7    4  float  Target pos X
   8    11    4  float  Target pos X
  12    15    4  float  Hotspot
  16    19    4  float  Falloff
  • 0010 - RGB Color
pascal
  start end size type   name
   0     3   4   float  Red
   4     7   4   float  Green
   8    11   4   float  Blue
  • 0011 - RGB Color - 24 bit
pascal
  start end size type   name
   0    1    1   byte   Red
   1    1    1   byte   Green
   2    2    1   byte   Blue
  • 4700 - Camera

    Describes the details of the camera in the scene

pascal
 start end size type   name
  0     3   4   float  Camera pos X
  4     7   4   float  Camera pos Y
  8    11   4   float  Camera pos Z
 12    15   4   float  Camera target X
 16    19   4   float  Camera target X
 20    23   4   float  Camera target X
 24    27   4   float  Camera bank ( rotation angle )
 28    31   4   float  Camera lens
  • Keyframer chunk
pascal
  id         Description
 B00A        unknown
 7001        See first description of this chunk
 B008        Frames
 B009        unknown
 B002        Start object description
  • B008 - Frame information

simple structure describing frame info

pascal
 start end size type            name
   0    3    4  unsigned long   start frame
   4    7    4  unsigned long   end frame

*B002 - Start of Object info

Subhunks

pascal
  id     Description
 B010    Name & Hierarchy
 B011*   Name Dummy Object
 B013    unknown
 B014*   unknown
 B015    unknown
 B020    Objects pivot point ?
 B021    unknown
 B022    unknown
  • B010 - Name & Hierarchy descriptor
pascal
 start end  size type          name
 0      ?    ?   ASCIIZ        Object name
 ?      ?    ?   unsigned int  unknown
 ?      ?    ?   unsigned int  unknown
 ?      ?    ?   unsigned int  Hierarchy of Object

The object hierarchy is a bit complex but works like this. Each Object in the scene is given a number to identify its order in the tree. Also each object is orddered in the 3ds file as it would appear in the tree. The root object is given the number -1 ( FFFF ). As the file is read a counter of the object number is kept. Is the counter increments the object are children of the previous objects.But when the pattern is broken by a number what will be less than the current counter the hierarchy returns to that level.

for example.

pascal
object   hierarchy
name
pascal
A      -1
B       0                 This example is taken
C       1                 from 50pman.3ds
D       2
E       1                 I would really reccomend
F       4                 having a look at one of the
G       5                 examples with the hierarchy
H       1                 numbers to help work it out.
I       7
J       8
K       0
L      10
M      11
N       0
O      13
P      14
pascal
A
pascal
+-----------------+----------------+
B                 K                N
pascal
+----+----+            +                +
C    E    H            L                O
+    +    +            +                +
D    F    I            M                P
     +    +
     G    J

Still not done with this chunk yet ! If the object name is $$$DUMMY then it is a dummy object and therefore you should expect a few extra chunks.

  • B011 - Dummy objects name.
pascal
Names a dummy object. ASCIIZ string.
  • B020 - Pivot Point ?

The Objects pivot point. Not quite sure what the first five floats do yet ( ideas ?).

pascal
 start end size type   name
   0    3    4  float  unknown
   4    7    4  float  unknown
   8   11    4  float  unknown
  12   16    4  float  unknown
  16   19    4  float  unknown
  20   23    4  float  unknown
  24   27    4  float  Pivot Y
  28   32    4  float  Pivot X