goat3d
view libs/openctm/internal.h @ 17:1d85d7dd0038
goatprim done
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 27 Sep 2013 02:29:52 +0300 |
parents | |
children |
line source
1 //-----------------------------------------------------------------------------
2 // Product: OpenCTM
3 // File: internal.h
4 // Description: Internal (private) declarations, types and function prototypes.
5 //-----------------------------------------------------------------------------
6 // Copyright (c) 2009-2010 Marcus Geelnard
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not
22 // be misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
26 //-----------------------------------------------------------------------------
28 #ifndef __OPENCTM_INTERNAL_H_
29 #define __OPENCTM_INTERNAL_H_
31 //-----------------------------------------------------------------------------
32 // Constants
33 //-----------------------------------------------------------------------------
34 // OpenCTM file format version (v5).
35 #define _CTM_FORMAT_VERSION 0x00000005
37 // Flags for the Mesh flags field of the file header
38 #define _CTM_HAS_NORMALS_BIT 0x00000001
40 //-----------------------------------------------------------------------------
41 // _CTMfloatmap - Internal representation of a floating point based vertex map
42 // (used for UV maps and attribute maps).
43 //-----------------------------------------------------------------------------
44 typedef struct _CTMfloatmap_struct _CTMfloatmap;
45 struct _CTMfloatmap_struct {
46 char * mName; // Unique name
47 char * mFileName; // File name reference (used only for UV maps)
48 CTMfloat mPrecision; // Precision for this map
49 CTMfloat * mValues; // Attribute/UV coordinate values (per vertex)
50 _CTMfloatmap * mNext; // Pointer to the next map in the list (linked list)
51 };
53 //-----------------------------------------------------------------------------
54 // _CTMcontext - Internal CTM context structure.
55 //-----------------------------------------------------------------------------
56 typedef struct {
57 // Context mode (import or export)
58 CTMenum mMode;
60 // Vertices
61 CTMfloat * mVertices;
62 CTMuint mVertexCount;
64 // Indices
65 CTMuint * mIndices;
66 CTMuint mTriangleCount;
68 // Normals (optional)
69 CTMfloat * mNormals;
71 // Multiple sets of UV coordinate maps (optional)
72 CTMuint mUVMapCount;
73 _CTMfloatmap * mUVMaps;
75 // Multiple sets of custom vertex attribute maps (optional)
76 CTMuint mAttribMapCount;
77 _CTMfloatmap * mAttribMaps;
79 // Last error code
80 CTMenum mError;
82 // The selected compression method
83 CTMenum mMethod;
85 // The selected compression level
86 CTMuint mCompressionLevel;
88 // Vertex coordinate precision
89 CTMfloat mVertexPrecision;
91 // Normal precision (angular + magnitude)
92 CTMfloat mNormalPrecision;
94 // File comment
95 char * mFileComment;
97 // Read() function pointer
98 CTMreadfn mReadFn;
100 // Write() function pointer
101 CTMwritefn mWriteFn;
103 // User data (for stream read/write - usually the stream handle)
104 void * mUserData;
105 } _CTMcontext;
107 //-----------------------------------------------------------------------------
108 // Macros
109 //-----------------------------------------------------------------------------
110 #define FOURCC(str) (((CTMuint) str[0]) | (((CTMuint) str[1]) << 8) | \
111 (((CTMuint) str[2]) << 16) | (((CTMuint) str[3]) << 24))
113 //-----------------------------------------------------------------------------
114 // Funcion prototypes for stream.c
115 //-----------------------------------------------------------------------------
116 CTMuint _ctmStreamRead(_CTMcontext * self, void * aBuf, CTMuint aCount);
117 CTMuint _ctmStreamWrite(_CTMcontext * self, void * aBuf, CTMuint aCount);
118 CTMuint _ctmStreamReadUINT(_CTMcontext * self);
119 void _ctmStreamWriteUINT(_CTMcontext * self, CTMuint aValue);
120 CTMfloat _ctmStreamReadFLOAT(_CTMcontext * self);
121 void _ctmStreamWriteFLOAT(_CTMcontext * self, CTMfloat aValue);
122 void _ctmStreamReadSTRING(_CTMcontext * self, char ** aValue);
123 void _ctmStreamWriteSTRING(_CTMcontext * self, const char * aValue);
124 int _ctmStreamReadPackedInts(_CTMcontext * self, CTMint * aData, CTMuint aCount, CTMuint aSize, CTMint aSignedInts);
125 int _ctmStreamWritePackedInts(_CTMcontext * self, CTMint * aData, CTMuint aCount, CTMuint aSize, CTMint aSignedInts);
126 int _ctmStreamReadPackedFloats(_CTMcontext * self, CTMfloat * aData, CTMuint aCount, CTMuint aSize);
127 int _ctmStreamWritePackedFloats(_CTMcontext * self, CTMfloat * aData, CTMuint aCount, CTMuint aSize);
129 //-----------------------------------------------------------------------------
130 // Funcion prototypes for compressRAW.c
131 //-----------------------------------------------------------------------------
132 int _ctmCompressMesh_RAW(_CTMcontext * self);
133 int _ctmUncompressMesh_RAW(_CTMcontext * self);
135 //-----------------------------------------------------------------------------
136 // Funcion prototypes for compressMG1.c
137 //-----------------------------------------------------------------------------
138 int _ctmCompressMesh_MG1(_CTMcontext * self);
139 int _ctmUncompressMesh_MG1(_CTMcontext * self);
141 //-----------------------------------------------------------------------------
142 // Funcion prototypes for compressMG2.c
143 //-----------------------------------------------------------------------------
144 int _ctmCompressMesh_MG2(_CTMcontext * self);
145 int _ctmUncompressMesh_MG2(_CTMcontext * self);
147 #endif // __OPENCTM_INTERNAL_H_