vrshoot

view libs/assimp/assimp/cimport.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
6 Copyright (c) 2006-2012, assimp team
8 All rights reserved.
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
14 * Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
18 * Redistributions in binary form must reproduce the above
19 copyright notice, this list of conditions and the
20 following disclaimer in the documentation and/or other
21 materials provided with the distribution.
23 * Neither the name of the assimp team, nor the names of its
24 contributors may be used to endorse or promote products
25 derived from this software without specific prior
26 written permission of the assimp team.
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
42 /** @file assimp.h
43 * @brief Defines the C-API to the Open Asset Import Library.
44 */
45 #ifndef AI_ASSIMP_H_INC
46 #define AI_ASSIMP_H_INC
47 #include "types.h"
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
53 struct aiScene; // aiScene.h
54 struct aiFileIO; // aiFileIO.h
55 typedef void (*aiLogStreamCallback)(const char* /* message */, char* /* user */);
57 // --------------------------------------------------------------------------------
58 /** C-API: Represents a log stream. A log stream receives all log messages and
59 * streams them _somewhere_.
60 * @see aiGetPredefinedLogStream
61 * @see aiAttachLogStream
62 * @see aiDetachLogStream */
63 // --------------------------------------------------------------------------------
64 struct aiLogStream
65 {
66 /** callback to be called */
67 aiLogStreamCallback callback;
69 /** user data to be passed to the callback */
70 char* user;
71 };
74 // --------------------------------------------------------------------------------
75 /** C-API: Represents an opaque set of settings to be used during importing.
76 * @see aiCreatePropertyStore
77 * @see aiReleasePropertyStore
78 * @see aiImportFileExWithProperties
79 * @see aiSetPropertyInteger
80 * @see aiSetPropertyFloat
81 * @see aiSetPropertyString
82 */
83 // --------------------------------------------------------------------------------
84 struct aiPropertyStore { char sentinel; };
86 /** Our own C boolean type */
87 typedef int aiBool;
89 #define AI_FALSE 0
90 #define AI_TRUE 1
92 // --------------------------------------------------------------------------------
93 /** Reads the given file and returns its content.
94 *
95 * If the call succeeds, the imported data is returned in an aiScene structure.
96 * The data is intended to be read-only, it stays property of the ASSIMP
97 * library and will be stable until aiReleaseImport() is called. After you're
98 * done with it, call aiReleaseImport() to free the resources associated with
99 * this file. If the import fails, NULL is returned instead. Call
100 * aiGetErrorString() to retrieve a human-readable error text.
101 * @param pFile Path and filename of the file to be imported,
102 * expected to be a null-terminated c-string. NULL is not a valid value.
103 * @param pFlags Optional post processing steps to be executed after
104 * a successful import. Provide a bitwise combination of the
105 * #aiPostProcessSteps flags.
106 * @return Pointer to the imported data or NULL if the import failed.
107 */
108 ASSIMP_API const C_STRUCT aiScene* aiImportFile(
109 const char* pFile,
110 unsigned int pFlags);
112 // --------------------------------------------------------------------------------
113 /** Reads the given file using user-defined I/O functions and returns
114 * its content.
115 *
116 * If the call succeeds, the imported data is returned in an aiScene structure.
117 * The data is intended to be read-only, it stays property of the ASSIMP
118 * library and will be stable until aiReleaseImport() is called. After you're
119 * done with it, call aiReleaseImport() to free the resources associated with
120 * this file. If the import fails, NULL is returned instead. Call
121 * aiGetErrorString() to retrieve a human-readable error text.
122 * @param pFile Path and filename of the file to be imported,
123 * expected to be a null-terminated c-string. NULL is not a valid value.
124 * @param pFlags Optional post processing steps to be executed after
125 * a successful import. Provide a bitwise combination of the
126 * #aiPostProcessSteps flags.
127 * @param pFS aiFileIO structure. Will be used to open the model file itself
128 * and any other files the loader needs to open. Pass NULL to use the default
129 * implementation.
130 * @return Pointer to the imported data or NULL if the import failed.
131 * @note Include <aiFileIO.h> for the definition of #aiFileIO.
132 */
133 ASSIMP_API const C_STRUCT aiScene* aiImportFileEx(
134 const char* pFile,
135 unsigned int pFlags,
136 C_STRUCT aiFileIO* pFS);
138 // --------------------------------------------------------------------------------
139 /** Same as #aiImportFileEx, but adds an extra parameter containing importer settings.
140 *
141 * @param pProps #aiPropertyStore instance containing import settings.
142 * @see aiImportFileEx
143 */
144 ASSIMP_API const C_STRUCT aiScene* aiImportFileExWithProperties(
145 const char* pFile,
146 unsigned int pFlags,
147 C_STRUCT aiFileIO* pFS,
148 const C_STRUCT aiPropertyStore* pProps);
150 // --------------------------------------------------------------------------------
151 /** Reads the given file from a given memory buffer,
152 *
153 * If the call succeeds, the contents of the file are returned as a pointer to an
154 * aiScene object. The returned data is intended to be read-only, the importer keeps
155 * ownership of the data and will destroy it upon destruction. If the import fails,
156 * NULL is returned.
157 * A human-readable error description can be retrieved by calling aiGetErrorString().
158 * @param pBuffer Pointer to the file data
159 * @param pLength Length of pBuffer, in bytes
160 * @param pFlags Optional post processing steps to be executed after
161 * a successful import. Provide a bitwise combination of the
162 * #aiPostProcessSteps flags. If you wish to inspect the imported
163 * scene first in order to fine-tune your post-processing setup,
164 * consider to use #aiApplyPostProcessing().
165 * @param pHint An additional hint to the library. If this is a non empty string,
166 * the library looks for a loader to support the file extension specified by pHint
167 * and passes the file to the first matching loader. If this loader is unable to
168 * completely the request, the library continues and tries to determine the file
169 * format on its own, a task that may or may not be successful.
170 * Check the return value, and you'll know ...
171 * @return A pointer to the imported data, NULL if the import failed.
172 *
173 * @note This is a straightforward way to decode models from memory
174 * buffers, but it doesn't handle model formats that spread their
175 * data across multiple files or even directories. Examples include
176 * OBJ or MD3, which outsource parts of their material info into
177 * external scripts. If you need full functionality, provide
178 * a custom IOSystem to make Assimp find these files and use
179 * the regular aiImportFileEx()/aiImportFileExWithProperties() API.
180 */
181 ASSIMP_API const C_STRUCT aiScene* aiImportFileFromMemory(
182 const char* pBuffer,
183 unsigned int pLength,
184 unsigned int pFlags,
185 const char* pHint);
187 // --------------------------------------------------------------------------------
188 /** Same as #aiImportFileFromMemory, but adds an extra parameter containing importer settings.
189 *
190 * @param pProps #aiPropertyStore instance containing import settings.
191 * @see aiImportFileFromMemory
192 */
193 ASSIMP_API const C_STRUCT aiScene* aiImportFileFromMemoryWithProperties(
194 const char* pBuffer,
195 unsigned int pLength,
196 unsigned int pFlags,
197 const char* pHint,
198 const C_STRUCT aiPropertyStore* pProps);
200 // --------------------------------------------------------------------------------
201 /** Apply post-processing to an already-imported scene.
202 *
203 * This is strictly equivalent to calling #aiImportFile()/#aiImportFileEx with the
204 * same flags. However, you can use this separate function to inspect the imported
205 * scene first to fine-tune your post-processing setup.
206 * @param pScene Scene to work on.
207 * @param pFlags Provide a bitwise combination of the #aiPostProcessSteps flags.
208 * @return A pointer to the post-processed data. Post processing is done in-place,
209 * meaning this is still the same #aiScene which you passed for pScene. However,
210 * _if_ post-processing failed, the scene could now be NULL. That's quite a rare
211 * case, post processing steps are not really designed to 'fail'. To be exact,
212 * the #aiProcess_ValidateDS flag is currently the only post processing step
213 * which can actually cause the scene to be reset to NULL.
214 */
215 ASSIMP_API const C_STRUCT aiScene* aiApplyPostProcessing(
216 const C_STRUCT aiScene* pScene,
217 unsigned int pFlags);
219 // --------------------------------------------------------------------------------
220 /** Get one of the predefine log streams. This is the quick'n'easy solution to
221 * access Assimp's log system. Attaching a log stream can slightly reduce Assimp's
222 * overall import performance.
223 *
224 * Usage is rather simple (this will stream the log to a file, named log.txt, and
225 * the stdout stream of the process:
226 * @code
227 * struct aiLogStream c;
228 * c = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"log.txt");
229 * aiAttachLogStream(&c);
230 * c = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
231 * aiAttachLogStream(&c);
232 * @endcode
233 *
234 * @param pStreams One of the #aiDefaultLogStream enumerated values.
235 * @param file Solely for the #aiDefaultLogStream_FILE flag: specifies the file to write to.
236 * Pass NULL for all other flags.
237 * @return The log stream. callback is set to NULL if something went wrong.
238 */
239 ASSIMP_API C_STRUCT aiLogStream aiGetPredefinedLogStream(
240 C_ENUM aiDefaultLogStream pStreams,
241 const char* file);
243 // --------------------------------------------------------------------------------
244 /** Attach a custom log stream to the libraries' logging system.
245 *
246 * Attaching a log stream can slightly reduce Assimp's overall import
247 * performance. Multiple log-streams can be attached.
248 * @param stream Describes the new log stream.
249 * @note To ensure proepr destruction of the logging system, you need to manually
250 * call aiDetachLogStream() on every single log stream you attach.
251 * Alternatively (for the lazy folks) #aiDetachAllLogStreams is provided.
252 */
253 ASSIMP_API void aiAttachLogStream(
254 const C_STRUCT aiLogStream* stream);
256 // --------------------------------------------------------------------------------
257 /** Enable verbose logging. Verbose logging includes debug-related stuff and
258 * detailed import statistics. This can have severe impact on import performance
259 * and memory consumption. However, it might be useful to find out why a file
260 * didn't read correctly.
261 * @param d AI_TRUE or AI_FALSE, your decision.
262 */
263 ASSIMP_API void aiEnableVerboseLogging(aiBool d);
265 // --------------------------------------------------------------------------------
266 /** Detach a custom log stream from the libraries' logging system.
267 *
268 * This is the counterpart of #aiAttachPredefinedLogStream. If you attached a stream,
269 * don't forget to detach it again.
270 * @param stream The log stream to be detached.
271 * @return AI_SUCCESS if the log stream has been detached successfully.
272 * @see aiDetachAllLogStreams
273 */
274 ASSIMP_API C_ENUM aiReturn aiDetachLogStream(
275 const C_STRUCT aiLogStream* stream);
277 // --------------------------------------------------------------------------------
278 /** Detach all active log streams from the libraries' logging system.
279 * This ensures that the logging system is terminated properly and all
280 * resources allocated by it are actually freed. If you attached a stream,
281 * don't forget to detach it again.
282 * @see aiAttachLogStream
283 * @see aiDetachLogStream
284 */
285 ASSIMP_API void aiDetachAllLogStreams(void);
287 // --------------------------------------------------------------------------------
288 /** Releases all resources associated with the given import process.
289 *
290 * Call this function after you're done with the imported data.
291 * @param pScene The imported data to release. NULL is a valid value.
292 */
293 ASSIMP_API void aiReleaseImport(
294 const C_STRUCT aiScene* pScene);
296 // --------------------------------------------------------------------------------
297 /** Returns the error text of the last failed import process.
298 *
299 * @return A textual description of the error that occurred at the last
300 * import process. NULL if there was no error. There can't be an error if you
301 * got a non-NULL #aiScene from #aiImportFile/#aiImportFileEx/#aiApplyPostProcessing.
302 */
303 ASSIMP_API const char* aiGetErrorString();
305 // --------------------------------------------------------------------------------
306 /** Returns whether a given file extension is supported by ASSIMP
307 *
308 * @param szExtension Extension for which the function queries support for.
309 * Must include a leading dot '.'. Example: ".3ds", ".md3"
310 * @return AI_TRUE if the file extension is supported.
311 */
312 ASSIMP_API aiBool aiIsExtensionSupported(
313 const char* szExtension);
315 // --------------------------------------------------------------------------------
316 /** Get a list of all file extensions supported by ASSIMP.
317 *
318 * If a file extension is contained in the list this does, of course, not
319 * mean that ASSIMP is able to load all files with this extension.
320 * @param szOut String to receive the extension list.
321 * Format of the list: "*.3ds;*.obj;*.dae". NULL is not a valid parameter.
322 */
323 ASSIMP_API void aiGetExtensionList(
324 C_STRUCT aiString* szOut);
326 // --------------------------------------------------------------------------------
327 /** Get the approximated storage required by an imported asset
328 * @param pIn Input asset.
329 * @param in Data structure to be filled.
330 */
331 ASSIMP_API void aiGetMemoryRequirements(
332 const C_STRUCT aiScene* pIn,
333 C_STRUCT aiMemoryInfo* in);
337 // --------------------------------------------------------------------------------
338 /** Create an empty property store. Property stores are used to collect import
339 * settings.
340 * @return New property store. Property stores need to be manually destroyed using
341 * the #aiReleasePropertyStore API function.
342 */
343 ASSIMP_API C_STRUCT aiPropertyStore* aiCreatePropertyStore(void);
345 // --------------------------------------------------------------------------------
346 /** Delete a property store.
347 * @param p Property store to be deleted.
348 */
349 ASSIMP_API void aiReleasePropertyStore(C_STRUCT aiPropertyStore* p);
351 // --------------------------------------------------------------------------------
352 /** Set an integer property.
353 *
354 * This is the C-version of #Assimp::Importer::SetPropertyInteger(). In the C
355 * interface, properties are always shared by all imports. It is not possible to
356 * specify them per import.
357 *
358 * @param szName Name of the configuration property to be set. All supported
359 * public properties are defined in the config.h header file (#AI_CONFIG_XXX).
360 * @param value New value for the property
361 */
362 ASSIMP_API void aiSetImportPropertyInteger(
363 C_STRUCT aiPropertyStore* store,
364 const char* szName,
365 int value);
367 // --------------------------------------------------------------------------------
368 /** Set a floating-point property.
369 *
370 * This is the C-version of #Assimp::Importer::SetPropertyFloat(). In the C
371 * interface, properties are always shared by all imports. It is not possible to
372 * specify them per import.
373 *
374 * @param szName Name of the configuration property to be set. All supported
375 * public properties are defined in the config.h header file (#AI_CONFIG_XXX).
376 * @param value New value for the property
377 */
378 ASSIMP_API void aiSetImportPropertyFloat(
379 C_STRUCT aiPropertyStore* store,
380 const char* szName,
381 float value);
383 // --------------------------------------------------------------------------------
384 /** Set a string property.
385 *
386 * This is the C-version of #Assimp::Importer::SetPropertyString(). In the C
387 * interface, properties are always shared by all imports. It is not possible to
388 * specify them per import.
389 *
390 * @param property store to modify. Use #aiCreatePropertyStore to obtain a store.
391 * @param szName Name of the configuration property to be set. All supported
392 * public properties are defined in the config.h header file (#AI_CONFIG_XXX).
393 * @param value New value for the property
394 */
395 ASSIMP_API void aiSetImportPropertyString(
396 C_STRUCT aiPropertyStore* store,
397 const char* szName,
398 const C_STRUCT aiString* st);
400 // --------------------------------------------------------------------------------
401 /** Construct a quaternion from a 3x3 rotation matrix.
402 * @param quat Receives the output quaternion.
403 * @param mat Matrix to 'quaternionize'.
404 * @see aiQuaternion(const aiMatrix3x3& pRotMatrix)
405 */
406 ASSIMP_API void aiCreateQuaternionFromMatrix(
407 C_STRUCT aiQuaternion* quat,
408 const C_STRUCT aiMatrix3x3* mat);
410 // --------------------------------------------------------------------------------
411 /** Decompose a transformation matrix into its rotational, translational and
412 * scaling components.
413 *
414 * @param mat Matrix to decompose
415 * @param scaling Receives the scaling component
416 * @param rotation Receives the rotational component
417 * @param position Receives the translational component.
418 * @see aiMatrix4x4::Decompose (aiVector3D&, aiQuaternion&, aiVector3D&) const;
419 */
420 ASSIMP_API void aiDecomposeMatrix(
421 const C_STRUCT aiMatrix4x4* mat,
422 C_STRUCT aiVector3D* scaling,
423 C_STRUCT aiQuaternion* rotation,
424 C_STRUCT aiVector3D* position);
426 // --------------------------------------------------------------------------------
427 /** Transpose a 4x4 matrix.
428 * @param mat Pointer to the matrix to be transposed
429 */
430 ASSIMP_API void aiTransposeMatrix4(
431 C_STRUCT aiMatrix4x4* mat);
433 // --------------------------------------------------------------------------------
434 /** Transpose a 3x3 matrix.
435 * @param mat Pointer to the matrix to be transposed
436 */
437 ASSIMP_API void aiTransposeMatrix3(
438 C_STRUCT aiMatrix3x3* mat);
440 // --------------------------------------------------------------------------------
441 /** Transform a vector by a 3x3 matrix
442 * @param vec Vector to be transformed.
443 * @param mat Matrix to transform the vector with.
444 */
445 ASSIMP_API void aiTransformVecByMatrix3(
446 C_STRUCT aiVector3D* vec,
447 const C_STRUCT aiMatrix3x3* mat);
449 // --------------------------------------------------------------------------------
450 /** Transform a vector by a 4x4 matrix
451 * @param vec Vector to be transformed.
452 * @param mat Matrix to transform the vector with.
453 */
454 ASSIMP_API void aiTransformVecByMatrix4(
455 C_STRUCT aiVector3D* vec,
456 const C_STRUCT aiMatrix4x4* mat);
458 // --------------------------------------------------------------------------------
459 /** Multiply two 4x4 matrices.
460 * @param dst First factor, receives result.
461 * @param src Matrix to be multiplied with 'dst'.
462 */
463 ASSIMP_API void aiMultiplyMatrix4(
464 C_STRUCT aiMatrix4x4* dst,
465 const C_STRUCT aiMatrix4x4* src);
467 // --------------------------------------------------------------------------------
468 /** Multiply two 3x3 matrices.
469 * @param dst First factor, receives result.
470 * @param src Matrix to be multiplied with 'dst'.
471 */
472 ASSIMP_API void aiMultiplyMatrix3(
473 C_STRUCT aiMatrix3x3* dst,
474 const C_STRUCT aiMatrix3x3* src);
476 // --------------------------------------------------------------------------------
477 /** Get a 3x3 identity matrix.
478 * @param mat Matrix to receive its personal identity
479 */
480 ASSIMP_API void aiIdentityMatrix3(
481 C_STRUCT aiMatrix3x3* mat);
483 // --------------------------------------------------------------------------------
484 /** Get a 4x4 identity matrix.
485 * @param mat Matrix to receive its personal identity
486 */
487 ASSIMP_API void aiIdentityMatrix4(
488 C_STRUCT aiMatrix4x4* mat);
491 #ifdef __cplusplus
492 }
493 #endif
495 #endif // AI_ASSIMP_H_INC