cimport.h 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2021, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file cimport.h
  35. * @brief Defines the C-API to the Open Asset Import Library.
  36. */
  37. #pragma once
  38. #ifndef AI_ASSIMP_H_INC
  39. #define AI_ASSIMP_H_INC
  40. #ifdef __GNUC__
  41. #pragma GCC system_header
  42. #endif
  43. #include <assimp/importerdesc.h>
  44. #include <assimp/types.h>
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. struct aiScene;
  49. struct aiFileIO;
  50. typedef void (*aiLogStreamCallback)(const char * /* message */, char * /* user */);
  51. // --------------------------------------------------------------------------------
  52. /** C-API: Represents a log stream. A log stream receives all log messages and
  53. * streams them _somewhere_.
  54. * @see aiGetPredefinedLogStream
  55. * @see aiAttachLogStream
  56. * @see aiDetachLogStream */
  57. // --------------------------------------------------------------------------------
  58. struct aiLogStream {
  59. /** callback to be called */
  60. aiLogStreamCallback callback;
  61. /** user data to be passed to the callback */
  62. char *user;
  63. };
  64. // --------------------------------------------------------------------------------
  65. /** C-API: Represents an opaque set of settings to be used during importing.
  66. * @see aiCreatePropertyStore
  67. * @see aiReleasePropertyStore
  68. * @see aiImportFileExWithProperties
  69. * @see aiSetPropertyInteger
  70. * @see aiSetPropertyFloat
  71. * @see aiSetPropertyString
  72. * @see aiSetPropertyMatrix
  73. */
  74. // --------------------------------------------------------------------------------
  75. struct aiPropertyStore {
  76. char sentinel;
  77. };
  78. /** Our own C boolean type */
  79. typedef int aiBool;
  80. #define AI_FALSE 0
  81. #define AI_TRUE 1
  82. // --------------------------------------------------------------------------------
  83. /** Reads the given file and returns its content.
  84. *
  85. * If the call succeeds, the imported data is returned in an aiScene structure.
  86. * The data is intended to be read-only, it stays property of the ASSIMP
  87. * library and will be stable until aiReleaseImport() is called. After you're
  88. * done with it, call aiReleaseImport() to free the resources associated with
  89. * this file. If the import fails, NULL is returned instead. Call
  90. * aiGetErrorString() to retrieve a human-readable error text.
  91. * @param pFile Path and filename of the file to be imported,
  92. * expected to be a null-terminated c-string. NULL is not a valid value.
  93. * @param pFlags Optional post processing steps to be executed after
  94. * a successful import. Provide a bitwise combination of the
  95. * #aiPostProcessSteps flags.
  96. * @return Pointer to the imported data or NULL if the import failed.
  97. */
  98. ASSIMP_API const C_STRUCT aiScene *aiImportFile(
  99. const char *pFile,
  100. unsigned int pFlags);
  101. // --------------------------------------------------------------------------------
  102. /** Reads the given file using user-defined I/O functions and returns
  103. * its content.
  104. *
  105. * If the call succeeds, the imported data is returned in an aiScene structure.
  106. * The data is intended to be read-only, it stays property of the ASSIMP
  107. * library and will be stable until aiReleaseImport() is called. After you're
  108. * done with it, call aiReleaseImport() to free the resources associated with
  109. * this file. If the import fails, NULL is returned instead. Call
  110. * aiGetErrorString() to retrieve a human-readable error text.
  111. * @param pFile Path and filename of the file to be imported,
  112. * expected to be a null-terminated c-string. NULL is not a valid value.
  113. * @param pFlags Optional post processing steps to be executed after
  114. * a successful import. Provide a bitwise combination of the
  115. * #aiPostProcessSteps flags.
  116. * @param pFS aiFileIO structure. Will be used to open the model file itself
  117. * and any other files the loader needs to open. Pass NULL to use the default
  118. * implementation.
  119. * @return Pointer to the imported data or NULL if the import failed.
  120. * @note Include <aiFileIO.h> for the definition of #aiFileIO.
  121. */
  122. ASSIMP_API const C_STRUCT aiScene *aiImportFileEx(
  123. const char *pFile,
  124. unsigned int pFlags,
  125. C_STRUCT aiFileIO *pFS);
  126. // --------------------------------------------------------------------------------
  127. /** Same as #aiImportFileEx, but adds an extra parameter containing importer settings.
  128. *
  129. * @param pFile Path and filename of the file to be imported,
  130. * expected to be a null-terminated c-string. NULL is not a valid value.
  131. * @param pFlags Optional post processing steps to be executed after
  132. * a successful import. Provide a bitwise combination of the
  133. * #aiPostProcessSteps flags.
  134. * @param pFS aiFileIO structure. Will be used to open the model file itself
  135. * and any other files the loader needs to open. Pass NULL to use the default
  136. * implementation.
  137. * @param pProps #aiPropertyStore instance containing import settings.
  138. * @return Pointer to the imported data or NULL if the import failed.
  139. * @note Include <aiFileIO.h> for the definition of #aiFileIO.
  140. * @see aiImportFileEx
  141. */
  142. ASSIMP_API const C_STRUCT aiScene *aiImportFileExWithProperties(
  143. const char *pFile,
  144. unsigned int pFlags,
  145. C_STRUCT aiFileIO *pFS,
  146. const C_STRUCT aiPropertyStore *pProps);
  147. // --------------------------------------------------------------------------------
  148. /** Reads the given file from a given memory buffer,
  149. *
  150. * If the call succeeds, the contents of the file are returned as a pointer to an
  151. * aiScene object. The returned data is intended to be read-only, the importer keeps
  152. * ownership of the data and will destroy it upon destruction. If the import fails,
  153. * NULL is returned.
  154. * A human-readable error description can be retrieved by calling aiGetErrorString().
  155. * @param pBuffer Pointer to the file data
  156. * @param pLength Length of pBuffer, in bytes
  157. * @param pFlags Optional post processing steps to be executed after
  158. * a successful import. Provide a bitwise combination of the
  159. * #aiPostProcessSteps flags. If you wish to inspect the imported
  160. * scene first in order to fine-tune your post-processing setup,
  161. * consider to use #aiApplyPostProcessing().
  162. * @param pHint An additional hint to the library. If this is a non empty string,
  163. * the library looks for a loader to support the file extension specified by pHint
  164. * and passes the file to the first matching loader. If this loader is unable to
  165. * completely the request, the library continues and tries to determine the file
  166. * format on its own, a task that may or may not be successful.
  167. * Check the return value, and you'll know ...
  168. * @return A pointer to the imported data, NULL if the import failed.
  169. *
  170. * @note This is a straightforward way to decode models from memory
  171. * buffers, but it doesn't handle model formats that spread their
  172. * data across multiple files or even directories. Examples include
  173. * OBJ or MD3, which outsource parts of their material info into
  174. * external scripts. If you need full functionality, provide
  175. * a custom IOSystem to make Assimp find these files and use
  176. * the regular aiImportFileEx()/aiImportFileExWithProperties() API.
  177. */
  178. ASSIMP_API const C_STRUCT aiScene *aiImportFileFromMemory(
  179. const char *pBuffer,
  180. unsigned int pLength,
  181. unsigned int pFlags,
  182. const char *pHint);
  183. // --------------------------------------------------------------------------------
  184. /** Same as #aiImportFileFromMemory, but adds an extra parameter containing importer settings.
  185. *
  186. * @param pBuffer Pointer to the file data
  187. * @param pLength Length of pBuffer, in bytes
  188. * @param pFlags Optional post processing steps to be executed after
  189. * a successful import. Provide a bitwise combination of the
  190. * #aiPostProcessSteps flags. If you wish to inspect the imported
  191. * scene first in order to fine-tune your post-processing setup,
  192. * consider to use #aiApplyPostProcessing().
  193. * @param pHint An additional hint to the library. If this is a non empty string,
  194. * the library looks for a loader to support the file extension specified by pHint
  195. * and passes the file to the first matching loader. If this loader is unable to
  196. * completely the request, the library continues and tries to determine the file
  197. * format on its own, a task that may or may not be successful.
  198. * Check the return value, and you'll know ...
  199. * @param pProps #aiPropertyStore instance containing import settings.
  200. * @return A pointer to the imported data, NULL if the import failed.
  201. *
  202. * @note This is a straightforward way to decode models from memory
  203. * buffers, but it doesn't handle model formats that spread their
  204. * data across multiple files or even directories. Examples include
  205. * OBJ or MD3, which outsource parts of their material info into
  206. * external scripts. If you need full functionality, provide
  207. * a custom IOSystem to make Assimp find these files and use
  208. * the regular aiImportFileEx()/aiImportFileExWithProperties() API.
  209. * @see aiImportFileFromMemory
  210. */
  211. ASSIMP_API const C_STRUCT aiScene *aiImportFileFromMemoryWithProperties(
  212. const char *pBuffer,
  213. unsigned int pLength,
  214. unsigned int pFlags,
  215. const char *pHint,
  216. const C_STRUCT aiPropertyStore *pProps);
  217. // --------------------------------------------------------------------------------
  218. /** Apply post-processing to an already-imported scene.
  219. *
  220. * This is strictly equivalent to calling #aiImportFile()/#aiImportFileEx with the
  221. * same flags. However, you can use this separate function to inspect the imported
  222. * scene first to fine-tune your post-processing setup.
  223. * @param pScene Scene to work on.
  224. * @param pFlags Provide a bitwise combination of the #aiPostProcessSteps flags.
  225. * @return A pointer to the post-processed data. Post processing is done in-place,
  226. * meaning this is still the same #aiScene which you passed for pScene. However,
  227. * _if_ post-processing failed, the scene could now be NULL. That's quite a rare
  228. * case, post processing steps are not really designed to 'fail'. To be exact,
  229. * the #aiProcess_ValidateDataStructure flag is currently the only post processing step
  230. * which can actually cause the scene to be reset to NULL.
  231. */
  232. ASSIMP_API const C_STRUCT aiScene *aiApplyPostProcessing(
  233. const C_STRUCT aiScene *pScene,
  234. unsigned int pFlags);
  235. // --------------------------------------------------------------------------------
  236. /** Get one of the predefine log streams. This is the quick'n'easy solution to
  237. * access Assimp's log system. Attaching a log stream can slightly reduce Assimp's
  238. * overall import performance.
  239. *
  240. * Usage is rather simple (this will stream the log to a file, named log.txt, and
  241. * the stdout stream of the process:
  242. * @code
  243. * struct aiLogStream c;
  244. * c = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"log.txt");
  245. * aiAttachLogStream(&c);
  246. * c = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
  247. * aiAttachLogStream(&c);
  248. * @endcode
  249. *
  250. * @param pStreams One of the #aiDefaultLogStream enumerated values.
  251. * @param file Solely for the #aiDefaultLogStream_FILE flag: specifies the file to write to.
  252. * Pass NULL for all other flags.
  253. * @return The log stream. callback is set to NULL if something went wrong.
  254. */
  255. ASSIMP_API C_STRUCT aiLogStream aiGetPredefinedLogStream(
  256. C_ENUM aiDefaultLogStream pStreams,
  257. const char *file);
  258. // --------------------------------------------------------------------------------
  259. /** Attach a custom log stream to the libraries' logging system.
  260. *
  261. * Attaching a log stream can slightly reduce Assimp's overall import
  262. * performance. Multiple log-streams can be attached.
  263. * @param stream Describes the new log stream.
  264. * @note To ensure proper destruction of the logging system, you need to manually
  265. * call aiDetachLogStream() on every single log stream you attach.
  266. * Alternatively (for the lazy folks) #aiDetachAllLogStreams is provided.
  267. */
  268. ASSIMP_API void aiAttachLogStream(
  269. const C_STRUCT aiLogStream *stream);
  270. // --------------------------------------------------------------------------------
  271. /** Enable verbose logging. Verbose logging includes debug-related stuff and
  272. * detailed import statistics. This can have severe impact on import performance
  273. * and memory consumption. However, it might be useful to find out why a file
  274. * didn't read correctly.
  275. * @param d AI_TRUE or AI_FALSE, your decision.
  276. */
  277. ASSIMP_API void aiEnableVerboseLogging(aiBool d);
  278. // --------------------------------------------------------------------------------
  279. /** Detach a custom log stream from the libraries' logging system.
  280. *
  281. * This is the counterpart of #aiAttachLogStream. If you attached a stream,
  282. * don't forget to detach it again.
  283. * @param stream The log stream to be detached.
  284. * @return AI_SUCCESS if the log stream has been detached successfully.
  285. * @see aiDetachAllLogStreams
  286. */
  287. ASSIMP_API C_ENUM aiReturn aiDetachLogStream(
  288. const C_STRUCT aiLogStream *stream);
  289. // --------------------------------------------------------------------------------
  290. /** Detach all active log streams from the libraries' logging system.
  291. * This ensures that the logging system is terminated properly and all
  292. * resources allocated by it are actually freed. If you attached a stream,
  293. * don't forget to detach it again.
  294. * @see aiAttachLogStream
  295. * @see aiDetachLogStream
  296. */
  297. ASSIMP_API void aiDetachAllLogStreams(void);
  298. // --------------------------------------------------------------------------------
  299. /** Releases all resources associated with the given import process.
  300. *
  301. * Call this function after you're done with the imported data.
  302. * @param pScene The imported data to release. NULL is a valid value.
  303. */
  304. ASSIMP_API void aiReleaseImport(
  305. const C_STRUCT aiScene *pScene);
  306. // --------------------------------------------------------------------------------
  307. /** Returns the error text of the last failed import process.
  308. *
  309. * @return A textual description of the error that occurred at the last
  310. * import process. NULL if there was no error. There can't be an error if you
  311. * got a non-NULL #aiScene from #aiImportFile/#aiImportFileEx/#aiApplyPostProcessing.
  312. */
  313. ASSIMP_API const char *aiGetErrorString(void);
  314. // --------------------------------------------------------------------------------
  315. /** Returns whether a given file extension is supported by ASSIMP
  316. *
  317. * @param szExtension Extension for which the function queries support for.
  318. * Must include a leading dot '.'. Example: ".3ds", ".md3"
  319. * @return AI_TRUE if the file extension is supported.
  320. */
  321. ASSIMP_API aiBool aiIsExtensionSupported(
  322. const char *szExtension);
  323. // --------------------------------------------------------------------------------
  324. /** Get a list of all file extensions supported by ASSIMP.
  325. *
  326. * If a file extension is contained in the list this does, of course, not
  327. * mean that ASSIMP is able to load all files with this extension.
  328. * @param szOut String to receive the extension list.
  329. * Format of the list: "*.3ds;*.obj;*.dae". NULL is not a valid parameter.
  330. */
  331. ASSIMP_API void aiGetExtensionList(
  332. C_STRUCT aiString *szOut);
  333. // --------------------------------------------------------------------------------
  334. /** Get the approximated storage required by an imported asset
  335. * @param pIn Input asset.
  336. * @param in Data structure to be filled.
  337. */
  338. ASSIMP_API void aiGetMemoryRequirements(
  339. const C_STRUCT aiScene *pIn,
  340. C_STRUCT aiMemoryInfo *in);
  341. // --------------------------------------------------------------------------------
  342. /** Create an empty property store. Property stores are used to collect import
  343. * settings.
  344. * @return New property store. Property stores need to be manually destroyed using
  345. * the #aiReleasePropertyStore API function.
  346. */
  347. ASSIMP_API C_STRUCT aiPropertyStore *aiCreatePropertyStore(void);
  348. // --------------------------------------------------------------------------------
  349. /** Delete a property store.
  350. * @param p Property store to be deleted.
  351. */
  352. ASSIMP_API void aiReleasePropertyStore(C_STRUCT aiPropertyStore *p);
  353. // --------------------------------------------------------------------------------
  354. /** Set an integer property.
  355. *
  356. * This is the C-version of #Assimp::Importer::SetPropertyInteger(). In the C
  357. * interface, properties are always shared by all imports. It is not possible to
  358. * specify them per import.
  359. *
  360. * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store.
  361. * @param szName Name of the configuration property to be set. All supported
  362. * public properties are defined in the config.h header file (AI_CONFIG_XXX).
  363. * @param value New value for the property
  364. */
  365. ASSIMP_API void aiSetImportPropertyInteger(
  366. C_STRUCT aiPropertyStore *store,
  367. const char *szName,
  368. int value);
  369. // --------------------------------------------------------------------------------
  370. /** Set a floating-point property.
  371. *
  372. * This is the C-version of #Assimp::Importer::SetPropertyFloat(). In the C
  373. * interface, properties are always shared by all imports. It is not possible to
  374. * specify them per import.
  375. *
  376. * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store.
  377. * @param szName Name of the configuration property to be set. All supported
  378. * public properties are defined in the config.h header file (AI_CONFIG_XXX).
  379. * @param value New value for the property
  380. */
  381. ASSIMP_API void aiSetImportPropertyFloat(
  382. C_STRUCT aiPropertyStore *store,
  383. const char *szName,
  384. ai_real value);
  385. // --------------------------------------------------------------------------------
  386. /** Set a string property.
  387. *
  388. * This is the C-version of #Assimp::Importer::SetPropertyString(). In the C
  389. * interface, properties are always shared by all imports. It is not possible to
  390. * specify them per import.
  391. *
  392. * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store.
  393. * @param szName Name of the configuration property to be set. All supported
  394. * public properties are defined in the config.h header file (AI_CONFIG_XXX).
  395. * @param st New value for the property
  396. */
  397. ASSIMP_API void aiSetImportPropertyString(
  398. C_STRUCT aiPropertyStore *store,
  399. const char *szName,
  400. const C_STRUCT aiString *st);
  401. // --------------------------------------------------------------------------------
  402. /** Set a matrix property.
  403. *
  404. * This is the C-version of #Assimp::Importer::SetPropertyMatrix(). In the C
  405. * interface, properties are always shared by all imports. It is not possible to
  406. * specify them per import.
  407. *
  408. * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store.
  409. * @param szName Name of the configuration property to be set. All supported
  410. * public properties are defined in the config.h header file (AI_CONFIG_XXX).
  411. * @param mat New value for the property
  412. */
  413. ASSIMP_API void aiSetImportPropertyMatrix(
  414. C_STRUCT aiPropertyStore *store,
  415. const char *szName,
  416. const C_STRUCT aiMatrix4x4 *mat);
  417. // --------------------------------------------------------------------------------
  418. /** Construct a quaternion from a 3x3 rotation matrix.
  419. * @param quat Receives the output quaternion.
  420. * @param mat Matrix to 'quaternionize'.
  421. * @see aiQuaternion(const aiMatrix3x3& pRotMatrix)
  422. */
  423. ASSIMP_API void aiCreateQuaternionFromMatrix(
  424. C_STRUCT aiQuaternion *quat,
  425. const C_STRUCT aiMatrix3x3 *mat);
  426. // --------------------------------------------------------------------------------
  427. /** Decompose a transformation matrix into its rotational, translational and
  428. * scaling components.
  429. *
  430. * @param mat Matrix to decompose
  431. * @param scaling Receives the scaling component
  432. * @param rotation Receives the rotational component
  433. * @param position Receives the translational component.
  434. * @see aiMatrix4x4::Decompose (aiVector3D&, aiQuaternion&, aiVector3D&) const;
  435. */
  436. ASSIMP_API void aiDecomposeMatrix(
  437. const C_STRUCT aiMatrix4x4 *mat,
  438. C_STRUCT aiVector3D *scaling,
  439. C_STRUCT aiQuaternion *rotation,
  440. C_STRUCT aiVector3D *position);
  441. // --------------------------------------------------------------------------------
  442. /** Transpose a 4x4 matrix.
  443. * @param mat Pointer to the matrix to be transposed
  444. */
  445. ASSIMP_API void aiTransposeMatrix4(
  446. C_STRUCT aiMatrix4x4 *mat);
  447. // --------------------------------------------------------------------------------
  448. /** Transpose a 3x3 matrix.
  449. * @param mat Pointer to the matrix to be transposed
  450. */
  451. ASSIMP_API void aiTransposeMatrix3(
  452. C_STRUCT aiMatrix3x3 *mat);
  453. // --------------------------------------------------------------------------------
  454. /** Transform a vector by a 3x3 matrix
  455. * @param vec Vector to be transformed.
  456. * @param mat Matrix to transform the vector with.
  457. */
  458. ASSIMP_API void aiTransformVecByMatrix3(
  459. C_STRUCT aiVector3D *vec,
  460. const C_STRUCT aiMatrix3x3 *mat);
  461. // --------------------------------------------------------------------------------
  462. /** Transform a vector by a 4x4 matrix
  463. * @param vec Vector to be transformed.
  464. * @param mat Matrix to transform the vector with.
  465. */
  466. ASSIMP_API void aiTransformVecByMatrix4(
  467. C_STRUCT aiVector3D *vec,
  468. const C_STRUCT aiMatrix4x4 *mat);
  469. // --------------------------------------------------------------------------------
  470. /** Multiply two 4x4 matrices.
  471. * @param dst First factor, receives result.
  472. * @param src Matrix to be multiplied with 'dst'.
  473. */
  474. ASSIMP_API void aiMultiplyMatrix4(
  475. C_STRUCT aiMatrix4x4 *dst,
  476. const C_STRUCT aiMatrix4x4 *src);
  477. // --------------------------------------------------------------------------------
  478. /** Multiply two 3x3 matrices.
  479. * @param dst First factor, receives result.
  480. * @param src Matrix to be multiplied with 'dst'.
  481. */
  482. ASSIMP_API void aiMultiplyMatrix3(
  483. C_STRUCT aiMatrix3x3 *dst,
  484. const C_STRUCT aiMatrix3x3 *src);
  485. // --------------------------------------------------------------------------------
  486. /** Get a 3x3 identity matrix.
  487. * @param mat Matrix to receive its personal identity
  488. */
  489. ASSIMP_API void aiIdentityMatrix3(
  490. C_STRUCT aiMatrix3x3 *mat);
  491. // --------------------------------------------------------------------------------
  492. /** Get a 4x4 identity matrix.
  493. * @param mat Matrix to receive its personal identity
  494. */
  495. ASSIMP_API void aiIdentityMatrix4(
  496. C_STRUCT aiMatrix4x4 *mat);
  497. // --------------------------------------------------------------------------------
  498. /** Returns the number of import file formats available in the current Assimp build.
  499. * Use aiGetImportFormatDescription() to retrieve infos of a specific import format.
  500. */
  501. ASSIMP_API size_t aiGetImportFormatCount(void);
  502. // --------------------------------------------------------------------------------
  503. /** Returns a description of the nth import file format. Use #aiGetImportFormatCount()
  504. * to learn how many import formats are supported.
  505. * @param pIndex Index of the import format to retrieve information for. Valid range is
  506. * 0 to #aiGetImportFormatCount()
  507. * @return A description of that specific import format. NULL if pIndex is out of range.
  508. */
  509. ASSIMP_API const C_STRUCT aiImporterDesc *aiGetImportFormatDescription(size_t pIndex);
  510. // --------------------------------------------------------------------------------
  511. /** Check if 2D vectors are equal.
  512. * @param a First vector to compare
  513. * @param b Second vector to compare
  514. * @return 1 if the vectors are equal
  515. * @return 0 if the vectors are not equal
  516. */
  517. ASSIMP_API int aiVector2AreEqual(
  518. const C_STRUCT aiVector2D *a,
  519. const C_STRUCT aiVector2D *b);
  520. // --------------------------------------------------------------------------------
  521. /** Check if 2D vectors are equal using epsilon.
  522. * @param a First vector to compare
  523. * @param b Second vector to compare
  524. * @param epsilon Epsilon
  525. * @return 1 if the vectors are equal
  526. * @return 0 if the vectors are not equal
  527. */
  528. ASSIMP_API int aiVector2AreEqualEpsilon(
  529. const C_STRUCT aiVector2D *a,
  530. const C_STRUCT aiVector2D *b,
  531. const float epsilon);
  532. // --------------------------------------------------------------------------------
  533. /** Add 2D vectors.
  534. * @param dst First addend, receives result.
  535. * @param src Vector to be added to 'dst'.
  536. */
  537. ASSIMP_API void aiVector2Add(
  538. C_STRUCT aiVector2D *dst,
  539. const C_STRUCT aiVector2D *src);
  540. // --------------------------------------------------------------------------------
  541. /** Subtract 2D vectors.
  542. * @param dst Minuend, receives result.
  543. * @param src Vector to be subtracted from 'dst'.
  544. */
  545. ASSIMP_API void aiVector2Subtract(
  546. C_STRUCT aiVector2D *dst,
  547. const C_STRUCT aiVector2D *src);
  548. // --------------------------------------------------------------------------------
  549. /** Multiply a 2D vector by a scalar.
  550. * @param dst Vector to be scaled by \p s
  551. * @param s Scale factor
  552. */
  553. ASSIMP_API void aiVector2Scale(
  554. C_STRUCT aiVector2D *dst,
  555. const float s);
  556. // --------------------------------------------------------------------------------
  557. /** Multiply each component of a 2D vector with
  558. * the components of another vector.
  559. * @param dst First vector, receives result
  560. * @param other Second vector
  561. */
  562. ASSIMP_API void aiVector2SymMul(
  563. C_STRUCT aiVector2D *dst,
  564. const C_STRUCT aiVector2D *other);
  565. // --------------------------------------------------------------------------------
  566. /** Divide a 2D vector by a scalar.
  567. * @param dst Vector to be divided by \p s
  568. * @param s Scalar divisor
  569. */
  570. ASSIMP_API void aiVector2DivideByScalar(
  571. C_STRUCT aiVector2D *dst,
  572. const float s);
  573. // --------------------------------------------------------------------------------
  574. /** Divide each component of a 2D vector by
  575. * the components of another vector.
  576. * @param dst Vector as the dividend
  577. * @param v Vector as the divisor
  578. */
  579. ASSIMP_API void aiVector2DivideByVector(
  580. C_STRUCT aiVector2D *dst,
  581. C_STRUCT aiVector2D *v);
  582. // --------------------------------------------------------------------------------
  583. /** Get the length of a 2D vector.
  584. * @return v Vector to evaluate
  585. */
  586. ASSIMP_API float aiVector2Length(
  587. const C_STRUCT aiVector2D *v);
  588. // --------------------------------------------------------------------------------
  589. /** Get the squared length of a 2D vector.
  590. * @return v Vector to evaluate
  591. */
  592. ASSIMP_API float aiVector2SquareLength(
  593. const C_STRUCT aiVector2D *v);
  594. // --------------------------------------------------------------------------------
  595. /** Negate a 2D vector.
  596. * @param dst Vector to be negated
  597. */
  598. ASSIMP_API void aiVector2Negate(
  599. C_STRUCT aiVector2D *dst);
  600. // --------------------------------------------------------------------------------
  601. /** Get the dot product of 2D vectors.
  602. * @param a First vector
  603. * @param b Second vector
  604. * @return The dot product of vectors
  605. */
  606. ASSIMP_API float aiVector2DotProduct(
  607. const C_STRUCT aiVector2D *a,
  608. const C_STRUCT aiVector2D *b);
  609. // --------------------------------------------------------------------------------
  610. /** Normalize a 2D vector.
  611. * @param v Vector to normalize
  612. */
  613. ASSIMP_API void aiVector2Normalize(
  614. C_STRUCT aiVector2D *v);
  615. // --------------------------------------------------------------------------------
  616. /** Check if 3D vectors are equal.
  617. * @param a First vector to compare
  618. * @param b Second vector to compare
  619. * @return 1 if the vectors are equal
  620. * @return 0 if the vectors are not equal
  621. */
  622. ASSIMP_API int aiVector3AreEqual(
  623. const C_STRUCT aiVector3D *a,
  624. const C_STRUCT aiVector3D *b);
  625. // --------------------------------------------------------------------------------
  626. /** Check if 3D vectors are equal using epsilon.
  627. * @param a First vector to compare
  628. * @param b Second vector to compare
  629. * @param epsilon Epsilon
  630. * @return 1 if the vectors are equal
  631. * @return 0 if the vectors are not equal
  632. */
  633. ASSIMP_API int aiVector3AreEqualEpsilon(
  634. const C_STRUCT aiVector3D *a,
  635. const C_STRUCT aiVector3D *b,
  636. const float epsilon);
  637. // --------------------------------------------------------------------------------
  638. /** Check if vector \p a is less than vector \p b.
  639. * @param a First vector to compare
  640. * @param b Second vector to compare
  641. * @param epsilon Epsilon
  642. * @return 1 if \p a is less than \p b
  643. * @return 0 if \p a is equal or greater than \p b
  644. */
  645. ASSIMP_API int aiVector3LessThan(
  646. const C_STRUCT aiVector3D *a,
  647. const C_STRUCT aiVector3D *b);
  648. // --------------------------------------------------------------------------------
  649. /** Add 3D vectors.
  650. * @param dst First addend, receives result.
  651. * @param src Vector to be added to 'dst'.
  652. */
  653. ASSIMP_API void aiVector3Add(
  654. C_STRUCT aiVector3D *dst,
  655. const C_STRUCT aiVector3D *src);
  656. // --------------------------------------------------------------------------------
  657. /** Subtract 3D vectors.
  658. * @param dst Minuend, receives result.
  659. * @param src Vector to be subtracted from 'dst'.
  660. */
  661. ASSIMP_API void aiVector3Subtract(
  662. C_STRUCT aiVector3D *dst,
  663. const C_STRUCT aiVector3D *src);
  664. // --------------------------------------------------------------------------------
  665. /** Multiply a 3D vector by a scalar.
  666. * @param dst Vector to be scaled by \p s
  667. * @param s Scale factor
  668. */
  669. ASSIMP_API void aiVector3Scale(
  670. C_STRUCT aiVector3D *dst,
  671. const float s);
  672. // --------------------------------------------------------------------------------
  673. /** Multiply each component of a 3D vector with
  674. * the components of another vector.
  675. * @param dst First vector, receives result
  676. * @param other Second vector
  677. */
  678. ASSIMP_API void aiVector3SymMul(
  679. C_STRUCT aiVector3D *dst,
  680. const C_STRUCT aiVector3D *other);
  681. // --------------------------------------------------------------------------------
  682. /** Divide a 3D vector by a scalar.
  683. * @param dst Vector to be divided by \p s
  684. * @param s Scalar divisor
  685. */
  686. ASSIMP_API void aiVector3DivideByScalar(
  687. C_STRUCT aiVector3D *dst,
  688. const float s);
  689. // --------------------------------------------------------------------------------
  690. /** Divide each component of a 3D vector by
  691. * the components of another vector.
  692. * @param dst Vector as the dividend
  693. * @param v Vector as the divisor
  694. */
  695. ASSIMP_API void aiVector3DivideByVector(
  696. C_STRUCT aiVector3D *dst,
  697. C_STRUCT aiVector3D *v);
  698. // --------------------------------------------------------------------------------
  699. /** Get the length of a 3D vector.
  700. * @return v Vector to evaluate
  701. */
  702. ASSIMP_API float aiVector3Length(
  703. const C_STRUCT aiVector3D *v);
  704. // --------------------------------------------------------------------------------
  705. /** Get the squared length of a 3D vector.
  706. * @return v Vector to evaluate
  707. */
  708. ASSIMP_API float aiVector3SquareLength(
  709. const C_STRUCT aiVector3D *v);
  710. // --------------------------------------------------------------------------------
  711. /** Negate a 3D vector.
  712. * @param dst Vector to be negated
  713. */
  714. ASSIMP_API void aiVector3Negate(
  715. C_STRUCT aiVector3D *dst);
  716. // --------------------------------------------------------------------------------
  717. /** Get the dot product of 3D vectors.
  718. * @param a First vector
  719. * @param b Second vector
  720. * @return The dot product of vectors
  721. */
  722. ASSIMP_API float aiVector3DotProduct(
  723. const C_STRUCT aiVector3D *a,
  724. const C_STRUCT aiVector3D *b);
  725. // --------------------------------------------------------------------------------
  726. /** Get cross product of 3D vectors.
  727. * @param dst Vector to receive the result.
  728. * @param a First vector
  729. * @param b Second vector
  730. * @return The dot product of vectors
  731. */
  732. ASSIMP_API void aiVector3CrossProduct(
  733. C_STRUCT aiVector3D *dst,
  734. const C_STRUCT aiVector3D *a,
  735. const C_STRUCT aiVector3D *b);
  736. // --------------------------------------------------------------------------------
  737. /** Normalize a 3D vector.
  738. * @param v Vector to normalize
  739. */
  740. ASSIMP_API void aiVector3Normalize(
  741. C_STRUCT aiVector3D *v);
  742. // --------------------------------------------------------------------------------
  743. /** Check for division by zero and normalize a 3D vector.
  744. * @param v Vector to normalize
  745. */
  746. ASSIMP_API void aiVector3NormalizeSafe(
  747. C_STRUCT aiVector3D *v);
  748. // --------------------------------------------------------------------------------
  749. /** Rotate a 3D vector by a quaternion.
  750. * @param v The vector to rotate by \p q
  751. * @param q Quaternion to use to rotate \p v
  752. */
  753. ASSIMP_API void aiVector3RotateByQuaternion(
  754. C_STRUCT aiVector3D *v,
  755. const C_STRUCT aiQuaternion *q);
  756. // --------------------------------------------------------------------------------
  757. /** Construct a 3x3 matrix from a 4x4 matrix.
  758. * @param dst Receives the output matrix
  759. * @param mat The 4x4 matrix to use
  760. */
  761. ASSIMP_API void aiMatrix3FromMatrix4(
  762. C_STRUCT aiMatrix3x3 *dst,
  763. const C_STRUCT aiMatrix4x4 *mat);
  764. // --------------------------------------------------------------------------------
  765. /** Construct a 3x3 matrix from a quaternion.
  766. * @param mat Receives the output matrix
  767. * @param q The quaternion matrix to use
  768. */
  769. ASSIMP_API void aiMatrix3FromQuaternion(
  770. C_STRUCT aiMatrix3x3 *mat,
  771. const C_STRUCT aiQuaternion *q);
  772. // --------------------------------------------------------------------------------
  773. /** Check if 3x3 matrices are equal.
  774. * @param a First matrix to compare
  775. * @param b Second matrix to compare
  776. * @return 1 if the matrices are equal
  777. * @return 0 if the matrices are not equal
  778. */
  779. ASSIMP_API int aiMatrix3AreEqual(
  780. const C_STRUCT aiMatrix3x3 *a,
  781. const C_STRUCT aiMatrix3x3 *b);
  782. // --------------------------------------------------------------------------------
  783. /** Check if 3x3 matrices are equal.
  784. * @param a First matrix to compare
  785. * @param b Second matrix to compare
  786. * @param epsilon Epsilon
  787. * @return 1 if the matrices are equal
  788. * @return 0 if the matrices are not equal
  789. */
  790. ASSIMP_API int aiMatrix3AreEqualEpsilon(
  791. const C_STRUCT aiMatrix3x3 *a,
  792. const C_STRUCT aiMatrix3x3 *b,
  793. const float epsilon);
  794. // --------------------------------------------------------------------------------
  795. /** Invert a 3x3 matrix.
  796. * @param mat Matrix to invert
  797. */
  798. ASSIMP_API void aiMatrix3Inverse(
  799. C_STRUCT aiMatrix3x3 *mat);
  800. // --------------------------------------------------------------------------------
  801. /** Get the determinant of a 3x3 matrix.
  802. * @param mat Matrix to get the determinant from
  803. */
  804. ASSIMP_API float aiMatrix3Determinant(
  805. const C_STRUCT aiMatrix3x3 *mat);
  806. // --------------------------------------------------------------------------------
  807. /** Get a 3x3 rotation matrix around the Z axis.
  808. * @param mat Receives the output matrix
  809. * @param angle Rotation angle, in radians
  810. */
  811. ASSIMP_API void aiMatrix3RotationZ(
  812. C_STRUCT aiMatrix3x3 *mat,
  813. const float angle);
  814. // --------------------------------------------------------------------------------
  815. /** Returns a 3x3 rotation matrix for a rotation around an arbitrary axis.
  816. * @param mat Receives the output matrix
  817. * @param axis Rotation axis, should be a normalized vector
  818. * @param angle Rotation angle, in radians
  819. */
  820. ASSIMP_API void aiMatrix3FromRotationAroundAxis(
  821. C_STRUCT aiMatrix3x3 *mat,
  822. const C_STRUCT aiVector3D *axis,
  823. const float angle);
  824. // --------------------------------------------------------------------------------
  825. /** Get a 3x3 translation matrix.
  826. * @param mat Receives the output matrix
  827. * @param translation The translation vector
  828. */
  829. ASSIMP_API void aiMatrix3Translation(
  830. C_STRUCT aiMatrix3x3 *mat,
  831. const C_STRUCT aiVector2D *translation);
  832. // --------------------------------------------------------------------------------
  833. /** Create a 3x3 matrix that rotates one vector to another vector.
  834. * @param mat Receives the output matrix
  835. * @param from Vector to rotate from
  836. * @param to Vector to rotate to
  837. */
  838. ASSIMP_API void aiMatrix3FromTo(
  839. C_STRUCT aiMatrix3x3 *mat,
  840. const C_STRUCT aiVector3D *from,
  841. const C_STRUCT aiVector3D *to);
  842. // --------------------------------------------------------------------------------
  843. /** Construct a 4x4 matrix from a 3x3 matrix.
  844. * @param dst Receives the output matrix
  845. * @param mat The 3x3 matrix to use
  846. */
  847. ASSIMP_API void aiMatrix4FromMatrix3(
  848. C_STRUCT aiMatrix4x4 *dst,
  849. const C_STRUCT aiMatrix3x3 *mat);
  850. // --------------------------------------------------------------------------------
  851. /** Construct a 4x4 matrix from scaling, rotation and position.
  852. * @param mat Receives the output matrix.
  853. * @param scaling The scaling for the x,y,z axes
  854. * @param rotation The rotation as a hamilton quaternion
  855. * @param position The position for the x,y,z axes
  856. */
  857. ASSIMP_API void aiMatrix4FromScalingQuaternionPosition(
  858. C_STRUCT aiMatrix4x4 *mat,
  859. const C_STRUCT aiVector3D *scaling,
  860. const C_STRUCT aiQuaternion *rotation,
  861. const C_STRUCT aiVector3D *position);
  862. // --------------------------------------------------------------------------------
  863. /** Add 4x4 matrices.
  864. * @param dst First addend, receives result.
  865. * @param src Matrix to be added to 'dst'.
  866. */
  867. ASSIMP_API void aiMatrix4Add(
  868. C_STRUCT aiMatrix4x4 *dst,
  869. const C_STRUCT aiMatrix4x4 *src);
  870. // --------------------------------------------------------------------------------
  871. /** Check if 4x4 matrices are equal.
  872. * @param a First matrix to compare
  873. * @param b Second matrix to compare
  874. * @return 1 if the matrices are equal
  875. * @return 0 if the matrices are not equal
  876. */
  877. ASSIMP_API int aiMatrix4AreEqual(
  878. const C_STRUCT aiMatrix4x4 *a,
  879. const C_STRUCT aiMatrix4x4 *b);
  880. // --------------------------------------------------------------------------------
  881. /** Check if 4x4 matrices are equal.
  882. * @param a First matrix to compare
  883. * @param b Second matrix to compare
  884. * @param epsilon Epsilon
  885. * @return 1 if the matrices are equal
  886. * @return 0 if the matrices are not equal
  887. */
  888. ASSIMP_API int aiMatrix4AreEqualEpsilon(
  889. const C_STRUCT aiMatrix4x4 *a,
  890. const C_STRUCT aiMatrix4x4 *b,
  891. const float epsilon);
  892. // --------------------------------------------------------------------------------
  893. /** Invert a 4x4 matrix.
  894. * @param result Matrix to invert
  895. */
  896. ASSIMP_API void aiMatrix4Inverse(
  897. C_STRUCT aiMatrix4x4 *mat);
  898. // --------------------------------------------------------------------------------
  899. /** Get the determinant of a 4x4 matrix.
  900. * @param mat Matrix to get the determinant from
  901. * @return The determinant of the matrix
  902. */
  903. ASSIMP_API float aiMatrix4Determinant(
  904. const C_STRUCT aiMatrix4x4 *mat);
  905. // --------------------------------------------------------------------------------
  906. /** Returns true of the matrix is the identity matrix.
  907. * @param mat Matrix to get the determinant from
  908. * @return 1 if \p mat is an identity matrix.
  909. * @return 0 if \p mat is not an identity matrix.
  910. */
  911. ASSIMP_API int aiMatrix4IsIdentity(
  912. const C_STRUCT aiMatrix4x4 *mat);
  913. // --------------------------------------------------------------------------------
  914. /** Decompose a transformation matrix into its scaling,
  915. * rotational as euler angles, and translational components.
  916. *
  917. * @param mat Matrix to decompose
  918. * @param scaling Receives the output scaling for the x,y,z axes
  919. * @param rotation Receives the output rotation as a Euler angles
  920. * @param position Receives the output position for the x,y,z axes
  921. */
  922. ASSIMP_API void aiMatrix4DecomposeIntoScalingEulerAnglesPosition(
  923. const C_STRUCT aiMatrix4x4 *mat,
  924. C_STRUCT aiVector3D *scaling,
  925. C_STRUCT aiVector3D *rotation,
  926. C_STRUCT aiVector3D *position);
  927. // --------------------------------------------------------------------------------
  928. /** Decompose a transformation matrix into its scaling,
  929. * rotational split into an axis and rotational angle,
  930. * and it's translational components.
  931. *
  932. * @param mat Matrix to decompose
  933. * @param rotation Receives the rotational component
  934. * @param axis Receives the output rotation axis
  935. * @param angle Receives the output rotation angle
  936. * @param position Receives the output position for the x,y,z axes.
  937. */
  938. ASSIMP_API void aiMatrix4DecomposeIntoScalingAxisAnglePosition(
  939. const C_STRUCT aiMatrix4x4 *mat,
  940. C_STRUCT aiVector3D *scaling,
  941. C_STRUCT aiVector3D *axis,
  942. ai_real *angle,
  943. C_STRUCT aiVector3D *position);
  944. // --------------------------------------------------------------------------------
  945. /** Decompose a transformation matrix into its rotational and
  946. * translational components.
  947. *
  948. * @param mat Matrix to decompose
  949. * @param rotation Receives the rotational component
  950. * @param position Receives the translational component.
  951. */
  952. ASSIMP_API void aiMatrix4DecomposeNoScaling(
  953. const C_STRUCT aiMatrix4x4 *mat,
  954. C_STRUCT aiQuaternion *rotation,
  955. C_STRUCT aiVector3D *position);
  956. // --------------------------------------------------------------------------------
  957. /** Creates a 4x4 matrix from a set of euler angles.
  958. * @param mat Receives the output matrix
  959. * @param x Rotation angle for the x-axis, in radians
  960. * @param y Rotation angle for the y-axis, in radians
  961. * @param z Rotation angle for the z-axis, in radians
  962. */
  963. ASSIMP_API void aiMatrix4FromEulerAngles(
  964. C_STRUCT aiMatrix4x4 *mat,
  965. float x, float y, float z);
  966. // --------------------------------------------------------------------------------
  967. /** Get a 4x4 rotation matrix around the X axis.
  968. * @param mat Receives the output matrix
  969. * @param angle Rotation angle, in radians
  970. */
  971. ASSIMP_API void aiMatrix4RotationX(
  972. C_STRUCT aiMatrix4x4 *mat,
  973. const float angle);
  974. // --------------------------------------------------------------------------------
  975. /** Get a 4x4 rotation matrix around the Y axis.
  976. * @param mat Receives the output matrix
  977. * @param angle Rotation angle, in radians
  978. */
  979. ASSIMP_API void aiMatrix4RotationY(
  980. C_STRUCT aiMatrix4x4 *mat,
  981. const float angle);
  982. // --------------------------------------------------------------------------------
  983. /** Get a 4x4 rotation matrix around the Z axis.
  984. * @param mat Receives the output matrix
  985. * @param angle Rotation angle, in radians
  986. */
  987. ASSIMP_API void aiMatrix4RotationZ(
  988. C_STRUCT aiMatrix4x4 *mat,
  989. const float angle);
  990. // --------------------------------------------------------------------------------
  991. /** Returns a 4x4 rotation matrix for a rotation around an arbitrary axis.
  992. * @param mat Receives the output matrix
  993. * @param axis Rotation axis, should be a normalized vector
  994. * @param angle Rotation angle, in radians
  995. */
  996. ASSIMP_API void aiMatrix4FromRotationAroundAxis(
  997. C_STRUCT aiMatrix4x4 *mat,
  998. const C_STRUCT aiVector3D *axis,
  999. const float angle);
  1000. // --------------------------------------------------------------------------------
  1001. /** Get a 4x4 translation matrix.
  1002. * @param mat Receives the output matrix
  1003. * @param translation The translation vector
  1004. */
  1005. ASSIMP_API void aiMatrix4Translation(
  1006. C_STRUCT aiMatrix4x4 *mat,
  1007. const C_STRUCT aiVector3D *translation);
  1008. // --------------------------------------------------------------------------------
  1009. /** Get a 4x4 scaling matrix.
  1010. * @param mat Receives the output matrix
  1011. * @param scaling The scaling vector
  1012. */
  1013. ASSIMP_API void aiMatrix4Scaling(
  1014. C_STRUCT aiMatrix4x4 *mat,
  1015. const C_STRUCT aiVector3D *scaling);
  1016. // --------------------------------------------------------------------------------
  1017. /** Create a 4x4 matrix that rotates one vector to another vector.
  1018. * @param mat Receives the output matrix
  1019. * @param from Vector to rotate from
  1020. * @param to Vector to rotate to
  1021. */
  1022. ASSIMP_API void aiMatrix4FromTo(
  1023. C_STRUCT aiMatrix4x4 *mat,
  1024. const C_STRUCT aiVector3D *from,
  1025. const C_STRUCT aiVector3D *to);
  1026. // --------------------------------------------------------------------------------
  1027. /** Create a Quaternion from euler angles.
  1028. * @param q Receives the output quaternion
  1029. * @param x Rotation angle for the x-axis, in radians
  1030. * @param y Rotation angle for the y-axis, in radians
  1031. * @param z Rotation angle for the z-axis, in radians
  1032. */
  1033. ASSIMP_API void aiQuaternionFromEulerAngles(
  1034. C_STRUCT aiQuaternion *q,
  1035. float x, float y, float z);
  1036. // --------------------------------------------------------------------------------
  1037. /** Create a Quaternion from an axis angle pair.
  1038. * @param q Receives the output quaternion
  1039. * @param axis The orientation axis
  1040. * @param angle The rotation angle, in radians
  1041. */
  1042. ASSIMP_API void aiQuaternionFromAxisAngle(
  1043. C_STRUCT aiQuaternion *q,
  1044. const C_STRUCT aiVector3D *axis,
  1045. const float angle);
  1046. // --------------------------------------------------------------------------------
  1047. /** Create a Quaternion from a normalized quaternion stored
  1048. * in a 3D vector.
  1049. * @param q Receives the output quaternion
  1050. * @param normalized The vector that stores the quaternion
  1051. */
  1052. ASSIMP_API void aiQuaternionFromNormalizedQuaternion(
  1053. C_STRUCT aiQuaternion *q,
  1054. const C_STRUCT aiVector3D *normalized);
  1055. // --------------------------------------------------------------------------------
  1056. /** Check if quaternions are equal.
  1057. * @param a First quaternion to compare
  1058. * @param b Second quaternion to compare
  1059. * @return 1 if the quaternions are equal
  1060. * @return 0 if the quaternions are not equal
  1061. */
  1062. ASSIMP_API int aiQuaternionAreEqual(
  1063. const C_STRUCT aiQuaternion *a,
  1064. const C_STRUCT aiQuaternion *b);
  1065. // --------------------------------------------------------------------------------
  1066. /** Check if quaternions are equal using epsilon.
  1067. * @param a First quaternion to compare
  1068. * @param b Second quaternion to compare
  1069. * @param epsilon Epsilon
  1070. * @return 1 if the quaternions are equal
  1071. * @return 0 if the quaternions are not equal
  1072. */
  1073. ASSIMP_API int aiQuaternionAreEqualEpsilon(
  1074. const C_STRUCT aiQuaternion *a,
  1075. const C_STRUCT aiQuaternion *b,
  1076. const float epsilon);
  1077. // --------------------------------------------------------------------------------
  1078. /** Normalize a quaternion.
  1079. * @param q Quaternion to normalize
  1080. */
  1081. ASSIMP_API void aiQuaternionNormalize(
  1082. C_STRUCT aiQuaternion *q);
  1083. // --------------------------------------------------------------------------------
  1084. /** Compute quaternion conjugate.
  1085. * @param q Quaternion to compute conjugate,
  1086. * receives the output quaternion
  1087. */
  1088. ASSIMP_API void aiQuaternionConjugate(
  1089. C_STRUCT aiQuaternion *q);
  1090. // --------------------------------------------------------------------------------
  1091. /** Multiply quaternions.
  1092. * @param dst First quaternion, receives the output quaternion
  1093. * @param q Second quaternion
  1094. */
  1095. ASSIMP_API void aiQuaternionMultiply(
  1096. C_STRUCT aiQuaternion *dst,
  1097. const C_STRUCT aiQuaternion *q);
  1098. // --------------------------------------------------------------------------------
  1099. /** Performs a spherical interpolation between two quaternions.
  1100. * @param dst Receives the quaternion resulting from the interpolation.
  1101. * @param start Quaternion when factor == 0
  1102. * @param end Quaternion when factor == 1
  1103. * @param factor Interpolation factor between 0 and 1
  1104. */
  1105. ASSIMP_API void aiQuaternionInterpolate(
  1106. C_STRUCT aiQuaternion *dst,
  1107. const C_STRUCT aiQuaternion *start,
  1108. const C_STRUCT aiQuaternion *end,
  1109. const float factor);
  1110. #ifdef __cplusplus
  1111. }
  1112. #endif
  1113. #endif // AI_ASSIMP_H_INC