# openctm.h File Reference

`#include <stdint.h>`

Go to the source code of this file.

## Defines

#define | CTM_API_VERSION 0x00000100
| OpenCTM API version (1.0).
#define | CTM_TRUE 1
| Boolean TRUE.
#define | CTM_FALSE 0
| Boolean FALSE.

## Typedefs

typedef float | CTMfloat
| Single precision floating point type (IEEE 754 32 bits wide).
typedef int32_t | CTMint
| Signed integer (32 bits wide).
typedef uint32_t | CTMuint
| Unsigned integer (32 bits wide).
typedef void * | CTMcontext
| OpenCTM context handle.
typedef CTMuint(CTMCALL * | CTMreadfn )(void *aBuf, CTMuint aCount, void *aUserData)
| Stream read() function pointer.
typedef CTMuint(CTMCALL * | CTMwritefn )(const void *aBuf, CTMuint aCount, void *aUserData)
| Stream write() function pointer.

## Enumerations

enum

CTMenum {
CTM_NONE = 0x0000,
CTM_INVALID_CONTEXT = 0x0001,
CTM_INVALID_ARGUMENT = 0x0002,
CTM_INVALID_OPERATION = 0x0003,
CTM_INVALID_MESH = 0x0004,
CTM_OUT_OF_MEMORY = 0x0005,
CTM_FILE_ERROR = 0x0006,
CTM_BAD_FORMAT = 0x0007,
CTM_LZMA_ERROR = 0x0008,
CTM_INTERNAL_ERROR = 0x0009,
CTM_UNSUPPORTED_FORMAT_VERSION = 0x000A,
CTM_IMPORT = 0x0101,
CTM_EXPORT = 0x0102,
CTM_METHOD_RAW = 0x0201,
CTM_METHOD_MG1 = 0x0202,
CTM_METHOD_MG2 = 0x0203,
CTM_VERTEX_COUNT = 0x0301,
CTM_TRIANGLE_COUNT = 0x0302,
CTM_HAS_NORMALS = 0x0303,
CTM_UV_MAP_COUNT = 0x0304,
CTM_ATTRIB_MAP_COUNT = 0x0305,
CTM_VERTEX_PRECISION = 0x0306,
CTM_NORMAL_PRECISION = 0x0307,
CTM_COMPRESSION_METHOD = 0x0308,
CTM_FILE_COMMENT = 0x0309,
CTM_NAME = 0x0501,
CTM_FILE_NAME = 0x0502,
CTM_PRECISION = 0x0503,
CTM_INDICES = 0x0601,
CTM_VERTICES = 0x0602,
CTM_NORMALS = 0x0603,
CTM_UV_MAP_1 = 0x0700,
CTM_UV_MAP_2 = 0x0701,
CTM_UV_MAP_3 = 0x0702,
CTM_UV_MAP_4 = 0x0703,
CTM_UV_MAP_5 = 0x0704,
CTM_UV_MAP_6 = 0x0705,
CTM_UV_MAP_7 = 0x0706,
CTM_UV_MAP_8 = 0x0707,
CTM_ATTRIB_MAP_1 = 0x0800,
CTM_ATTRIB_MAP_2 = 0x0801,
CTM_ATTRIB_MAP_3 = 0x0802,
CTM_ATTRIB_MAP_4 = 0x0803,
CTM_ATTRIB_MAP_5 = 0x0804,
CTM_ATTRIB_MAP_6 = 0x0805,
CTM_ATTRIB_MAP_7 = 0x0806,
CTM_ATTRIB_MAP_8 = 0x0807
}

| OpenCTM specific enumerators. More...

## Functions

CTMEXPORT CTMcontext CTMCALL | ctmNewContext (CTMenum aMode)
| Create a new OpenCTM context.
CTMEXPORT void CTMCALL | ctmFreeContext (CTMcontext aContext)
| Free an OpenCTM context.
CTMEXPORT CTMenum CTMCALL | ctmGetError (CTMcontext aContext)
| Returns the latest error.
CTMEXPORT const char *CTMCALL | ctmErrorString (CTMenum aError)
| Converts an OpenCTM error code to a zero-terminated string.
CTMEXPORT CTMuint CTMCALL | ctmGetInteger (CTMcontext aContext, CTMenum aProperty)
| Get information about an OpenCTM context.
CTMEXPORT CTMfloat CTMCALL | ctmGetFloat (CTMcontext aContext, CTMenum aProperty)
| Get information about an OpenCTM context.
CTMEXPORT const CTMuint *CTMCALL | ctmGetIntegerArray (CTMcontext aContext, CTMenum aProperty)
| Get an integer array from an OpenCTM context.
CTMEXPORT const CTMfloat *CTMCALL | ctmGetFloatArray (CTMcontext aContext, CTMenum aProperty)
| Get a floating point array from an OpenCTM context.
CTMEXPORT CTMenum CTMCALL | ctmGetNamedUVMap (CTMcontext aContext, const char *aName)
| Get a reference to the named UV map.
CTMEXPORT const char *CTMCALL | ctmGetUVMapString (CTMcontext aContext, CTMenum aUVMap, CTMenum aProperty)
| Get information about a UV map.
CTMEXPORT CTMfloat CTMCALL | ctmGetUVMapFloat (CTMcontext aContext, CTMenum aUVMap, CTMenum aProperty)
| Get information about a UV map.
CTMEXPORT CTMenum CTMCALL | ctmGetNamedAttribMap (CTMcontext aContext, const char *aName)
| Get a reference to the named vertex attribute map.
CTMEXPORT const char *CTMCALL | ctmGetAttribMapString (CTMcontext aContext, CTMenum aAttribMap, CTMenum aProperty)
| Get information about a vertex attribute map.
CTMEXPORT CTMfloat CTMCALL | ctmGetAttribMapFloat (CTMcontext aContext, CTMenum aAttribMap, CTMenum aProperty)
| Get information about a vertex attribute map.
CTMEXPORT const char *CTMCALL | ctmGetString (CTMcontext aContext, CTMenum aProperty)
| Get information about an OpenCTM context.
CTMEXPORT void CTMCALL | ctmCompressionMethod (CTMcontext aContext, CTMenum aMethod)
| Set which compression method to use for the given OpenCTM context.
CTMEXPORT void CTMCALL | ctmCompressionLevel (CTMcontext aContext, CTMuint aLevel)
| Set which LZMA compression level to use for the given OpenCTM context.
CTMEXPORT void CTMCALL | ctmVertexPrecision (CTMcontext aContext, CTMfloat aPrecision)
| Set the vertex coordinate precision (only used by the MG2 compression method).
CTMEXPORT void CTMCALL | ctmVertexPrecisionRel (CTMcontext aContext, CTMfloat aRelPrecision)
| Set the vertex coordinate precision, relative to the mesh dimensions (only used by the MG2 compression method).
CTMEXPORT void CTMCALL | ctmNormalPrecision (CTMcontext aContext, CTMfloat aPrecision)
| Set the normal precision (only used by the MG2 compression method).
CTMEXPORT void CTMCALL | ctmUVCoordPrecision (CTMcontext aContext, CTMenum aUVMap, CTMfloat aPrecision)
| Set the coordinate precision for the specified UV map (only used by the MG2 compression method).
CTMEXPORT void CTMCALL | ctmAttribPrecision (CTMcontext aContext, CTMenum aAttribMap, CTMfloat aPrecision)
| Set the attribute value precision for the specified attribute map (only used by the MG2 compression method).
CTMEXPORT void CTMCALL | ctmFileComment (CTMcontext aContext, const char *aFileComment)
| Set the file comment for the given OpenCTM context.
CTMEXPORT void CTMCALL | ctmDefineMesh (CTMcontext aContext, const CTMfloat *aVertices, CTMuint aVertexCount, const CTMuint *aIndices, CTMuint aTriangleCount, const CTMfloat *aNormals)
| Define a triangle mesh.
CTMEXPORT CTMenum CTMCALL | ctmAddUVMap (CTMcontext aContext, const CTMfloat *aUVCoords, const char *aName, const char *aFileName)
| Define a UV map.
CTMEXPORT CTMenum CTMCALL | ctmAddAttribMap (CTMcontext aContext, const CTMfloat *aAttribValues, const char *aName)
| Define a custom vertex attribute map.
CTMEXPORT void CTMCALL | ctmLoad (CTMcontext aContext, const char *aFileName)
| Load an OpenCTM format file into the context.
CTMEXPORT void CTMCALL | ctmLoadCustom (CTMcontext aContext, CTMreadfn aReadFn, void *aUserData)
| Load an OpenCTM format file using a custom stream read function.
CTMEXPORT void CTMCALL | ctmSave (CTMcontext aContext, const char *aFileName)
| Save an OpenCTM format file.
CTMEXPORT void CTMCALL | ctmSaveCustom (CTMcontext aContext, CTMwritefn aWriteFn, void *aUserData)
| Save an OpenCTM format file using a custom stream write function.

## Define Documentation

#define CTM_API_VERSION 0x00000100

OpenCTM API version (1.0).

#define CTM_FALSE 0

Boolean FALSE.

#define CTM_TRUE 1

Boolean TRUE.

## Typedef Documentation

typedef void* CTMcontext

OpenCTM context handle.

typedef float CTMfloat

Single precision floating point type (IEEE 754 32 bits wide).

typedef int32_t CTMint

Signed integer (32 bits wide).

typedef CTMuint(CTMCALL * CTMreadfn)(void *aBuf, CTMuint aCount, void *aUserData)

Stream read() function pointer.

Parameters:

  `[in]` | aBuf | Pointer to the memory buffer to which data should be read.
  `[in]` | aCount | The number of bytes to read.
  `[in]` | aUserData | The custom user data that was passed to the ctmLoadCustom() function.

Returns:
  The number of bytes actually read (if this is less than aCount, it indicates that an error occured or the end of file was reached before all bytes were read).

typedef uint32_t CTMuint

Unsigned integer (32 bits wide).

typedef CTMuint(CTMCALL * CTMwritefn)(const void *aBuf, CTMuint aCount, void *aUserData)

Stream write() function pointer.

Parameters:

  `[in]` | aBuf | Pointer to the memory buffer from which data should be written.
  `[in]` | aCount | The number of bytes to write.
  `[in]` | aUserData | The custom user data that was passed to the ctmSaveCustom() function.

Returns:
  The number of bytes actually written (if this is less than aCount, it indicates that an error occured).

## Enumeration Type Documentation

enum CTMenum

OpenCTM specific enumerators.

Note:
  For the information query functions, it is an error to query a value of the wrong type (e.g. to query a string value with the ctmGetInteger() function).

Enumerator:

  CTM_NONE | No error has occured (everything is OK). Also used as an error return value for functions that should return a CTMenum value.
  CTM_INVALID_CONTEXT | The OpenCTM context was invalid (e.g. NULL).
  CTM_INVALID_ARGUMENT | A function argument was invalid.
  CTM_INVALID_OPERATION | The operation is not allowed.
  CTM_INVALID_MESH | The mesh was invalid (e.g. no vertices).
  CTM_OUT_OF_MEMORY | Not enough memory to proceed.
  CTM_FILE_ERROR | File I/O error.
  CTM_BAD_FORMAT | File format error (e.g. unrecognized format or corrupted file).
  CTM_LZMA_ERROR | An error occured within the LZMA library.
  CTM_INTERNAL_ERROR | An internal error occured (indicates a bug).
  CTM_UNSUPPORTED_FORMAT_VERSION | Unsupported file format version.
  CTM_IMPORT | The OpenCTM context will be used for importing data.
  CTM_EXPORT | The OpenCTM context will be used for exporting data.
  CTM_METHOD_RAW | Just store the raw data.
  CTM_METHOD_MG1 | Lossless compression (floating point).
  CTM_METHOD_MG2 | Lossless compression (fixed point).
  CTM_VERTEX_COUNT | Number of vertices in the mesh (integer).
  CTM_TRIANGLE_COUNT | Number of triangles in the mesh (integer).
  CTM_HAS_NORMALS | CTM_TRUE if the mesh has normals (integer).
  CTM_UV_MAP_COUNT | Number of UV coordinate sets (integer).
  CTM_ATTRIB_MAP_COUNT | Number of custom attribute sets (integer).
  CTM_VERTEX_PRECISION | Vertex precision - for MG2 (float).
  CTM_NORMAL_PRECISION | Normal precision - for MG2 (float).
  CTM_COMPRESSION_METHOD | Compression method (integer).
  CTM_FILE_COMMENT | File comment (string).
  CTM_NAME | Unique name (UV/attrib map string).
  CTM_FILE_NAME | File name reference (UV map string).
  CTM_PRECISION | Value precision (UV/attrib map float).
  CTM_INDICES | Triangle indices (integer array).
  CTM_VERTICES | Vertex point coordinates (float array).
  CTM_NORMALS | Per vertex normals (float array).
  CTM_UV_MAP_1 | Per vertex UV map 1 (float array).
  CTM_UV_MAP_2 | Per vertex UV map 2 (float array).
  CTM_UV_MAP_3 | Per vertex UV map 3 (float array).
  CTM_UV_MAP_4 | Per vertex UV map 4 (float array).
  CTM_UV_MAP_5 | Per vertex UV map 5 (float array).
  CTM_UV_MAP_6 | Per vertex UV map 6 (float array).
  CTM_UV_MAP_7 | Per vertex UV map 7 (float array).
  CTM_UV_MAP_8 | Per vertex UV map 8 (float array).
  CTM_ATTRIB_MAP_1 | Per vertex attribute map 1 (float array).
  CTM_ATTRIB_MAP_2 | Per vertex attribute map 2 (float array).
  CTM_ATTRIB_MAP_3 | Per vertex attribute map 3 (float array).
  CTM_ATTRIB_MAP_4 | Per vertex attribute map 4 (float array).
  CTM_ATTRIB_MAP_5 | Per vertex attribute map 5 (float array).
  CTM_ATTRIB_MAP_6 | Per vertex attribute map 6 (float array).
  CTM_ATTRIB_MAP_7 | Per vertex attribute map 7 (float array).
  CTM_ATTRIB_MAP_8 | Per vertex attribute map 8 (float array).

## Function Documentation

CTMEXPORT CTMenum CTMCALL ctmAddAttribMap | ( | CTMcontext | aContext,
|  | const CTMfloat * | aAttribValues,
|  | const char * | aName |
| ) |  |  |

Define a custom vertex attribute map.

Custom vertex attributes can be used for defining special per-vertex attributes, such as color, weight, ambient occlusion factor, etc.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aAttribValues | An array of attribute values. Each attribute value is made up by four consecutive floats, and there must be as many values as there are vertices in the mesh.
  `[in]` | aName | A unique name for this attribute map (zero terminated UTF-8 string).

Returns:
  A attribute map index (CTM_ATTRIB_MAP_1 and higher). If the function failed, it will return the zero valued CTM_NONE (use ctmGetError() to determine the cause of the error).

Note:
  A triangle mesh must have been defined before calling this function, since the number of vertices is defined by the triangle mesh.

See also:
  ctmDefineMesh().

CTMEXPORT CTMenum CTMCALL ctmAddUVMap | ( | CTMcontext | aContext,
|  | const CTMfloat * | aUVCoords,
|  | const char * | aName,
|  | const char * | aFileName |
| ) |  |  |

Define a UV map.

There can be several UV maps in a mesh. A UV map is typically used for 2D texture mapping.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aUVCoords | An array of UV coordinates. Each UV coordinate is made up by two consecutive floats, and there must be as many coordinates as there are vertices in the mesh.
  `[in]` | aName | A unique name for this UV map (zero terminated UTF-8 string).
  `[in]` | aFileName | A reference to a image file (zero terminated UTF-8 string). If no file name reference exists, pass NULL.

Returns:
  A UV map index (CTM_UV_MAP_1 and higher). If the function failed, it will return the zero valued CTM_NONE (use ctmGetError() to determine the cause of the error).

Note:
  A triangle mesh must have been defined before calling this function, since the number of vertices is defined by the triangle mesh.

See also:
  ctmDefineMesh().

CTMEXPORT void CTMCALL ctmAttribPrecision | ( | CTMcontext | aContext,
|  | CTMenum | aAttribMap,
|  | CTMfloat | aPrecision |
| ) |  |  |

Set the attribute value precision for the specified attribute map (only used by the MG2 compression method).

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aAttribMap | An attribute map specifier for a defined attribute map (CTM_ATTRIB_MAP_1, ...).
  `[in]` | aPrecision | Fixed point precision. For instance, if this value is 0.001, all attribute values will be rounded to three decimals. If the attributes represent integer values, set the precision to 1.0. The default attribute precision is 2^-8 ~= 0.0039.

See also:
  ctmAddAttribMap().

CTMEXPORT void CTMCALL ctmCompressionLevel | ( | CTMcontext | aContext,
|  | CTMuint | aLevel |
| ) |  |  |

Set which LZMA compression level to use for the given OpenCTM context.

The compression level can be between 0 (fastest) and 9 (best). The higher the compression level, the more memory is required for compression and decompression. The default compression level is 1.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aLevel | Which compression level to use (0 to 9).

CTMEXPORT void CTMCALL ctmCompressionMethod | ( | CTMcontext | aContext,
|  | CTMenum | aMethod |
| ) |  |  |

Set which compression method to use for the given OpenCTM context.

The selected compression method will be used when calling the ctmSave() function.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aMethod | Which compression method to use: CTM_METHOD_RAW, CTM_METHOD_MG1 or CTM_METHOD_MG2 (the default method is CTM_METHOD_MG1).

See also:
  CTM_METHOD_RAW, CTM_METHOD_MG1, CTM_METHOD_MG2

CTMEXPORT void CTMCALL ctmDefineMesh | ( | CTMcontext | aContext,
|  | const CTMfloat * | aVertices,
|  | CTMuint | aVertexCount,
|  | const CTMuint * | aIndices,
|  | CTMuint | aTriangleCount,
|  | const CTMfloat * | aNormals |
| ) |  |  |

Define a triangle mesh.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aVertices | An array of vertices (three consecutive floats make one vertex).
  `[in]` | aVertexCount | The number of vertices in `aVertices` (and optionally `aTexCoords`).
  `[in]` | aIndices | An array of vertex indices (three consecutive integers make one triangle).
  `[in]` | aTriangleCount | The number of triangles in `aIndices` (there must be exactly 3 x `aTriangleCount` indices in `aIndices`).
  `[in]` | aNormals | An array of per-vertex normals (or NULL if there are no normals). Each normal is made up by three consecutive floats, and there must be `aVertexCount` normals.

See also:
  ctmAddUVMap(), ctmAddAttribMap(), ctmSave(), ctmSaveCustom().

CTMEXPORT const char* CTMCALL ctmErrorString | ( | CTMenum | aError | ) |

Converts an OpenCTM error code to a zero-terminated string.

Parameters:

  `[in]` | aError | An OpenCTM error code, as returned by ctmGetError().

Returns:
  A zero terminated string that describes the error. For instance, if `aError` is CTM_INVALID_OPERATION, then the return value will be "CTM_INVALID_OPERATION".

See also:
  CTMenum

CTMEXPORT void CTMCALL ctmFileComment | ( | CTMcontext | aContext,
|  | const char * | aFileComment |
| ) |  |  |

Set the file comment for the given OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aFileComment | The file comment (zero terminated UTF-8 string).

CTMEXPORT void CTMCALL ctmFreeContext | ( | CTMcontext | aContext | ) |

Free an OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().

See also:
  ctmNewContext()

CTMEXPORT CTMfloat CTMCALL ctmGetAttribMapFloat | ( | CTMcontext | aContext,
|  | CTMenum | aAttribMap,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about a vertex attribute map.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aAttribMap | Which vertex attribute map to query (CTM_ATTRIB_MAP_1 or higher).
  `[in]` | aProperty | Which vertex attribute map property to return.

Returns:
  A floating point value, representing the vertex attribute map property given by `aProperty`.

See also:
  CTMenum

CTMEXPORT const char* CTMCALL ctmGetAttribMapString | ( | CTMcontext | aContext,
|  | CTMenum | aAttribMap,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about a vertex attribute map.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aAttribMap | Which vertex attribute map to query (CTM_ATTRIB_MAP_1 or higher).
  `[in]` | aProperty | Which vertex attribute map property to return.

Returns:
  A string value, representing the vertex attribute map property given by `aProperty`.

Note:
  The string is only valid as long as the vertex attribute map within the OpenCTM context is valid. Trying to access an invalid string will result in undefined behaviour. Therefor it is recommended that the string is copied to a new variable if it is to be used other than directly after the call to ctmGetAttribMapString().

See also:
  CTMenum

CTMEXPORT CTMenum CTMCALL ctmGetError | ( | CTMcontext | aContext | ) |

Returns the latest error.

Calling this function will return the last produced error code, or CTM_NO_ERROR (zero) if no error has occured since the last call to ctmGetError(). When this function is called, the internal error varibale will be reset to CTM_NONE.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().

Returns:
  An OpenCTM error code.

See also:
  CTMenum

CTMEXPORT CTMfloat CTMCALL ctmGetFloat | ( | CTMcontext | aContext,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about an OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aProperty | Which property to return.

Returns:
  A floating point value, representing the OpenCTM context property given by `aProperty`.

See also:
  CTMenum

CTMEXPORT const CTMfloat* CTMCALL ctmGetFloatArray | ( | CTMcontext | aContext,
|  | CTMenum | aProperty |
| ) |  |  |

Get a floating point array from an OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aProperty | Which array to return.

Returns:
  A floating point array. If the requested array does not exist, or if `aProperty` does not indicate a float array, the function returns NULL.

Note:
  The array is only valid as long as the OpenCTM context is valid, or until the corresponding array changes within the OpenCTM context. Trying to access an invalid array will result in undefined behaviour. Therefor it is recommended that the array is copied to a new variable if it is to be used other than directly after the call to ctmGetFloatArray().

See also:
  CTMenum

CTMEXPORT CTMuint CTMCALL ctmGetInteger | ( | CTMcontext | aContext,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about an OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aProperty | Which property to return.

Returns:
  An integer value, representing the OpenCTM context property given by `aProperty`.

See also:
  CTMenum

CTMEXPORT const CTMuint* CTMCALL ctmGetIntegerArray | ( | CTMcontext | aContext,
|  | CTMenum | aProperty |
| ) |  |  |

Get an integer array from an OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aProperty | Which array to return.

Returns:
  An integer array. If the requested array does not exist, or if `aProperty` does not indicate an integer array, the function returns NULL.

Note:
  The array is only valid as long as the OpenCTM context is valid, or until the corresponding array changes within the OpenCTM context. Trying to access an invalid array will result in undefined behaviour. Therefor it is recommended that the array is copied to a new variable if it is to be used other than directly after the call to ctmGetIntegerArray().

See also:
  CTMenum

CTMEXPORT CTMenum CTMCALL ctmGetNamedAttribMap | ( | CTMcontext | aContext,
|  | const char * | aName |
| ) |  |  |

Get a reference to the named vertex attribute map.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aName | The name of the attribute map that should be returned.

Returns:
  A reference to an attribute map. If the attribute map was found, a value of CTM_ATTRIB_MAP_1 or higher is returned, otherwise CTM_NONE is returned.

CTMEXPORT CTMenum CTMCALL ctmGetNamedUVMap | ( | CTMcontext | aContext,
|  | const char * | aName |
| ) |  |  |

Get a reference to the named UV map.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aName | The name of the UV map that should be returned.

Returns:
  A reference to a UV map. If the UV map was found, a value of CTM_UV_MAP_1 or higher is returned, otherwise CTM_NONE is returned.

CTMEXPORT const char* CTMCALL ctmGetString | ( | CTMcontext | aContext,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about an OpenCTM context.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aProperty | Which property to return.

Returns:
  A string value, representing the OpenCTM context property given by `aProperty`.

Note:
  The string is only valid as long as the OpenCTM context is valid, or until the corresponding string changes within the OpenCTM context (e.g. calling ctmFileComment() invalidates the CTM_FILE_COMMENT string). Trying to access an invalid string will result in undefined behaviour. Therefor it is recommended that the string is copied to a new variable if it is to be used other than directly after the call to ctmGetString().

See also:
  CTMenum

CTMEXPORT CTMfloat CTMCALL ctmGetUVMapFloat | ( | CTMcontext | aContext,
|  | CTMenum | aUVMap,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about a UV map.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aUVMap | Which UV map to query (CTM_UV_MAP_1 or higher).
  `[in]` | aProperty | Which UV map property to return.

Returns:
  A floating point value, representing the UV map property given by `aProperty`.

See also:
  CTMenum

CTMEXPORT const char* CTMCALL ctmGetUVMapString | ( | CTMcontext | aContext,
|  | CTMenum | aUVMap,
|  | CTMenum | aProperty |
| ) |  |  |

Get information about a UV map.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aUVMap | Which UV map to query (CTM_UV_MAP_1 or higher).
  `[in]` | aProperty | Which UV map property to return.

Returns:
  A string value, representing the UV map property given by `aProperty`.

Note:
  The string is only valid as long as the UV map within the OpenCTM context is valid. Trying to access an invalid string will result in undefined behaviour. Therefor it is recommended that the string is copied to a new variable if it is to be used other than directly after the call to ctmGetUVMapString().

See also:
  CTMenum

CTMEXPORT void CTMCALL ctmLoad | ( | CTMcontext | aContext,
|  | const char * | aFileName |
| ) |  |  |

Load an OpenCTM format file into the context.

The mesh data can be retrieved with the various ctmGet functions.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aFileName | The name of the file to be loaded.

CTMEXPORT void CTMCALL ctmLoadCustom | ( | CTMcontext | aContext,
|  | CTMreadfn | aReadFn,
|  | void * | aUserData |
| ) |  |  |

Load an OpenCTM format file using a custom stream read function.

The mesh data can be retrieved with the various ctmGet functions.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aReadFn | Pointer to a custom stream read function.
  `[in]` | aUserData | Custom user data, which can be a C language FILE handle, C++ istream object, or a custom object pointer of any type. The user data pointer will be passed to the custom stream read function.

See also:
  CTMreadfn.

CTMEXPORT CTMcontext CTMCALL ctmNewContext | ( | CTMenum | aMode | ) |

Create a new OpenCTM context.

The context is used for all subsequent OpenCTM function calls. Several contexts can coexist at the same time.

Parameters:

  `[in]` | aMode | An OpenCTM context mode. Set this to CTM_IMPORT if the context will be used for importing data, or set it to CTM_EXPORT if it will be used for exporting data.

Returns:
  An OpenCTM context handle (or NULL if no context could be created).

CTMEXPORT void CTMCALL ctmNormalPrecision | ( | CTMcontext | aContext,
|  | CTMfloat | aPrecision |
| ) |  |  |

Set the normal precision (only used by the MG2 compression method).

The normal is represented in spherical coordinates in the MG2 compression method, and the normal precision controls the angular and radial resolution.

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aPrecision | Fixed point precision. For the angular information, this value represents the angular precision. For the radial information, this value is the linear resolution. For instance, 0.01 means that the circle is divided into 100 steps, and the normal magnitude is rounded to 2 decimals. The default normal precision is 2^-8 ~= 0.0039.

CTMEXPORT void CTMCALL ctmSave | ( | CTMcontext | aContext,
|  | const char * | aFileName |
| ) |  |  |

Save an OpenCTM format file.

The mesh must have been defined by ctmDefineMesh().

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aFileName | The name of the file to be saved.

CTMEXPORT void CTMCALL ctmSaveCustom | ( | CTMcontext | aContext,
|  | CTMwritefn | aWriteFn,
|  | void * | aUserData |
| ) |  |  |

Save an OpenCTM format file using a custom stream write function.

The mesh must have been defined by ctmDefineMesh().

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aWriteFn | Pointer to a custom stream write function.
  `[in]` | aUserData | Custom user data, which can be a C language FILE handle, C++ ostream object, or a custom object pointer of any type. The user data pointer will be passed to the custom stream write function.

See also:
  CTMwritefn.

CTMEXPORT void CTMCALL ctmUVCoordPrecision | ( | CTMcontext | aContext,
|  | CTMenum | aUVMap,
|  | CTMfloat | aPrecision |
| ) |  |  |

Set the coordinate precision for the specified UV map (only used by the MG2 compression method).

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aUVMap | A UV map specifier for a defined UV map (CTM_UV_MAP_1, ...).
  `[in]` | aPrecision | Fixed point precision. For instance, if this value is 0.001, all UV coordinates will be rounded to three decimals. The default UV coordinate precision is 2^-12 ~= 0.00024.

See also:
  ctmAddUVMap().

CTMEXPORT void CTMCALL ctmVertexPrecision | ( | CTMcontext | aContext,
|  | CTMfloat | aPrecision |
| ) |  |  |

Set the vertex coordinate precision (only used by the MG2 compression method).

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aPrecision | Fixed point precision. For instance, if this value is 0.001, all vertex coordinates will be rounded to three decimals. The default vertex coordinate precision is 2^-10 ~= 0.00098.

CTMEXPORT void CTMCALL ctmVertexPrecisionRel | ( | CTMcontext | aContext,
|  | CTMfloat | aRelPrecision |
| ) |  |  |

Set the vertex coordinate precision, relative to the mesh dimensions (only used by the MG2 compression method).

Parameters:

  `[in]` | aContext | An OpenCTM context that has been created by ctmNewContext().
  `[in]` | aRelPrecision | Relative precision. This factor is multiplied by the average triangle edge length in the mesh in order to obtain the final, fixed point precision. For instance, if aRelPrecision is 0.01, and the average edge length is 3.7, then the fixed point precision is set to 0.037.

Note:
  The mesh must have been defined using the ctmDefineMesh() function before calling this function.

See also:
  ctmVertexPrecision().

Copyright © 2009-2010 Marcus Geelnard — openctm.sourceforge.net