goat3d

diff libs/openctm/internal.h @ 14:188c697b3b49

- added a document describing the goat3d file format chunk hierarchy - started an alternative XML-based file format - added the openctm library
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Sep 2013 04:47:05 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/openctm/internal.h	Thu Sep 26 04:47:05 2013 +0300
     1.3 @@ -0,0 +1,147 @@
     1.4 +//-----------------------------------------------------------------------------
     1.5 +// Product:     OpenCTM
     1.6 +// File:        internal.h
     1.7 +// Description: Internal (private) declarations, types and function prototypes.
     1.8 +//-----------------------------------------------------------------------------
     1.9 +// Copyright (c) 2009-2010 Marcus Geelnard
    1.10 +//
    1.11 +// This software is provided 'as-is', without any express or implied
    1.12 +// warranty. In no event will the authors be held liable for any damages
    1.13 +// arising from the use of this software.
    1.14 +//
    1.15 +// Permission is granted to anyone to use this software for any purpose,
    1.16 +// including commercial applications, and to alter it and redistribute it
    1.17 +// freely, subject to the following restrictions:
    1.18 +//
    1.19 +//     1. The origin of this software must not be misrepresented; you must not
    1.20 +//     claim that you wrote the original software. If you use this software
    1.21 +//     in a product, an acknowledgment in the product documentation would be
    1.22 +//     appreciated but is not required.
    1.23 +//
    1.24 +//     2. Altered source versions must be plainly marked as such, and must not
    1.25 +//     be misrepresented as being the original software.
    1.26 +//
    1.27 +//     3. This notice may not be removed or altered from any source
    1.28 +//     distribution.
    1.29 +//-----------------------------------------------------------------------------
    1.30 +
    1.31 +#ifndef __OPENCTM_INTERNAL_H_
    1.32 +#define __OPENCTM_INTERNAL_H_
    1.33 +
    1.34 +//-----------------------------------------------------------------------------
    1.35 +// Constants
    1.36 +//-----------------------------------------------------------------------------
    1.37 +// OpenCTM file format version (v5).
    1.38 +#define _CTM_FORMAT_VERSION  0x00000005
    1.39 +
    1.40 +// Flags for the Mesh flags field of the file header
    1.41 +#define _CTM_HAS_NORMALS_BIT 0x00000001
    1.42 +
    1.43 +//-----------------------------------------------------------------------------
    1.44 +// _CTMfloatmap - Internal representation of a floating point based vertex map
    1.45 +// (used for UV maps and attribute maps).
    1.46 +//-----------------------------------------------------------------------------
    1.47 +typedef struct _CTMfloatmap_struct _CTMfloatmap;
    1.48 +struct _CTMfloatmap_struct {
    1.49 +  char * mName;         // Unique name
    1.50 +  char * mFileName;     // File name reference (used only for UV maps)
    1.51 +  CTMfloat mPrecision;  // Precision for this map
    1.52 +  CTMfloat * mValues;   // Attribute/UV coordinate values (per vertex)
    1.53 +  _CTMfloatmap * mNext; // Pointer to the next map in the list (linked list)
    1.54 +};
    1.55 +
    1.56 +//-----------------------------------------------------------------------------
    1.57 +// _CTMcontext - Internal CTM context structure.
    1.58 +//-----------------------------------------------------------------------------
    1.59 +typedef struct {
    1.60 +  // Context mode (import or export)
    1.61 +  CTMenum mMode;
    1.62 +
    1.63 +  // Vertices
    1.64 +  CTMfloat * mVertices;
    1.65 +  CTMuint mVertexCount;
    1.66 +
    1.67 +  // Indices
    1.68 +  CTMuint * mIndices;
    1.69 +  CTMuint mTriangleCount;
    1.70 +
    1.71 +  // Normals (optional)
    1.72 +  CTMfloat * mNormals;
    1.73 +
    1.74 +  // Multiple sets of UV coordinate maps (optional)
    1.75 +  CTMuint mUVMapCount;
    1.76 +  _CTMfloatmap * mUVMaps;
    1.77 +
    1.78 +  // Multiple sets of custom vertex attribute maps (optional)
    1.79 +  CTMuint mAttribMapCount;
    1.80 +  _CTMfloatmap * mAttribMaps;
    1.81 +
    1.82 +  // Last error code
    1.83 +  CTMenum mError;
    1.84 +
    1.85 +  // The selected compression method
    1.86 +  CTMenum mMethod;
    1.87 +
    1.88 +  // The selected compression level
    1.89 +  CTMuint mCompressionLevel;
    1.90 +
    1.91 +  // Vertex coordinate precision
    1.92 +  CTMfloat mVertexPrecision;
    1.93 +
    1.94 +  // Normal precision (angular + magnitude)
    1.95 +  CTMfloat mNormalPrecision;
    1.96 +
    1.97 +  // File comment
    1.98 +  char * mFileComment;
    1.99 +
   1.100 +  // Read() function pointer
   1.101 +  CTMreadfn mReadFn;
   1.102 +
   1.103 +  // Write() function pointer
   1.104 +  CTMwritefn mWriteFn;
   1.105 +
   1.106 +  // User data (for stream read/write - usually the stream handle)
   1.107 +  void * mUserData;
   1.108 +} _CTMcontext;
   1.109 +
   1.110 +//-----------------------------------------------------------------------------
   1.111 +// Macros
   1.112 +//-----------------------------------------------------------------------------
   1.113 +#define FOURCC(str) (((CTMuint) str[0]) | (((CTMuint) str[1]) << 8) | \
   1.114 +                    (((CTMuint) str[2]) << 16) | (((CTMuint) str[3]) << 24))
   1.115 +
   1.116 +//-----------------------------------------------------------------------------
   1.117 +// Funcion prototypes for stream.c
   1.118 +//-----------------------------------------------------------------------------
   1.119 +CTMuint _ctmStreamRead(_CTMcontext * self, void * aBuf, CTMuint aCount);
   1.120 +CTMuint _ctmStreamWrite(_CTMcontext * self, void * aBuf, CTMuint aCount);
   1.121 +CTMuint _ctmStreamReadUINT(_CTMcontext * self);
   1.122 +void _ctmStreamWriteUINT(_CTMcontext * self, CTMuint aValue);
   1.123 +CTMfloat _ctmStreamReadFLOAT(_CTMcontext * self);
   1.124 +void _ctmStreamWriteFLOAT(_CTMcontext * self, CTMfloat aValue);
   1.125 +void _ctmStreamReadSTRING(_CTMcontext * self, char ** aValue);
   1.126 +void _ctmStreamWriteSTRING(_CTMcontext * self, const char * aValue);
   1.127 +int _ctmStreamReadPackedInts(_CTMcontext * self, CTMint * aData, CTMuint aCount, CTMuint aSize, CTMint aSignedInts);
   1.128 +int _ctmStreamWritePackedInts(_CTMcontext * self, CTMint * aData, CTMuint aCount, CTMuint aSize, CTMint aSignedInts);
   1.129 +int _ctmStreamReadPackedFloats(_CTMcontext * self, CTMfloat * aData, CTMuint aCount, CTMuint aSize);
   1.130 +int _ctmStreamWritePackedFloats(_CTMcontext * self, CTMfloat * aData, CTMuint aCount, CTMuint aSize);
   1.131 +
   1.132 +//-----------------------------------------------------------------------------
   1.133 +// Funcion prototypes for compressRAW.c
   1.134 +//-----------------------------------------------------------------------------
   1.135 +int _ctmCompressMesh_RAW(_CTMcontext * self);
   1.136 +int _ctmUncompressMesh_RAW(_CTMcontext * self);
   1.137 +
   1.138 +//-----------------------------------------------------------------------------
   1.139 +// Funcion prototypes for compressMG1.c
   1.140 +//-----------------------------------------------------------------------------
   1.141 +int _ctmCompressMesh_MG1(_CTMcontext * self);
   1.142 +int _ctmUncompressMesh_MG1(_CTMcontext * self);
   1.143 +
   1.144 +//-----------------------------------------------------------------------------
   1.145 +// Funcion prototypes for compressMG2.c
   1.146 +//-----------------------------------------------------------------------------
   1.147 +int _ctmCompressMesh_MG2(_CTMcontext * self);
   1.148 +int _ctmUncompressMesh_MG2(_CTMcontext * self);
   1.149 +
   1.150 +#endif // __OPENCTM_INTERNAL_H_