#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 CTM_API_VERSION 0x00000100 |
OpenCTM API version (1.0).
#define CTM_FALSE 0 |
Boolean FALSE.
#define CTM_TRUE 1 |
Boolean TRUE.
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).
Stream read() function pointer.
[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. |
typedef uint32_t CTMuint |
Unsigned integer (32 bits wide).
typedef CTMuint(CTMCALL * CTMwritefn)(const void *aBuf, CTMuint aCount, void *aUserData) |
Stream write() function pointer.
[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. |
enum CTMenum |
OpenCTM specific enumerators.
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.
[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). |
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.
[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. |
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).
[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. |
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.
[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.
[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). |
CTMEXPORT void CTMCALL ctmDefineMesh | ( | CTMcontext | aContext, | |
const CTMfloat * | aVertices, | |||
CTMuint | aVertexCount, | |||
const CTMuint * | aIndices, | |||
CTMuint | aTriangleCount, | |||
const CTMfloat * | aNormals | |||
) |
Define a triangle mesh.
[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. |
CTMEXPORT const char* CTMCALL ctmErrorString | ( | CTMenum | aError | ) |
Converts an OpenCTM error code to a zero-terminated string.
[in] | aError | An OpenCTM error code, as returned by ctmGetError(). |
aError
is CTM_INVALID_OPERATION, then the return value will be "CTM_INVALID_OPERATION". CTMEXPORT void CTMCALL ctmFileComment | ( | CTMcontext | aContext, | |
const char * | aFileComment | |||
) |
Set the file comment for the given OpenCTM context.
[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.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
CTMEXPORT CTMfloat CTMCALL ctmGetAttribMapFloat | ( | CTMcontext | aContext, | |
CTMenum | aAttribMap, | |||
CTMenum | aProperty | |||
) |
Get information about a vertex attribute map.
[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. |
aProperty
. CTMEXPORT const char* CTMCALL ctmGetAttribMapString | ( | CTMcontext | aContext, | |
CTMenum | aAttribMap, | |||
CTMenum | aProperty | |||
) |
Get information about a vertex attribute map.
[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. |
aProperty
. 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.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
CTMEXPORT CTMfloat CTMCALL ctmGetFloat | ( | CTMcontext | aContext, | |
CTMenum | aProperty | |||
) |
Get information about an OpenCTM context.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aProperty | Which property to return. |
aProperty
. CTMEXPORT const CTMfloat* CTMCALL ctmGetFloatArray | ( | CTMcontext | aContext, | |
CTMenum | aProperty | |||
) |
Get a floating point array from an OpenCTM context.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aProperty | Which array to return. |
aProperty
does not indicate a float array, the function returns NULL. CTMEXPORT CTMuint CTMCALL ctmGetInteger | ( | CTMcontext | aContext, | |
CTMenum | aProperty | |||
) |
Get information about an OpenCTM context.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aProperty | Which property to return. |
aProperty
. CTMEXPORT const CTMuint* CTMCALL ctmGetIntegerArray | ( | CTMcontext | aContext, | |
CTMenum | aProperty | |||
) |
Get an integer array from an OpenCTM context.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aProperty | Which array to return. |
aProperty
does not indicate an integer array, the function returns NULL. CTMEXPORT CTMenum CTMCALL ctmGetNamedAttribMap | ( | CTMcontext | aContext, | |
const char * | aName | |||
) |
Get a reference to the named vertex attribute map.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aName | The name of the attribute map that should be returned. |
CTMEXPORT CTMenum CTMCALL ctmGetNamedUVMap | ( | CTMcontext | aContext, | |
const char * | aName | |||
) |
Get a reference to the named UV map.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aName | The name of the UV map that should be returned. |
CTMEXPORT const char* CTMCALL ctmGetString | ( | CTMcontext | aContext, | |
CTMenum | aProperty | |||
) |
Get information about an OpenCTM context.
[in] | aContext | An OpenCTM context that has been created by ctmNewContext(). |
[in] | aProperty | Which property to return. |
aProperty
. CTMEXPORT CTMfloat CTMCALL ctmGetUVMapFloat | ( | CTMcontext | aContext, | |
CTMenum | aUVMap, | |||
CTMenum | aProperty | |||
) |
Get information about a UV map.
[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. |
aProperty
. CTMEXPORT const char* CTMCALL ctmGetUVMapString | ( | CTMcontext | aContext, | |
CTMenum | aUVMap, | |||
CTMenum | aProperty | |||
) |
Get information about a UV map.
[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. |
aProperty
. 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.
[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.
[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. |
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.
[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. |
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.
[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().
[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().
[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. |
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).
[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. |
CTMEXPORT void CTMCALL ctmVertexPrecision | ( | CTMcontext | aContext, | |
CTMfloat | aPrecision | |||
) |
Set the vertex coordinate precision (only used by the MG2 compression method).
[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).
[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. |
Copyright © 2009-2010 Marcus Geelnard — openctm.sourceforge.net