S3D Format

From SC4 Encyclopaedia

(Redirected from S3D/format)
Jump to: navigation, search

The following is the specification for S3D files. Due to the situation of not being able to distribute the current specification which is in use for privacy reasons, the best we can do is post the last user decoded spec. People are free to add to this and probably should considering all the information needed to fill in the blanks.



S3D format, continuing from Dimakrator2's work.

3DMD Section

3DMD (4 bytes)
DWORD (Size of the file most of the time)

HEAD Section

HEAD (4 bytes)
DWORD (Size of HEAD area including the header)
WORD (Major version | Critical to file parse) (1)
WORD (Minor version | Critical to file parse) (5) (for example version 1.5)

VERT Section

VERT (4 bytes)
DWORD (Size of VERT area, including the header)
DWORD (Number of vertices groups in VERT area)

(Vertices group (header and vertices)):
 WORD (Flags)
 WORD (Number of vertices in group)
 DWORD (Format of Vertices, 0x80004001 for known S3D's; note for decoding: if the two lower bytes are 0x0002, this appears to represent the same format)
 (Vertices 0x80004001):
 float, float, float, float, float (x, y, z, u, v for each vertex)
  (x, y, z = space coordinates, in meters)
  (u, v = texture coordinates)
  (0< u <1, 0< v <1)
  (0,0 = top-left corner of texture)

INDX Section

INDX (4 bytes) 
DWORD (size of INDX area including the header)
DWORD (number of indices groups in INDX area)

(Index group (header and indices)):
 WORD (Flags)
 WORD (Index data stride (always 2 in known models))
 WORD (Number of indices in group)

 WORD (Indices of vertices in VERT area; possibly BYTE or DWORD if Index data stride above is 1 or 4 (not fully tested))
  (Indices have no inherent relation to specific polygons (they are defined in the PRIM section),
   however Ilive's Reader assumes every three indices define an individual counter-clockwise triangle.)

PRIM Section

PRIM (4 bytes) 
DWORD (Size of PRIM area, including the header)
DWORD (Number of groups in PRIM area)

(Primitives group (header and subgroups)):
 WORD - Number of subgroups in this group

  DWORD - Primitive Type (0 = Triangles (typical), 1 = Triangle Strip, 2 = Triangle Fan, 3 = Quads, 4 = Quad Fan)
  DWORD - First index in the subgroup (references INDX section)
  DWORD - Number of indices in the subgroup
 (Ilive's Reader can only handle triangle meshes and PRIM groups with only a single subgroup starting at the first (#0) index in the INDX section.
  Multiple subgroups can be used to combine different mesh types, ie: a quad strip with spare triangles.)

MATS Section

MATS (4 bytes)
DWORD (Size of MATS area, including header) 
DWORD (Number of Materials groups)

(Materials group):
 DWORD (Flags)
   (bitmask: 1 = Alpha Test, 2 = Depth Test, 8 = Backface Culling,
    16 = Frame Buffer Blend, 32 = Texturing, 64 = Color Writes,
    128 = Depth Writes)
 BYTE - Alpha Function
 BYTE - Depth Function
 BYTE - Source Blend Factor
 BYTE - Destination Blend Factor
 WORD - Alpha Threshold
 DWORD - Material Class
 BYTE - Reserved
 BYTE - Texture count (seems to be 1 always)

  DWORD - Instance ID for this material
  BYTE - Wrap Mode U
  BYTE - Wrap Mode V

 (Next 2 bytes only if Minor version .5 or bigger)
  BYTE - Magnif(ication?) Filter
  BYTE - Minif(ication?) Filter

  WORD - Animation Rate
  WORD - Animation Mode
  BYTE - Length of materials name including the 00 ending byte Material Name
  STRING - Materials Name
  BYTE - 00 (end materials name)

ANIM Section

ANIM (4 bytes)
DWORD - Length of ANIM area including the header (only most of the time)
WORD - Number of Frames in each Assignment Group
WORD - Frame Rate
WORD - Animation mode (1 = ping-pong, 2 = one shot, 3 = looping)
DWORD - Flags
FLOAT32 - Displacement
WORD - Number of Assignment Groups

(Assigning Group):
 BYTE- Length of animation name including the 00 ending byte
 BYTE - Flags
 STRING - Animation Name
 BYTE - 00 (end of animation name)
  (Block indices, repeat following 8 bytes for each frame):
  WORD - Vertex block Index Number
  WORD - Index block Index Number
  WORD - Primitive block Index Number. 
  WORD - Material block Index Number

PROP Section

Prop area is for assignments of clothes and models to advisor animations and possibly other skinning animations.

PROP (4 bytes)
DWORD (Size of the PROP area)
DWORD (Number of property assignment groups)

(Property assignment group):
 WORD - Mesh Index
 WORD - Frame Number
 BYTE - size of type field)
 String - Type of assignment
 BYTE - 00 (end string)
 BYTE - size of assigned property name
 String - assigned value (IE Adult for skeleton type etc)
 BYTE - 00 (end string)

REGP Section

REGP area is used to attach effects to automata.

REGP (4 bytes)
DWORD (Size of REGP area, including header)
DWORD (Number of effects in REGP area)

 BYTE - Length of Effect name including the 00 ending byte
 Effect Name - ( fx_##_effectname )
 BYTE - 00 (end effects name)
 WORD - number of effects subgroups for this effect

 (Effect Subgroup):
  (Translation subgroup):
   FLOAT32 - X translation
   FLOAT32 - Y translation
   FLOAT32 - Z translation

  (Orientation subgroup):
   FLOAT32 - X orientation
   FLOAT32 - Y orientation
   FLOAT32 - Z orientation
   FLOAT32 - W orientation (Particle Weight?)
Personal tools