vrshoot
diff libs/assimp/assimp/cexport.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/assimp/cexport.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,242 @@ 1.4 +/* 1.5 +--------------------------------------------------------------------------- 1.6 +Open Asset Import Library (assimp) 1.7 +--------------------------------------------------------------------------- 1.8 + 1.9 +Copyright (c) 2006-2011, assimp team 1.10 + 1.11 +All rights reserved. 1.12 + 1.13 +Redistribution and use of this software in source and binary forms, 1.14 +with or without modification, are permitted provided that the following 1.15 +conditions are met: 1.16 + 1.17 +* Redistributions of source code must retain the above 1.18 +copyright notice, this list of conditions and the 1.19 +following disclaimer. 1.20 + 1.21 +* Redistributions in binary form must reproduce the above 1.22 +copyright notice, this list of conditions and the 1.23 +following disclaimer in the documentation and/or other 1.24 +materials provided with the distribution. 1.25 + 1.26 +* Neither the name of the assimp team, nor the names of its 1.27 +contributors may be used to endorse or promote products 1.28 +derived from this software without specific prior 1.29 +written permission of the assimp team. 1.30 + 1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.42 +--------------------------------------------------------------------------- 1.43 +*/ 1.44 + 1.45 +/** @file cexport.h 1.46 +* @brief Defines the C-API for the Assimp export interface 1.47 +*/ 1.48 +#ifndef AI_EXPORT_H_INC 1.49 +#define AI_EXPORT_H_INC 1.50 + 1.51 +#ifndef ASSIMP_BUILD_NO_EXPORT 1.52 + 1.53 +#include "types.h" 1.54 + 1.55 +#ifdef __cplusplus 1.56 +extern "C" { 1.57 +#endif 1.58 + 1.59 +struct aiScene; // aiScene.h 1.60 +struct aiFileIO; // aiFileIO.h 1.61 + 1.62 +// -------------------------------------------------------------------------------- 1.63 +/** Describes an file format which Assimp can export to. Use #aiGetExportFormatCount() to 1.64 +* learn how many export formats the current Assimp build supports and #aiGetExportFormatDescription() 1.65 +* to retrieve a description of an export format option. 1.66 +*/ 1.67 +struct aiExportFormatDesc 1.68 +{ 1.69 + /// a short string ID to uniquely identify the export format. Use this ID string to 1.70 + /// specify which file format you want to export to when calling #aiExportScene(). 1.71 + /// Example: "dae" or "obj" 1.72 + const char* id; 1.73 + 1.74 + /// A short description of the file format to present to users. Useful if you want 1.75 + /// to allow the user to select an export format. 1.76 + const char* description; 1.77 + 1.78 + /// Recommended file extension for the exported file in lower case. 1.79 + const char* fileExtension; 1.80 +}; 1.81 + 1.82 + 1.83 +// -------------------------------------------------------------------------------- 1.84 +/** Returns the number of export file formats available in the current Assimp build. 1.85 + * Use aiGetExportFormatDescription() to retrieve infos of a specific export format. 1.86 + */ 1.87 +ASSIMP_API size_t aiGetExportFormatCount(void); 1.88 + 1.89 + 1.90 +// -------------------------------------------------------------------------------- 1.91 +/** Returns a description of the nth export file format. Use #aiGetExportFormatCount() 1.92 + * to learn how many export formats are supported. 1.93 + * @param pIndex Index of the export format to retrieve information for. Valid range is 1.94 + * 0 to #aiGetExportFormatCount() 1.95 + * @return A description of that specific export format. NULL if pIndex is out of range. 1.96 + */ 1.97 +ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex); 1.98 + 1.99 + 1.100 +// -------------------------------------------------------------------------------- 1.101 +/** Create a modifyable copy of a scene. 1.102 + * This is useful to import files via Assimp, change their topology and 1.103 + * export them again. Since the scene returned by the various importer functions 1.104 + * is const, a modifyable copy is needed. 1.105 + * @param pIn Valid scene to be copied 1.106 + * @param pOut Receives a modifyable copy of the scene. 1.107 + */ 1.108 +ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn, 1.109 + C_STRUCT aiScene** pOut); 1.110 + 1.111 +// -------------------------------------------------------------------------------- 1.112 +/** Exports the given scene to a chosen file format and writes the result file(s) to disk. 1.113 +* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. 1.114 +* The scene is expected to conform to Assimp's Importer output format as specified 1.115 +* in the @link data Data Structures Page @endlink. In short, this means the model data 1.116 +* should use a right-handed coordinate systems, face winding should be counter-clockwise 1.117 +* and the UV coordinate origin is assumed to be in the upper left. If your input data 1.118 +* uses different conventions, have a look at the last parameter. 1.119 +* @param pFormatId ID string to specify to which format you want to export to. Use 1.120 +* aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available. 1.121 +* @param pFileName Output file to write 1.122 +* @param pIO custom IO implementation to be used. Use this if you use your own storage methods. 1.123 +* If none is supplied, a default implementation using standard file IO is used. Note that 1.124 +* #aiExportSceneToBlob is provided as convenience function to export to memory buffers. 1.125 +* @param pPreprocessing Accepts any choice of the #aiPostProcessing enumerated 1.126 +* flags, but in reality only a subset of them makes sense here. Specifying 1.127 +* 'preprocessing' flags is useful if the input scene does not conform to 1.128 +* Assimp's default conventions as specified in the @link data Data Structures Page @endlink. 1.129 +* In short, this means the geometry data should use a right-handed coordinate systems, face 1.130 +* winding should be counter-clockwise and the UV coordinate origin is assumed to be in 1.131 +* the upper left. The #aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and 1.132 +* #aiProcess_FlipWindingOrder flags are used in the import side to allow users 1.133 +* to have those defaults automatically adapted to their conventions. Specifying those flags 1.134 +* for exporting has the opposite effect, respectively. Some other of the 1.135 +* #aiPostProcessSteps enumerated values may be useful as well, but you'll need 1.136 +* to try out what their effect on the exported file is. Many formats impose 1.137 +* their own restrictions on the structure of the geometry stored therein, 1.138 +* so some preprocessing may have little or no effect at all, or may be 1.139 +* redundant as exporters would apply them anyhow. A good example 1.140 +* is triangulation - whilst you can enforce it by specifying 1.141 +* the #aiProcess_Triangulate flag, most export formats support only 1.142 +* triangulate data so they would run the step anyway. 1.143 +* @return a status code indicating the result of the export 1.144 +*/ 1.145 +ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, 1.146 + const char* pFormatId, 1.147 + const char* pFileName, 1.148 + unsigned int pPreprocessing); 1.149 + 1.150 + 1.151 +// -------------------------------------------------------------------------------- 1.152 +/** Exports the given scene to a chosen file format using custom IO logic supplied by you. 1.153 +* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. 1.154 +* @param pFormatId ID string to specify to which format you want to export to. Use 1.155 +* aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available. 1.156 +* @param pFileName Output file to write 1.157 +* @param pIO custom IO implementation to be used. Use this if you use your own storage methods. 1.158 +* If none is supplied, a default implementation using standard file IO is used. Note that 1.159 +* #aiExportSceneToBlob is provided as convenience function to export to memory buffers. 1.160 +* @param pPreprocessing Please see the documentation for #aiExportScene 1.161 +* @return a status code indicating the result of the export 1.162 +* @note Include <aiFileIO.h> for the definition of #aiFileIO. 1.163 +*/ 1.164 +ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, 1.165 + const char* pFormatId, 1.166 + const char* pFileName, 1.167 + C_STRUCT aiFileIO* pIO, 1.168 + unsigned int pPreprocessing ); 1.169 + 1.170 + 1.171 +// -------------------------------------------------------------------------------- 1.172 +/** Describes a blob of exported scene data. Use #aiExportSceneToBlob() to create a blob containing an 1.173 +* exported scene. The memory referred by this structure is owned by Assimp. Use #aiReleaseExportedFile() 1.174 +* to free its resources. Don't try to free the memory on your side - it will crash for most build configurations 1.175 +* due to conflicting heaps. 1.176 +* 1.177 +* Blobs can be nested - each blob may reference another blob, which may in turn reference another blob and so on. 1.178 +* This is used when exporters write more than one output file for a given #aiScene. See the remarks for 1.179 +* #aiExportDataBlob::name for more information. 1.180 +*/ 1.181 +struct aiExportDataBlob 1.182 +{ 1.183 + /// Size of the data in bytes 1.184 + size_t size; 1.185 + 1.186 + /// The data. 1.187 + void* data; 1.188 + 1.189 + /** Name of the blob. An empty string always 1.190 + indicates the first (and primary) blob, 1.191 + which contains the actual file data. 1.192 + Any other blobs are auxiliary files produced 1.193 + by exporters (i.e. material files). Existence 1.194 + of such files depends on the file format. Most 1.195 + formats don't split assets across multiple files. 1.196 + 1.197 + If used, blob names usually contain the file 1.198 + extension that should be used when writing 1.199 + the data to disc. 1.200 + */ 1.201 + aiString name; 1.202 + 1.203 + /** Pointer to the next blob in the chain or NULL if there is none. */ 1.204 + aiExportDataBlob * next; 1.205 + 1.206 +#ifdef __cplusplus 1.207 + /// Default constructor 1.208 + aiExportDataBlob() { size = 0; data = next = NULL; } 1.209 + /// Releases the data 1.210 + ~aiExportDataBlob() { delete [] static_cast<unsigned char*>( data ); delete next; } 1.211 + 1.212 +private: 1.213 + // no copying 1.214 + aiExportDataBlob(const aiExportDataBlob& ); 1.215 + aiExportDataBlob& operator= (const aiExportDataBlob& ); 1.216 +#endif // __cplusplus 1.217 +}; 1.218 + 1.219 +// -------------------------------------------------------------------------------- 1.220 +/** Exports the given scene to a chosen file format. Returns the exported data as a binary blob which 1.221 +* you can write into a file or something. When you're done with the data, use #aiReleaseExportBlob() 1.222 +* to free the resources associated with the export. 1.223 +* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. 1.224 +* @param pFormatId ID string to specify to which format you want to export to. Use 1.225 +* #aiGetExportFormatCount() / #aiGetExportFormatDescription() to learn which export formats are available. 1.226 +* @param pPreprocessing Please see the documentation for #aiExportScene 1.227 +* @return the exported data or NULL in case of error 1.228 +*/ 1.229 +ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing ); 1.230 + 1.231 + 1.232 +// -------------------------------------------------------------------------------- 1.233 +/** Releases the memory associated with the given exported data. Use this function to free a data blob 1.234 +* returned by aiExportScene(). 1.235 +* @param pData the data blob returned by #aiExportSceneToBlob 1.236 +*/ 1.237 +ASSIMP_API C_STRUCT void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData ); 1.238 + 1.239 +#ifdef __cplusplus 1.240 +} 1.241 +#endif 1.242 + 1.243 +#endif // ASSIMP_BUILD_NO_EXPORT 1.244 +#endif // AI_EXPORT_H_INC 1.245 +