cimport.h 49 KB

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