io7m | single-page | multi-page | SMF Format Specification 0.16.0-SNAPSHOT
3.2. Header
Previous
3. SMF/B - Binary Encoding
Up
3.4. Sections
Next

# 3.3. Section - smf

- 3.3.1. Definition
- 3.3.2. Cardinality/Ordering
- 3.3.3. Magic Number
- 3.3.4. Data

## 3.3.1. Definition

1
The smf section specifies information common to all sections in an SMF/B file.

## 3.3.2. Cardinality/Ordering

1
An smf section MUST appear exactly once in an SMF/B file.
2
The smf section MUST be the first section in an SMF/B file. Implementations MUST reject SMF/B files that do not start with an smf section.

## 3.3.3. Magic Number

1
The smf section is identified by the magic number 0x534D465F48454144.

## 3.3.4. Data

1
The smf section begins with the following structure:

### 3.3.4.2. SMF Header

    <composite name="SMFSectionFields">
      <ref name="fieldsSize"
           type="uint32"/>
      <ref name="schemaIdentifier"
           type="SMFSchemaIdentifier"/>
      <ref name="vertexCount"
           type="uint64"/>
      <type name="triangleCount"
            primitiveType="uint64"
            semanticType="Length"/>
      <type name="triangleSizeBits"
            primitiveType="uint32"
            semanticType="Length"/>
      <ref name="attributeCount"
           type="uint32"/>
      <ref name="coordinateSystem"
           type="SMFCoordinateSystem"/>
      <enum name="SMFByteOrder"
            encodingType="uint32">
        <validValue name="BIG_ENDIAN">0</validValue>
        <validValue name="LITTLE_ENDIAN">1</validValue>
      </enum>
    </composite>

3
The fieldsSize field specifies the total size of the header fields, after which a list of attributes will be declared. The purpose of this field is to allow for forward compatibility: Future updates to this specification may add extra fields to the end of the header structure, and the value of this field allows older implementations to skip those newer fields.
4
The schemaIdentifier field specifies the schema identifier for the model:

### 3.3.4.5. Schema Identifier

    <composite name="SMFSchemaIdentifier">
      <type name="nameLength"
            description="The number of bytes in the following name array that should be extracted to form a name."
            primitiveType="uint32"/>
      <type name="name"
            primitiveType="uint8"
            characterEncoding="UTF-8"
            length="64"/>
      <type name="versionMajor"
            description="The major version of the schema."
            primitiveType="uint32"/>
      <type name="versionMinor"
            description="The minor version of the schema."
            primitiveType="uint32"/>
    </composite>

6
If the length of the schema_id field is 0, the schema identifier as a whole is ignored.
7
The vertexCount field specifies the number of vertices that will be specified in a vertices-noninterleaved section. Parsers MUST raise an appropriate error if a non-zero vertex count is specified but no vertices are actually provided in any following section.
8
The triangleCount field specifies the number of triangles that will be specified in a triangles section. The triangleSizeBits field specifies the size in bits of the individual vertex indices within each triangle. Parsers MUST raise an appropriate error if a non-zero triangle count is specified but no triangles are actually provided in any following section.
9
The attributeCount field specifies the number of attributes that will be declared.
10
The coordinateSystem field specifies the coordinate system of the model:

### 3.3.4.11. Coordinate System

    <enum name="SMFAxis"
          encodingType="uint8">
      <validValue name="AXIS_POSITIVE_X">0</validValue>
      <validValue name="AXIS_POSITIVE_Y">1</validValue>
      <validValue name="AXIS_POSITIVE_Z">2</validValue>
      <validValue name="AXIS_NEGATIVE_X">3</validValue>
      <validValue name="AXIS_NEGATIVE_Y">4</validValue>
      <validValue name="AXIS_NEGATIVE_Z">5</validValue>
    </enum>

    <enum name="SMFWindingOrder"
          encodingType="uint8">
      <validValue name="FACE_WINDING_ORDER_CLOCKWISE">0</validValue>
      <validValue name="FACE_WINDING_ORDER_COUNTER_CLOCKWISE">1</validValue>
    </enum>

    <composite name="SMFCoordinateSystem">
      <ref name="right"
           type="SMFAxis"/>
      <ref name="up"
           type="SMFAxis"/>
      <ref name="forward"
           type="SMFAxis"/>
      <ref name="windingOrder"
           type="SMFWindingOrder"/>
    </composite>

12
The axis and winding order values are related to integer values via the following functions:

### 3.3.4.13. Coordinate System Mapping

    import qualified Axis as A

    axisOrdinal :: A.Axis -> Integer
    axisOrdinal A.PositiveX = 0
    axisOrdinal A.PositiveY = 1
    axisOrdinal A.PositiveZ = 2
    axisOrdinal A.NegativeX = 3
    axisOrdinal A.NegativeY = 4
    axisOrdinal A.NegativeZ = 5

    windingOrdinal :: A.WindingOrder -> Integer
    windingOrdinal A.WindingOrderClockwise        = 0
    windingOrdinal A.WindingOrderCounterClockwise = 1

14
The byteOrder field specifies the endianness of the values in the vertex and triangle.
15
Directly following the end of the header structure is a series of attribute declarations:

### 3.3.4.16. Attribute

    <composite name="SMFSchemaAttribute">
      <type name="nameLength"
            description="The number of bytes in the following name array that should be extracted to form a name."
            primitiveType="uint32"/>

      <type name="name"
            primitiveType="uint8"
            characterEncoding="UTF-8"
            length="64"/>

      <enum name="componentKind"
            encodingType="uint32">
        <validValue name="ELEMENT_TYPE_INTEGER_SIGNED">0</validValue>
        <validValue name="ELEMENT_TYPE_INTEGER_UNSIGNED">1</validValue>
        <validValue name="ELEMENT_TYPE_FLOATING">2</validValue>
      </enum>

      <type name="componentCount"
            description="The number of components in a single attribute value."
            minValue="1"
            maxValue="4"
            primitiveType="uint32"/>

      <type name="componentSizeBits"
            description="The size in bits of components in a single attribute value."
            minValue="1"
            maxValue="64"
            primitiveType="uint32"/>
    </composite>

17
The name field specifies the name of the attribute. The componentKind field specifies the type of the attribute components. The componentCount field specifies the number of components in each value in the attribute, and the componentSizeBits field specifies the size in bits of each component value.
18
Attribute component types are related to integer values via the following function:

### 3.3.4.19. Attribute Type Mapping

    import qualified Attribute as A

    attributeTypeOrdinal :: A.ComponentType -> Integer
    attributeTypeOrdinal A.IntegerSigned   = 0
    attributeTypeOrdinal A.IntegerUnsigned = 1
    attributeTypeOrdinal A.FloatingPoint   = 2

3.2. Header
Previous
3. SMF/B - Binary Encoding
Up
3.4. Sections
Next
io7m | single-page | multi-page | SMF Format Specification 0.16.0-SNAPSHOT