SetFormat

This function sets the type of export format, by setting a mask
  bit 0 & 1:
    00  Each vertex is unique (although mostly irrelevant UpdateIndexBuffer() and
          UpdateTransformationBuffer() are still returning information)
    01  Each index is unique => vertices are not necessarily (although mostly
          irrelevant UpdateTransformationBuffer() is still returning information)
    10  Single level Transformations are used, most optimal when using DirectX till version 11
          and OpenGL till version 2
    11  Nested Transformations are used, most optimal but till 2011 no known support of
          low level 3D interfaces like DirectX and OpenGL
  bit 2: (FORMAT_SIZE_VERTEX_DOUBLE)
    0  Vertex items returned as float (4 byte/32 bit)
    1  Vertex items returned as double (8 byte/64 bit)
  bit 3: (FORMAT_SIZE_INDEX_INT64)
    0  Index items returned as int32_t (4 byte/32 bit)
    1  Index items returned as int64_t (8 byte/64 bit) (only available in 64 bit mode)

  bit 4: (FORMAT_VERTEX_POINT)
    0  Vertex does not contain 3D point info
    1  Vertex does contain 3D point info
  bit 5: (FORMAT_VERTEX_NORMAL)
    0  Vertex does not contain 3D normal vector info
    1  Vertex does contain 3D normal vector info => if set, bit 4 will also be set
  bit 6: (FORMAT_VERTEX_TEXTURE_UV)
    0  Vertex does not contain first 2D texture info
    1  Vertex does contain first 2D texture info
  bit 7: (FORMAT_VERTEX_TEXTURE2_UV)
    0  Vertex does not contain second 2D texture info
    1  Vertex does contain second 2D texture info => if set, bit 6 will also be set

  bit 8: (FORMAT_EXPORT_TRIANGLES)
    0  No object form triangles are exported
    1  Object form triangles are exported (effective if instance contains faces and/or solids)
  bit 9: (FORMAT_EXPORT_LINES)
    0  No object polygon lines are exported
    1  Object polygon lines are exported (effective if instance contains line representations)
  bit 10: (FORMAT_EXPORT_POINTS)
    0  No object points are exported
    1  Object points are exported (effective if instance contains point representations)

  bit 11:  Reserved, by default 0

  bit 12: (FORMAT_EXPORT_FACE_POLYGONS)
    0  No object face polygon lines are exported
    1  Object face polygon lines (dense wireframe) are exported => if set, bit 8 will also be set
  bit 13: (FORMAT_EXPORT_CONCEPTUAL_FACE_POLYGONS)
    0  No object conceptual face polygon lines are exported
    1  Object conceptual face polygon lines (wireframe) are exported => if set, bit 12 will also be set
  bit 14: (FORMAT_EXPORT_POLYGONS_AS_TUPLES)
    0  Polygon lines (wireframe) exported as list, i.e. typical 4 point polygon exported as 0 1 2 3 0 -1
    1  Polygon lines (wireframe) exported as tuples, i.e. typical 4 point polygon exported as 0 1 1 2 2 3 3 0

  bit 15: (FORMAT_EXPORT_ADVANCED_NORMALS)
    0  All normals of triangles are transformed orthogonal to the 2D face they belong to
    1  Normals are exported to be in line with the original semantic form description (could be non orthogonal to the 2D face)

  bit 16: (FORMAT_EXPORT_DIRECTX)
    0  no specific behavior
    1  Where possible DirectX compatibility is given to exported data (i.e. order of components in vertex buffer)
        => [bit 20, bit 21 both UNSET]
        => if set, bit 17 will be unset

  bit 17: (FORMAT_EXPORT_OPENGL)
    0  no specific behavior
    1  Where possible OpenGL compatibility is given to exported data (i.e. order of components in vertex buffer and inverted texture coordinates in Y direction)
        => [bit 20, bit 21 both SET]
        => if set, bit 16 will be unset

  bit 18: (FORMAT_EXPORT_DOUBLE_SIDED)
    0  All faces are defined as calculated
    1  Every face has exactly one opposite face (normally both index and vertex buffer are doubled in size)

  bit 19: Reserved, by default 0

  bit 20-23:
    0000  version 0 (used in case there is different behavior between versions in DirectX or OpenGL)
    ....  ...
    1111  version 15

  bit 20: (FORMAT_EXPORT_VERSION_0001)
    0  Standard Triangle Rotation (LHS as expected by DirectX)
    1  Opposite Triangle Rotation (RHS as expected by OpenGL)
  bit 21: (FORMAT_EXPORT_VERSION_0010)
    0  X, Y, Z (nX, nY, nZ) formatted as considering internal concepts
    1  X, Y, Z (nX, nY, nZ) formatted as , i.e. X, -Z, Y (nX, -nZ, nY) considering internal concepts (OpenGL)

  bit 24: (FORMAT_VERTEX_COLOR_AMBIENT)
    0  Vertex does not contain Ambient color information
    1  Vertex does contain Ambient color information
  bit 25: (FORMAT_VERTEX_COLOR_DIFFUSE)
    0  Vertex does not contain Diffuse color information
    1  Vertex does contain Diffuse color information
  bit 26: (FORMAT_VERTEX_COLOR_EMISSIVE)
    0  Vertex does not contain Emissive color information
    1  Vertex does contain Emissive color information
  bit 27: (FORMAT_VERTEX_COLOR_SPECULAR)
    0  Vertex does not contain Specular color information
    1  Vertex does contain Specular color information

  bit 28: (FORMAT_VERTEX_TEXTURE_TANGENT)
    0  Vertex does not contain tangent vector for first texture
    1  Vertex does contain tangent vector for first texture => if set, bit 6 will also be set
  bit 29: (FORMAT_VERTEX_TEXTURE_BINORMAL)
    0  Vertex does not contain binormal vector for first texture
    1  Vertex does contain binormal vector for first texture => if set, bit 6 will also be set
  bit 30: (FORMAT_VERTEX_TEXTURE2_TANGENT) ONLY WORKS IN 64 BIT MODE
    0  Vertex does not contain tangent vector for second texture
    1  Vertex does contain tangent vector for second texture => if set, bit 6 will also be set
  bit 31: (FORMAT_VERTEX_TEXTURE2_BINORMAL) ONLY WORKS IN 64 BIT MODE
    0  Vertex does not contain binormal vector for second texture
    1  Vertex does contain binormal vector for second texture => if set, bit 6 will also be set

  bit 26-31: Reserved, by default 0

  bit 32-63: Reserved, by default 0

Note: default setting is 0000 0000 0000 0000 0000 0000 0000 0000 - 0000 0000 0000 0000 1000 0001 0011 0000 = h0000 0000 - 0000 8130 = 33072


Depending on FORMAT_SIZE_VERTEX_DOUBLE each element in the vertex buffer is a double or float number.
Number of elements for each vertex depends on format setting. You can get the number by GetVertexElementsCounts.
Each vertex block contains data items in an order according to the table below. The table also specifies when an item is present and number of elements
it occupied. Use GetVertexDataOffset or GetVertexColor to get required item.

 # Vertex data item Included when format setting bit is on Size (num of elements)
 Point coordinates   X, Y, X FORMAT_VERTEX_POINT (bit 4) 3
 Normal coordinates   Nx, Ny, Nz FORMAT_VERTEX_NORMAL (bit 5) 3
 Texture coordinates   T1u, T1v FORMAT_VERTEX_TEXTURE_UV (bit 6) 2
 2nd Texture coordinates   T2u, T2v FORMAT_VERTEX_TEXTURE2_UV (bit 7) 2
 Ambient color   FORMAT_VERTEX_COLOR_AMBIENT (bit 24) 1
 Diffuse color   FORMAT_VERTEX_COLOR_DIFFUSE (bit 25) 1
 Emissive color   FORMAT_VERTEX_COLOR _EMISSIVE (bit 26) 1
 Specular color   FORMAT_VERTEX_COLOR _SPECULAR (bit 27) 1
 Texture tangent   T1Tx, T1Ty, T1Tz FORMAT_VERTEX_TEXTURE_TANGENT (bit 28) 3
 Texture binormal   T1BNx,T1BNy,T1BNz FORMAT_VERTEX_TEXTURE_BINORMAL (bit 29) 3
 2nd texture tangent   T2Tx, T2Ty, T2Tz FORMAT_VERTEX_TEXTURE2_TANGENT (bit 30) 3
 2nd texture binormal   T2BNx,T2BNy,T2BNz FORMAT_VERTEX_TEXTURE2_BINORMAL (bit 31) 3

Syntax

//
//   Strong typing definition
//
uint64_t        SetFormat(
                        OwlModel                model,
                        uint64_t                setting,
                        uint64_t                mask
                    );

static  inline  uint64_t    SetFormat(
                                    OwlModel                model
                                )
{
    return  SetFormat(
                    model,
                    0,                                  //    setting
                    0                                   //    mask
                );
}


//
//   Weak typing definition
//
uint64_t    __declspec(dllexport) __stdcall SetFormat(
                                                    int64_t                 model,
                                                    uint64_t                setting,
                                                    uint64_t                mask
                                                );

static  inline  uint64_t    SetFormat(
                                    int64_t                 model
                                )
{
    return  SetFormat(
                    model,
                    0,                                  //    setting
                    0                                   //    mask
                );
}
    

Property model

Size: 64 bit / 8 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

Property setting

Size: 64 bit / 8 byte (value)
The setting is the data that is defined for bitwise operations, only bits set in the mask will be relevant.

Property mask

Size: 64 bit / 8 byte (value)
This mask or bitmask is data that is used for bitwise operations, i.e. the bits set in the mask are the bits affected in the setting or return value.

Example (based on pure API calls)

Here you can find code snippits that show how the API call SetFormat can be used.

#include    "./include/engine.h"

static  const   uint64_t    flagbit0 = 1;                           // 2^^0                          0000.0000..0000.0001
static  const   uint64_t    flagbit1 = 2;                           // 2^^1                          0000.0000..0000.0010
static  const   uint64_t    flagbit2 = 4;                           // 2^^2                          0000.0000..0000.0100
static  const   uint64_t    flagbit3 = 8;                           // 2^^3                          0000.0000..0000.1000

static  const   uint64_t    flagbit4 = 16;                          // 2^^4                          0000.0000..0001.0000
static  const   uint64_t    flagbit5 = 32;                          // 2^^5                          0000.0000..0010.0000
static  const   uint64_t    flagbit6 = 64;                          // 2^^6                          0000.0000..0100.0000
static  const   uint64_t    flagbit7 = 128;                         // 2^^7                          0000.0000..1000.0000

static  const   uint64_t    flagbit8 = 256;                         // 2^^8                          0000.0001..0000.0000
static  const   uint64_t    flagbit9 = 512;                         // 2^^9                          0000.0010..0000.0000
static  const   uint64_t    flagbit10 = 1024;                       // 2^^10                         0000.0100..0000.0000
static  const   uint64_t    flagbit11 = 2048;                       // 2^^11                         0000.1000..0000.0000

static  const   uint64_t    flagbit12 = 4096;                       // 2^^12                         0001.0000..0000.0000
static  const   uint64_t    flagbit13 = 8192;                       // 2^^13                         0010.0000..0000.0000
static  const   uint64_t    flagbit14 = 16384;                      // 2^^14                         0100.0000..0000.0000
static  const   uint64_t    flagbit15 = 32768;                      // 2^^15                         1000.0000..0000.0000

static  const   uint64_t    flagbit16 = 65536;                      // 2^^16   0000.0000..0000.0001  0000.0000..0000.0000
static  const   uint64_t    flagbit17 = 131072;                     // 2^^17   0000.0000..0000.0010  0000.0000..0000.0000
static  const   uint64_t    flagbit18 = 262144;                     // 2^^18   0000.0000..0000.0100  0000.0000..0000.0000
static  const   uint64_t    flagbit19 = 524288;                     // 2^^19   0000.0000..0000.1000  0000.0000..0000.0000

static  const   uint64_t    flagbit20 = 1048576;                    // 2^^20   0000.0000..0001.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit21 = 2097152;                    // 2^^21   0000.0000..0010.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit22 = 4194304;                    // 2^^22   0000.0000..0100.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit23 = 8388608;                    // 2^^23   0000.0000..1000.0000  0000.0000..0000.0000

static  const   uint64_t    flagbit24 = 16777216;                   // 2^^24   0000.0001..0000.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit25 = 33554432;                   // 2^^25   0000.0010..0000.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit26 = 67108864;                   // 2^^26   0000.0100..0000.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit27 = 134217728;                  // 2^^27   0000.1000..0000.0000  0000.0000..0000.0000

static  const   uint64_t    flagbit28 = 268435456;                  // 2^^28   0001.0000..0000.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit29 = 536870912;                  // 2^^29   0010.0000..0000.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit30 = (uint64_t) 1073741824;      // 2^^30   0100.0000..0000.0000  0000.0000..0000.0000
static  const   uint64_t    flagbit31 = (uint64_t) 2147483648;      // 2^^31   1000.0000..0000.0000  0000.0000..0000.0000

...

int64_t model = CreateModel();

if (model) {
    {
        //
        //  Initializing the mask with all possible options
        //
        int64_t setting = 0,
                mask = GetFormat(0, 0);

        setting += 0 * flagbit2;        //    SINGLE / DOUBLE PRECISION (float / double)
        setting += 0 * flagbit3;        //    32 / 63 BIT INDEX ARRAY (int32_t / int64_t)

        setting += 1 * flagbit4;        //    OFF / ON VECTORS (x, y, z) 
        setting += 1 * flagbit5;        //    OFF / ON NORMALS (Nx, Ny, Nz)
        setting += 0 * flagbit6;        //    OFF / ON TEXTURE I (u1, v1)
        setting += 0 * flagbit7;        //    OFF / ON TEXTURE II (u2, v2)

        setting += 1 * flagbit8;        //    OFF / ON TRIANGLES
        setting += 1 * flagbit9;        //    OFF / ON LINES
        setting += 1 * flagbit10;       //    OFF / ON POINTS

        setting += 0 * flagbit12;       //    OFF / ON WIREFRAME FACES
        setting += 0 * flagbit13;       //    OFF / ON WIREFRAME CONCEPTUAL FACES

        setting += 0 * flagbit14;       //    OFF / ON STRUCTURE WIREFRAME AS POLYGON / TUPLE
        setting += 0 * flagbit15;       //    OFF / ON ADVANCED NORMALS (I.E. FOLLOWING THE SEMANTIC MEANING OF THE CONCEPT)

        setting += 0 * flagbit16;       //    OFF / ON DIRECTX (COMBINATION SETTING BIT 20, 21, 22, 23)
        setting += 0 * flagbit17;       //    OFF / ON OPENGL (COMBINATION SETTING BIT 20, 21, 22, 23)

        setting += 0 * flagbit18;       //    OFF / ON EXPORT BOTH SIDES OF TRIANGLES

        setting += 0 * flagbit20;       //    OFF / ON EXPERT SETTING TRIANGLE WINDING CW / ACW
        setting += 0 * flagbit21;       //    OFF / ON EXPERT SETTING NONE / VERTEX + NORMAL Y = Z / Z = -Y
        setting += 0 * flagbit22;       //    OFF / ON EXPERT SETTING
        setting += 0 * flagbit23;       //    OFF / ON EXPERT SETTING

        setting += 0 * flagbit24;       //    OFF / ON AMBIENT COLOR COMPONENT
        setting += 0 * flagbit25;       //    OFF / ON DIFFUSE COLOR COMPONENT
        setting += 0 * flagbit26;       //    OFF / ON EMISSIVE COLOR COMPONENT
        setting += 0 * flagbit27;       //    OFF / ON SPECULAR COLOR COMPONENT

        setting += 0 * flagbit28;       //    OFF / ON TEXTURE I TANGENT
        setting += 0 * flagbit29;       //    OFF / ON TEXTURE I BINORMAL

        setting += 0 * flagbit30;       //    OFF / ON TEXTURE II TANGENT (64 BIT ONLY)
        setting += 0 * flagbit31;       //    OFF / ON TEXTURE II BINORMAL (64 BIT ONLY)

        int64_t vertexElementSizeInBytes = SetFormat(model, setting, mask);
    }

    //
    //  Check if a certain option is set
    //
    if (GetFormat(model, flagbit5)) {
        //  Normal coordinates (Nx, Ny, Nz) are exported
    }
    else {
        //  Normal coordinates (Nx, Ny, Nz) are not exported
    }

    if (GetFormat(model, flagbit27)) {
        //  Specular color is exported
    }
    else {
        //  Specular color is not exported
    }

    {
        //
        //  Get all set options
        //
        int64_t setting = GetFormat(model, GetFormat(0, 0));

        if (setting & flagbit5) {
            //  Normal coordinates (Nx, Ny, Nz) are exported
        }
        else {
            //  Normal coordinates (Nx, Ny, Nz) are not exported
        }

        if (setting & flagbit27) {
            //  Specular color is exported
        }
        else {
            //  Specular color is not exported
        }
    }
}