Assimp.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development 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 Development 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 Assimp.cpp
  35. * @brief Implementation of the Plain-C API
  36. */
  37. #include "AssimpPCH.h"
  38. #include "../include/assimp.h"
  39. #include "../include/aiFileIO.h"
  40. #include "GenericProperty.h"
  41. // ------------------------------------------------------------------------------------------------
  42. #ifdef AI_C_THREADSAFE
  43. # include <boost/thread/thread.hpp>
  44. # include <boost/thread/mutex.hpp>
  45. #endif
  46. // ------------------------------------------------------------------------------------------------
  47. using namespace Assimp;
  48. namespace Assimp
  49. {
  50. /** Stores the importer objects for all active import processes */
  51. typedef std::map<const aiScene*, Assimp::Importer*> ImporterMap;
  52. /** Stores the LogStream objects for all active C log streams */
  53. struct mpred {
  54. bool operator () (const aiLogStream& s0, const aiLogStream& s1) const {
  55. return s0.callback<s1.callback&&s0.user<s1.user;
  56. }
  57. };
  58. typedef std::map<aiLogStream, Assimp::LogStream*, mpred> LogStreamMap;
  59. /** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */
  60. typedef std::list<Assimp::LogStream*> PredefLogStreamMap;
  61. /** Local storage of all active import processes */
  62. static ImporterMap gActiveImports;
  63. /** Local storage of all active log streams */
  64. static LogStreamMap gActiveLogStreams;
  65. /** Local storage of LogStreams allocated by #aiGetPredefinedLogStream */
  66. static PredefLogStreamMap gPredefinedStreams;
  67. /** Error message of the last failed import process */
  68. static std::string gLastErrorString;
  69. /** Verbose logging active or not? */
  70. static aiBool gVerboseLogging = false;
  71. }
  72. /** Configuration properties */
  73. static ImporterPimpl::IntPropertyMap gIntProperties;
  74. static ImporterPimpl::FloatPropertyMap gFloatProperties;
  75. static ImporterPimpl::StringPropertyMap gStringProperties;
  76. #ifdef AI_C_THREADSAFE
  77. /** Global mutex to manage the access to the importer map */
  78. static boost::mutex gMutex;
  79. /** Global mutex to manage the access to the logstream map */
  80. static boost::mutex gLogStreamMutex;
  81. #endif
  82. class CIOSystemWrapper;
  83. class CIOStreamWrapper;
  84. // ------------------------------------------------------------------------------------------------
  85. // Custom IOStream implementation for the C-API
  86. class CIOStreamWrapper : public IOStream
  87. {
  88. friend class CIOSystemWrapper;
  89. public:
  90. CIOStreamWrapper(aiFile* pFile)
  91. : mFile(pFile)
  92. {}
  93. // ...................................................................
  94. size_t Read(void* pvBuffer,
  95. size_t pSize,
  96. size_t pCount
  97. ){
  98. // need to typecast here as C has no void*
  99. return mFile->ReadProc(mFile,(char*)pvBuffer,pSize,pCount);
  100. }
  101. // ...................................................................
  102. size_t Write(const void* pvBuffer,
  103. size_t pSize,
  104. size_t pCount
  105. ){
  106. // need to typecast here as C has no void*
  107. return mFile->WriteProc(mFile,(const char*)pvBuffer,pSize,pCount);
  108. }
  109. // ...................................................................
  110. aiReturn Seek(size_t pOffset,
  111. aiOrigin pOrigin
  112. ){
  113. return mFile->SeekProc(mFile,pOffset,pOrigin);
  114. }
  115. // ...................................................................
  116. size_t Tell(void) const {
  117. return mFile->TellProc(mFile);
  118. }
  119. // ...................................................................
  120. size_t FileSize() const {
  121. return mFile->FileSizeProc(mFile);
  122. }
  123. // ...................................................................
  124. void Flush () {
  125. return mFile->FlushProc(mFile);
  126. }
  127. private:
  128. aiFile* mFile;
  129. };
  130. // ------------------------------------------------------------------------------------------------
  131. // Custom IOStream implementation for the C-API
  132. class CIOSystemWrapper : public IOSystem
  133. {
  134. public:
  135. CIOSystemWrapper(aiFileIO* pFile)
  136. : mFileSystem(pFile)
  137. {}
  138. // ...................................................................
  139. bool Exists( const char* pFile) const {
  140. CIOSystemWrapper* pip = const_cast<CIOSystemWrapper*>(this);
  141. IOStream* p = pip->Open(pFile);
  142. if (p){
  143. pip->Close(p);
  144. return true;
  145. }
  146. return false;
  147. }
  148. // ...................................................................
  149. char getOsSeparator() const {
  150. #ifndef _WIN32
  151. return '/';
  152. #else
  153. return '\\';
  154. #endif
  155. }
  156. // ...................................................................
  157. IOStream* Open(const char* pFile,const char* pMode = "rb") {
  158. aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile,pMode);
  159. if (!p) {
  160. return NULL;
  161. }
  162. return new CIOStreamWrapper(p);
  163. }
  164. // ...................................................................
  165. void Close( IOStream* pFile) {
  166. if (!pFile) {
  167. return;
  168. }
  169. mFileSystem->CloseProc(mFileSystem,((CIOStreamWrapper*) pFile)->mFile);
  170. delete pFile;
  171. }
  172. private:
  173. aiFileIO* mFileSystem;
  174. };
  175. // ------------------------------------------------------------------------------------------------
  176. // Custom LogStream implementation for the C-API
  177. class LogToCallbackRedirector : public LogStream
  178. {
  179. public:
  180. LogToCallbackRedirector(const aiLogStream& s)
  181. : stream (s) {
  182. ai_assert(NULL != s.callback);
  183. }
  184. ~LogToCallbackRedirector() {
  185. #ifdef AI_C_THREADSAFE
  186. boost::mutex::scoped_lock lock(gLogStreamMutex);
  187. #endif
  188. // (HACK) Check whether the 'stream.user' pointer points to a
  189. // custom LogStream allocated by #aiGetPredefinedLogStream.
  190. // In this case, we need to delete it, too. Of course, this
  191. // might cause strange problems, but the chance is quite low.
  192. PredefLogStreamMap::iterator it = std::find(gPredefinedStreams.begin(),
  193. gPredefinedStreams.end(), (Assimp::LogStream*)stream.user);
  194. if (it != gPredefinedStreams.end()) {
  195. delete *it;
  196. gPredefinedStreams.erase(it);
  197. }
  198. }
  199. /** @copydoc LogStream::write */
  200. void write(const char* message) {
  201. stream.callback(message,stream.user);
  202. }
  203. private:
  204. aiLogStream stream;
  205. };
  206. // ------------------------------------------------------------------------------------------------
  207. void ReportSceneNotFoundError()
  208. {
  209. DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. "
  210. "Are you playing fools with us? Don't mix cpp and c API. Thanks.");
  211. assert(false);
  212. }
  213. // ------------------------------------------------------------------------------------------------
  214. // Reads the given file and returns its content.
  215. const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
  216. {
  217. return aiImportFileEx(pFile,pFlags,NULL);
  218. }
  219. // ------------------------------------------------------------------------------------------------
  220. const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
  221. aiFileIO* pFS)
  222. {
  223. ai_assert(NULL != pFile);
  224. // create an Importer for this file
  225. Assimp::Importer* imp = new Assimp::Importer();
  226. #ifdef AI_C_THREADSAFE
  227. boost::mutex::scoped_lock lock(gMutex);
  228. #endif
  229. // copy the global property lists to the Importer instance
  230. imp->pimpl->mIntProperties = gIntProperties;
  231. imp->pimpl->mFloatProperties = gFloatProperties;
  232. imp->pimpl->mStringProperties = gStringProperties;
  233. #ifdef AI_C_THREADSAFE
  234. lock.unlock();
  235. #endif
  236. // setup a custom IO system if necessary
  237. if (pFS) {
  238. imp->SetIOHandler( new CIOSystemWrapper (pFS) );
  239. }
  240. // and have it read the file
  241. const aiScene* scene = imp->ReadFile( pFile, pFlags);
  242. // if succeeded, place it in the collection of active processes
  243. if( scene) {
  244. #ifdef AI_C_THREADSAFE
  245. lock.lock();
  246. #endif
  247. gActiveImports[scene] = imp;
  248. }
  249. else {
  250. // if failed, extract error code and destroy the import
  251. gLastErrorString = imp->GetErrorString();
  252. delete imp;
  253. }
  254. // return imported data. If the import failed the pointer is NULL anyways
  255. return scene;
  256. }
  257. // ------------------------------------------------------------------------------------------------
  258. const aiScene* aiImportFileFromMemory(
  259. const char* pBuffer,
  260. unsigned int pLength,
  261. unsigned int pFlags,
  262. const char* pHint)
  263. {
  264. ai_assert(NULL != pBuffer && 0 != pLength);
  265. // create an Importer for this file
  266. Assimp::Importer* imp = new Assimp::Importer();
  267. #ifdef AI_C_THREADSAFE
  268. boost::mutex::scoped_lock lock(gMutex);
  269. #endif
  270. // copy the global property lists to the Importer instance
  271. imp->pimpl->mIntProperties = gIntProperties;
  272. imp->pimpl->mFloatProperties = gFloatProperties;
  273. imp->pimpl->mStringProperties = gStringProperties;
  274. #ifdef AI_C_THREADSAFE
  275. lock.unlock();
  276. #endif
  277. // and have it read the file from the memory buffer
  278. const aiScene* scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint);
  279. // if succeeded, place it in the collection of active processes
  280. if( scene) {
  281. #ifdef AI_C_THREADSAFE
  282. lock.lock();
  283. #endif
  284. gActiveImports[scene] = imp;
  285. }
  286. else {
  287. // if failed, extract error code and destroy the import
  288. gLastErrorString = imp->GetErrorString();
  289. delete imp;
  290. }
  291. // return imported data. If the import failed the pointer is NULL anyways
  292. return scene;
  293. }
  294. // ------------------------------------------------------------------------------------------------
  295. // Releases all resources associated with the given import process.
  296. void aiReleaseImport( const aiScene* pScene)
  297. {
  298. if (!pScene) {
  299. return;
  300. }
  301. #ifdef AI_C_THREADSAFE
  302. boost::mutex::scoped_lock lock(gMutex);
  303. #endif
  304. // find the importer associated with this data
  305. ImporterMap::iterator it = gActiveImports.find( pScene);
  306. // it should be there... else the user is playing fools with us
  307. if( it == gActiveImports.end()) {
  308. ReportSceneNotFoundError();
  309. return;
  310. }
  311. // kill the importer, the data dies with it
  312. delete it->second;
  313. gActiveImports.erase( it);
  314. }
  315. // ------------------------------------------------------------------------------------------------
  316. ASSIMP_API const aiScene* aiApplyPostProcessing(const aiScene* pScene,
  317. unsigned int pFlags)
  318. {
  319. #ifdef AI_C_THREADSAFE
  320. boost::mutex::scoped_lock lock(gMutex);
  321. #endif
  322. // find the importer associated with this data
  323. ImporterMap::iterator it = gActiveImports.find( pScene);
  324. // it should be there... else the user is playing fools with us
  325. if( it == gActiveImports.end()) {
  326. ReportSceneNotFoundError();
  327. return NULL;
  328. }
  329. #ifdef AI_C_THREADSAFE
  330. lock.unlock();
  331. #endif
  332. const aiScene* sc = it->second->ApplyPostProcessing(pFlags);
  333. #ifdef AI_C_THREADSAFE
  334. lock.lock();
  335. #endif
  336. if (!sc) {
  337. // kill the importer, the data dies with it
  338. delete it->second;
  339. gActiveImports.erase( it);
  340. return NULL;
  341. }
  342. return it->first;
  343. }
  344. // ------------------------------------------------------------------------------------------------
  345. void CallbackToLogRedirector (const char* msg, char* dt)
  346. {
  347. ai_assert(NULL != msg && NULL != dt);
  348. LogStream* s = (LogStream*)dt;
  349. s->write(msg);
  350. }
  351. // ------------------------------------------------------------------------------------------------
  352. ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const char* file)
  353. {
  354. aiLogStream sout;
  355. LogStream* stream = LogStream::createDefaultStream(pStream,file);
  356. if (!stream) {
  357. sout.callback = NULL;
  358. sout.user = NULL;
  359. }
  360. else {
  361. sout.callback = &CallbackToLogRedirector;
  362. sout.user = (char*)stream;
  363. }
  364. gPredefinedStreams.push_back(stream);
  365. return sout;
  366. }
  367. // ------------------------------------------------------------------------------------------------
  368. ASSIMP_API void aiAttachLogStream( const aiLogStream* stream )
  369. {
  370. #ifdef AI_C_THREADSAFE
  371. boost::mutex::scoped_lock lock(gLogStreamMutex);
  372. #endif
  373. LogStream* lg = new LogToCallbackRedirector(*stream);
  374. gActiveLogStreams[*stream] = lg;
  375. if (DefaultLogger::isNullLogger()) {
  376. DefaultLogger::create(NULL,(gVerboseLogging == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL));
  377. }
  378. DefaultLogger::get()->attachStream(lg);
  379. }
  380. // ------------------------------------------------------------------------------------------------
  381. ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream)
  382. {
  383. #ifdef AI_C_THREADSAFE
  384. boost::mutex::scoped_lock lock(gLogStreamMutex);
  385. #endif
  386. // find the logstream associated with this data
  387. LogStreamMap::iterator it = gActiveLogStreams.find( *stream);
  388. // it should be there... else the user is playing fools with us
  389. if( it == gActiveLogStreams.end()) {
  390. return AI_FAILURE;
  391. }
  392. delete it->second;
  393. gActiveLogStreams.erase( it);
  394. if (gActiveLogStreams.empty()) {
  395. DefaultLogger::kill();
  396. }
  397. return AI_SUCCESS;
  398. }
  399. // ------------------------------------------------------------------------------------------------
  400. ASSIMP_API void aiDetachAllLogStreams(void)
  401. {
  402. #ifdef AI_C_THREADSAFE
  403. boost::mutex::scoped_lock lock(gLogStreamMutex);
  404. #endif
  405. for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) {
  406. delete it->second;
  407. }
  408. gActiveLogStreams.clear();
  409. DefaultLogger::kill();
  410. }
  411. // ------------------------------------------------------------------------------------------------
  412. ASSIMP_API void aiEnableVerboseLogging(aiBool d)
  413. {
  414. if (!DefaultLogger::isNullLogger()) {
  415. DefaultLogger::get()->setLogSeverity((d == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL));
  416. }
  417. gVerboseLogging = d;
  418. }
  419. // ------------------------------------------------------------------------------------------------
  420. // Returns the error text of the last failed import process.
  421. const char* aiGetErrorString()
  422. {
  423. return gLastErrorString.c_str();
  424. }
  425. // ------------------------------------------------------------------------------------------------
  426. // Returns the error text of the last failed import process.
  427. aiBool aiIsExtensionSupported(const char* szExtension)
  428. {
  429. ai_assert(NULL != szExtension);
  430. #ifdef AI_C_THREADSAFE
  431. boost::mutex::scoped_lock lock(gMutex);
  432. #endif
  433. if (!gActiveImports.empty()) {
  434. return ((*(gActiveImports.begin())).second->IsExtensionSupported( szExtension )) ? AI_TRUE : AI_FALSE;
  435. }
  436. // fixme: no need to create a temporary Importer instance just for that ..
  437. Assimp::Importer tmp;
  438. return tmp.IsExtensionSupported(std::string(szExtension)) ? AI_TRUE : AI_FALSE;
  439. }
  440. // ------------------------------------------------------------------------------------------------
  441. // Get a list of all file extensions supported by ASSIMP
  442. void aiGetExtensionList(aiString* szOut)
  443. {
  444. ai_assert(NULL != szOut);
  445. #ifdef AI_C_THREADSAFE
  446. boost::mutex::scoped_lock lock(gMutex);
  447. #endif
  448. if (!gActiveImports.empty())
  449. {
  450. (*(gActiveImports.begin())).second->GetExtensionList(*szOut);
  451. return;
  452. }
  453. // fixme: no need to create a temporary Importer instance just for that ..
  454. Assimp::Importer tmp;
  455. tmp.GetExtensionList(*szOut);
  456. }
  457. // ------------------------------------------------------------------------------------------------
  458. // Get the memory requirements for a particular import.
  459. void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
  460. C_STRUCT aiMemoryInfo* in)
  461. {
  462. #ifdef AI_C_THREADSAFE
  463. boost::mutex::scoped_lock lock(gMutex);
  464. #endif
  465. // find the importer associated with this data
  466. ImporterMap::iterator it = gActiveImports.find( pIn);
  467. // it should be there... else the user is playing fools with us
  468. if( it == gActiveImports.end()) {
  469. ReportSceneNotFoundError();
  470. return;
  471. }
  472. // get memory statistics
  473. #ifdef AI_C_THREADSAFE
  474. lock.unlock();
  475. #endif
  476. it->second->GetMemoryRequirements(*in);
  477. }
  478. // ------------------------------------------------------------------------------------------------
  479. // Importer::SetPropertyInteger
  480. ASSIMP_API void aiSetImportPropertyInteger(const char* szName, int value)
  481. {
  482. #ifdef AI_C_THREADSAFE
  483. boost::mutex::scoped_lock lock(gMutex);
  484. #endif
  485. SetGenericProperty<int>(gIntProperties,szName,value,NULL);
  486. }
  487. // ------------------------------------------------------------------------------------------------
  488. // Importer::SetPropertyFloat
  489. ASSIMP_API void aiSetImportPropertyFloat(const char* szName, float value)
  490. {
  491. #ifdef AI_C_THREADSAFE
  492. boost::mutex::scoped_lock lock(gMutex);
  493. #endif
  494. SetGenericProperty<float>(gFloatProperties,szName,value,NULL);
  495. }
  496. // ------------------------------------------------------------------------------------------------
  497. // Importer::SetPropertyString
  498. ASSIMP_API void aiSetImportPropertyString(const char* szName,
  499. const C_STRUCT aiString* st)
  500. {
  501. if (!st) {
  502. return;
  503. }
  504. #ifdef AI_C_THREADSAFE
  505. boost::mutex::scoped_lock lock(gMutex);
  506. #endif
  507. SetGenericProperty<std::string>(gStringProperties,szName,
  508. std::string( st->data ),NULL);
  509. }
  510. // ------------------------------------------------------------------------------------------------
  511. // Rotation matrix to quaternion
  512. ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x3* mat)
  513. {
  514. ai_assert(NULL != quat && NULL != mat);
  515. *quat = aiQuaternion(*mat);
  516. }
  517. // ------------------------------------------------------------------------------------------------
  518. // Matrix decomposition
  519. ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4* mat,aiVector3D* scaling,
  520. aiQuaternion* rotation,
  521. aiVector3D* position)
  522. {
  523. ai_assert(NULL != rotation && NULL != position && NULL != scaling && NULL != mat);
  524. mat->Decompose(*scaling,*rotation,*position);
  525. }
  526. // ------------------------------------------------------------------------------------------------
  527. // Matrix transpose
  528. ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3* mat)
  529. {
  530. ai_assert(NULL != mat);
  531. mat->Transpose();
  532. }
  533. // ------------------------------------------------------------------------------------------------
  534. ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat)
  535. {
  536. ai_assert(NULL != mat);
  537. mat->Transpose();
  538. }
  539. // ------------------------------------------------------------------------------------------------
  540. // Vector transformation
  541. ASSIMP_API void aiTransformVecByMatrix3(C_STRUCT aiVector3D* vec,
  542. const C_STRUCT aiMatrix3x3* mat)
  543. {
  544. ai_assert(NULL != mat && NULL != vec);
  545. *vec *= (*mat);
  546. }
  547. // ------------------------------------------------------------------------------------------------
  548. ASSIMP_API void aiTransformVecByMatrix4(C_STRUCT aiVector3D* vec,
  549. const C_STRUCT aiMatrix4x4* mat)
  550. {
  551. ai_assert(NULL != mat && NULL != vec);
  552. *vec *= (*mat);
  553. }
  554. // ------------------------------------------------------------------------------------------------
  555. // Matrix multiplication
  556. ASSIMP_API void aiMultiplyMatrix4(
  557. C_STRUCT aiMatrix4x4* dst,
  558. const C_STRUCT aiMatrix4x4* src)
  559. {
  560. ai_assert(NULL != dst && NULL != src);
  561. *dst = (*dst) * (*src);
  562. }
  563. // ------------------------------------------------------------------------------------------------
  564. ASSIMP_API void aiMultiplyMatrix3(
  565. C_STRUCT aiMatrix3x3* dst,
  566. const C_STRUCT aiMatrix3x3* src)
  567. {
  568. ai_assert(NULL != dst && NULL != src);
  569. *dst = (*dst) * (*src);
  570. }
  571. // ------------------------------------------------------------------------------------------------
  572. // Matrix identity
  573. ASSIMP_API void aiIdentityMatrix3(
  574. C_STRUCT aiMatrix3x3* mat)
  575. {
  576. ai_assert(NULL != mat);
  577. *mat = aiMatrix3x3();
  578. }
  579. // ------------------------------------------------------------------------------------------------
  580. ASSIMP_API void aiIdentityMatrix4(
  581. C_STRUCT aiMatrix4x4* mat)
  582. {
  583. ai_assert(NULL != mat);
  584. *mat = aiMatrix4x4();
  585. }