dox.h 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647
  1. /** @file dox.h
  2. * @brief General documentation built from a doxygen comment
  3. */
  4. /**
  5. @mainpage assimp - Open Asset Import Library
  6. <img src="dragonsplash.png"></img>
  7. @section intro Introduction
  8. assimp is a library to load and process geometric scenes from various data formats. It is tailored at typical game
  9. scenarios by supporting a node hierarchy, static or skinned meshes, materials, bone animations and potential texture data.
  10. The library is *not* designed for speed, it is primarily useful for importing assets from various sources once and
  11. storing it in a engine-specific format for easy and fast every-day-loading. assimp is also able to apply various post
  12. processing steps to the imported data such as conversion to indexed meshes, calculation of normals or tangents/bitangents
  13. or conversion from right-handed to left-handed coordinate systems.
  14. assimp currently supports the following file formats (note that some loaders lack some features of their formats because
  15. some file formats contain data not supported by assimp, some stuff would require so much conversion work
  16. that it has not been implemented yet and some (most ...) formats lack proper specifications):
  17. <hr>
  18. <br><tt>
  19. <b>Collada</b> ( <i>*.dae;*.xml</i> )<br>
  20. <b>Blender</b> ( <i>*.blend</i> ) <sup>3</sup><br>
  21. <b>Biovision BVH </b> ( <i>*.bvh</i> ) <br>
  22. <b>3D Studio Max 3DS</b> ( <i>*.3ds</i> ) <br>
  23. <b>3D Studio Max ASE</b> ( <i>*.ase</i> ) <br>
  24. <b>Wavefront Object</b> ( <i>*.obj</i> ) <br>
  25. <b>Stanford Polygon Library</b> ( <i>*.ply</i> ) <br>
  26. <b>AutoCAD DXF</b> ( <i>*.dxf</i> ) <br>
  27. <b>IFC-STEP</b> ( <i>*.ifc</i> )<br>
  28. <b>Neutral File Format</b> ( <i>*.nff</i> ) <br>
  29. <b>Sense8 WorldToolkit</b> ( <i>*.nff</i> ) <br>
  30. <b>Valve Model</b> ( <i>*.smd,*.vta</i> ) <sup>3</sup> <br>
  31. <b>Quake I</b> ( <i>*.mdl</i> ) <br>
  32. <b>Quake II</b> ( <i>*.md2</i> ) <br>
  33. <b>Quake III</b> ( <i>*.md3</i> ) <br>
  34. <b>Quake 3 BSP</b> ( <i>*.pk3</i> ) <sup>1</sup> <br>
  35. <b>RtCW</b> ( <i>*.mdc</i> )<br>
  36. <b>Doom 3</b> ( <i>*.md5mesh;*.md5anim;*.md5camera</i> ) <br>
  37. <b>DirectX X </b> ( <i>*.x</i> ). <br>
  38. <b>Quick3D </b> ( <i>*.q3o;*q3s</i> ). <br>
  39. <b>Raw Triangles </b> ( <i>*.raw</i> ). <br>
  40. <b>AC3D </b> ( <i>*.ac</i> ). <br>
  41. <b>Stereolithography </b> ( <i>*.stl</i> ). <br>
  42. <b>Autodesk DXF </b> ( <i>*.dxf</i> ). <br>
  43. <b>Irrlicht Mesh </b> ( <i>*.irrmesh;*.xml</i> ). <br>
  44. <b>Irrlicht Scene </b> ( <i>*.irr;*.xml</i> ). <br>
  45. <b>Object File Format </b> ( <i>*.off</i> ). <br>
  46. <b>Terragen Terrain </b> ( <i>*.ter</i> ) <br>
  47. <b>3D GameStudio Model </b> ( <i>*.mdl</i> ) <br>
  48. <b>3D GameStudio Terrain</b> ( <i>*.hmp</i> )<br>
  49. <b>Ogre</b> (<i>*.mesh.xml, *.skeleton.xml, *.material</i>)<sup>3</sup> <br>
  50. <b>Milkshape 3D</b> ( <i>*.ms3d</i> )<br>
  51. <b>LightWave Model</b> ( <i>*.lwo</i> )<br>
  52. <b>LightWave Scene</b> ( <i>*.lws</i> )<br>
  53. <b>Modo Model</b> ( <i>*.lxo</i> )<br>
  54. <b>CharacterStudio Motion</b> ( <i>*.csm</i> )<br>
  55. <b>Stanford Ply</b> ( <i>*.ply</i> )<br>
  56. <b>TrueSpace</b> ( <i>*.cob, *.scn</i> )<sup>2</sup><br><br>
  57. </tt>
  58. See the @link importer_notes Importer Notes Page @endlink for information, what a specific importer can do and what not.
  59. Note that although this paper claims to be the official documentation,
  60. https://github.com/assimp/assimp/blob/master/Readme.md
  61. <br>is usually the most up-to-date list of file formats supported by the library. <br>
  62. <sup>1</sup>: Experimental loaders<br>
  63. <sup>2</sup>: Indicates very limited support - many of the format's features don't map to Assimp's data structures.<br>
  64. <sup>3</sup>: These formats support animations, but assimp doesn't yet support them (or they're buggy)<br>
  65. <br>
  66. <hr>
  67. assimp is independent of the Operating System by nature, providing a C++ interface for easy integration
  68. with game engines and a C interface to allow bindings to other programming languages. At the moment the library runs
  69. on any little-endian platform including X86/Windows/Linux/Mac and X64/Windows/Linux/Mac. Special attention
  70. was paid to keep the library as free as possible from dependencies.
  71. Big endian systems such as PPC-Macs or PPC-Linux systems are not officially supported at the moment. However, most
  72. formats handle the required endian conversion correctly, so large parts of the library should work.
  73. The assimp linker library and viewer application are provided under the BSD 3-clause license. This basically means
  74. that you are free to use it in open- or closed-source projects, for commercial or non-commercial purposes as you like
  75. as long as you retain the license information and take own responsibility for what you do with it. For details see
  76. the LICENSE file.
  77. You can find test models for almost all formats in the <assimp_root>/test/models directory. Beware, they're *free*,
  78. but not all of them are *open-source*. If there's an accompagning '<file>\source.txt' file don't forget to read it.
  79. @section main_install Installation
  80. assimp can be used in two ways: linking against the pre-built libraries or building the library on your own. The former
  81. option is the easiest, but the assimp distribution contains pre-built libraries only for Visual C++ 2013, 2015 and 2017.
  82. For other compilers you'll have to build assimp for yourself. Which is hopefully as hassle-free as the other way, but
  83. needs a bit more work. Both ways are described at the @link install Installation page. @endlink
  84. If you want to use assimp on Ubuntu you can install it via the following command:
  85. @code
  86. sudo apt-get install assimp
  87. @endcode
  88. If you want to use the python-assimp-port just follow these instructions: https://github.com/assimp/assimp/tree/master/port/PyAssimp
  89. @section main_usage Usage
  90. When you're done integrating the library into your IDE / project, you can now start using it. There are two separate
  91. interfaces by which you can access the library: a C++ interface and a C interface using flat functions. While the former
  92. is easier to handle, the latter also forms a point where other programming languages can connect to. Up to the moment, though,
  93. there are no bindings for any other language provided. Have a look at the @link usage Usage page @endlink for a detailed explanation and code examples.
  94. @section main_data Data Structures
  95. When the importer successfully completed its job, the imported data is returned in an aiScene structure. This is the root
  96. point from where you can access all the various data types that a scene/model file can possibly contain. The
  97. @link data Data Structures page @endlink describes how to interpret this data.
  98. @section ext Extending the library
  99. There are many 3d file formats in the world, and we're happy to support as many as possible. If you need support for
  100. a particular file format, why not implement it yourself and add it to the library? Writing importer plugins for
  101. assimp is considerably easy, as the whole postprocessing infrastructure is available and does much of the work for you.
  102. See the @link extend Extending the library @endlink page for more information.
  103. @section main_support Support & Feedback
  104. If you have any questions/comments/suggestions/bug reports you're welcome to post them in our
  105. <a href="https://sourceforge.net/forum/forum.php?forum_id=817653">forums</a>. Alternatively there's
  106. a mailing list, <a href="https://sourceforge.net/mailarchive/forum.php?forum_name=assimp-discussions">
  107. assimp-discussions</a>.
  108. */
  109. /**
  110. @page install Installation
  111. @section install_prebuilt Using the pre-built libraries with Visual C++ 8/9
  112. If you develop at Visual Studio 2015 or 2017, you can simply use the pre-built linker libraries provided in the distribution.
  113. Extract all files to a place of your choice. A directory called "assimp" will be created there. Add the assimp/include path
  114. to your include paths (Menu-&gt;Extras-&gt;Options-&gt;Projects and Solutions-&gt;VC++ Directories-&gt;Include files)
  115. and the assimp/lib/&lt;Compiler&gt; path to your linker paths (Menu-&gt;Extras-&gt;Options-&gt;Projects and Solutions-&gt;VC++ Directories-&gt;Library files).
  116. This is necessary only once to setup all paths inside you IDE.
  117. To use the library in your C++ project you can simply generate a project file via cmake. One way is to add the assimp-folder
  118. as a subdirectory via the cmake-command
  119. @code
  120. addsubdiectory(assimp)
  121. @endcode
  122. Now just add the assimp-dependency to your application:
  123. @code
  124. TARGET_LINK_LIBRARIES(my_game assimp)
  125. @endcode
  126. If done correctly you should now be able to compile, link, run and use the application.
  127. @section install_own Building the library from scratch
  128. First you need to install cmake. Now just get the code from github or download the latest version from the webside.
  129. to build the library just open a command-prompt / bash, navigate into the repo-folder and run cmake via:
  130. @code
  131. cmake CMakeLists.txt
  132. @endcode
  133. A project-file of your default make-system ( like gnu-make on linux or Visual-Studio on Windows ) will be generated.
  134. Run the build and you are done. You can find the libs at assimp/lib and the dll's / so's at bin.
  135. @section assimp_dll Windows DLL Build
  136. The Assimp-package can be built as DLL. You just need to run the default cmake run.
  137. @section assimp static lib
  138. The Assimp-package can be build as a static library as well. Do do so just set the configuration variable <b>BUILD_SHARED_LIBS</b>
  139. to off during the cmake run.
  140. */
  141. /**
  142. @page usage Usage
  143. @section access_cpp Access by C++ class interface
  144. The assimp library can be accessed by both a class or flat function interface. The C++ class
  145. interface is the preferred way of interaction: you create an instance of class Assimp::Importer,
  146. maybe adjust some settings of it and then call Assimp::Importer::ReadFile(). The class will
  147. read the files and process its data, handing back the imported data as a pointer to an aiScene
  148. to you. You can now extract the data you need from the file. The importer manages all the resources
  149. for itsself. If the importer is destroyed, all the data that was created/read by it will be
  150. destroyed, too. So the easiest way to use the Importer is to create an instance locally, use its
  151. results and then simply let it go out of scope.
  152. C++ example:
  153. @code
  154. #include <assimp/Importer.hpp> // C++ importer interface
  155. #include <assimp/scene.h> // Output data structure
  156. #include <assimp/postprocess.h> // Post processing flags
  157. bool DoTheImportThing( const std::string& pFile)
  158. {
  159. // Create an instance of the Importer class
  160. Assimp::Importer importer;
  161. // And have it read the given file with some example postprocessing
  162. // Usually - if speed is not the most important aspect for you - you'll
  163. // probably to request more postprocessing than we do in this example.
  164. const aiScene* scene = importer.ReadFile( pFile,
  165. aiProcess_CalcTangentSpace |
  166. aiProcess_Triangulate |
  167. aiProcess_JoinIdenticalVertices |
  168. aiProcess_SortByPType);
  169. // If the import failed, report it
  170. if( !scene)
  171. {
  172. DoTheErrorLogging( importer.GetErrorString());
  173. return false;
  174. }
  175. // Now we can access the file's contents.
  176. DoTheSceneProcessing( scene);
  177. // We're done. Everything will be cleaned up by the importer destructor
  178. return true;
  179. }
  180. @endcode
  181. What exactly is read from the files and how you interpret it is described at the @ref data page. @endlink The post processing steps that the assimp library can apply to the
  182. imported data are listed at #aiPostProcessSteps. See the @ref pp Post processing page for more details.
  183. Note that the aiScene data structure returned is declared 'const'. Yes, you can get rid of
  184. these 5 letters with a simple cast. Yes, you may do that. No, it's not recommended (and it's
  185. suicide in DLL builds if you try to use new or delete on any of the arrays in the scene).
  186. @section access_c Access by plain-c function interface
  187. The plain function interface is just as simple, but requires you to manually call the clean-up
  188. after you're done with the imported data. To start the import process, call aiImportFile()
  189. with the filename in question and the desired postprocessing flags like above. If the call
  190. is successful, an aiScene pointer with the imported data is handed back to you. When you're
  191. done with the extraction of the data you're interested in, call aiReleaseImport() on the
  192. imported scene to clean up all resources associated with the import.
  193. C example:
  194. @code
  195. #include <assimp/cimport.h> // Plain-C interface
  196. #include <assimp/scene.h> // Output data structure
  197. #include <assimp/postprocess.h> // Post processing flags
  198. bool DoTheImportThing( const char* pFile)
  199. {
  200. // Start the import on the given file with some example postprocessing
  201. // Usually - if speed is not the most important aspect for you - you'll t
  202. // probably to request more postprocessing than we do in this example.
  203. const aiScene* scene = aiImportFile( pFile,
  204. aiProcess_CalcTangentSpace |
  205. aiProcess_Triangulate |
  206. aiProcess_JoinIdenticalVertices |
  207. aiProcess_SortByPType);
  208. // If the import failed, report it
  209. if( !scene)
  210. {
  211. DoTheErrorLogging( aiGetErrorString());
  212. return false;
  213. }
  214. // Now we can access the file's contents
  215. DoTheSceneProcessing( scene);
  216. // We're done. Release all resources associated with this import
  217. aiReleaseImport( scene);
  218. return true;
  219. }
  220. @endcode
  221. @section custom_io Using custom IO logic with the C++ class interface
  222. The assimp library needs to access files internally. This of course applies to the file you want
  223. to read, but also to additional files in the same folder for certain file formats. By default,
  224. standard C/C++ IO logic is used to access these files. If your application works in a special
  225. environment where custom logic is needed to access the specified files, you have to supply
  226. custom implementations of IOStream and IOSystem. A shortened example might look like this:
  227. @code
  228. #include <assimp/IOStream.hpp>
  229. #include <assimp/IOSystem.hpp>
  230. // My own implementation of IOStream
  231. class MyIOStream : public Assimp::IOStream
  232. {
  233. friend class MyIOSystem;
  234. protected:
  235. // Constructor protected for private usage by MyIOSystem
  236. MyIOStream(void);
  237. public:
  238. ~MyIOStream(void);
  239. size_t Read( void* pvBuffer, size_t pSize, size_t pCount) { ... }
  240. size_t Write( const void* pvBuffer, size_t pSize, size_t pCount) { ... }
  241. aiReturn Seek( size_t pOffset, aiOrigin pOrigin) { ... }
  242. size_t Tell() const { ... }
  243. size_t FileSize() const { ... }
  244. void Flush () { ... }
  245. };
  246. // Fisher Price - My First Filesystem
  247. class MyIOSystem : public Assimp::IOSystem
  248. {
  249. MyIOSystem() { ... }
  250. ~MyIOSystem() { ... }
  251. // Check whether a specific file exists
  252. bool Exists( const std::string& pFile) const {
  253. ..
  254. }
  255. // Get the path delimiter character we'd like to see
  256. char GetOsSeparator() const {
  257. return '/';
  258. }
  259. // ... and finally a method to open a custom stream
  260. IOStream* Open( const std::string& pFile, const std::string& pMode) {
  261. return new MyIOStream( ... );
  262. }
  263. void Close( IOStream* pFile) { delete pFile; }
  264. };
  265. @endcode
  266. Now that your IO system is implemented, supply an instance of it to the Importer object by calling
  267. Assimp::Importer::SetIOHandler().
  268. @code
  269. void DoTheImportThing( const std::string& pFile)
  270. {
  271. Assimp::Importer importer;
  272. // put my custom IO handling in place
  273. importer.SetIOHandler( new MyIOSystem());
  274. // the import process will now use this implementation to access any file
  275. importer.ReadFile( pFile, SomeFlag | SomeOtherFlag);
  276. }
  277. @endcode
  278. @section custom_io_c Using custom IO logic with the plain-c function interface
  279. The C interface also provides a way to override the file system. Control is not as fine-grained as for C++ although
  280. surely enough for almost any purpose. The process is simple:
  281. <ul>
  282. <li> Include cfileio.h
  283. <li> Fill an aiFileIO structure with custom file system callbacks (they're self-explanatory as they work similar to the CRT's fXXX functions)
  284. <li> .. and pass it as parameter to #aiImportFileEx
  285. </ul>
  286. @section logging Logging
  287. The assimp library provides an easy mechanism to log messages. For instance if you want to check the state of your
  288. import and you just want to see, after which preprocessing step the import-process was aborted you can take a look
  289. into the log.
  290. Per default the assimp-library provides a default log implementation, where you can log your user specific message
  291. by calling it as a singleton with the requested logging-type. To see how this works take a look to this:
  292. @code
  293. using namespace Assimp;
  294. // Create a logger instance
  295. DefaultLogger::create("", Logger::VERBOSE);
  296. // Now I am ready for logging my stuff
  297. DefaultLogger::get()->info("this is my info-call");
  298. // Kill it after the work is done
  299. DefaultLogger::kill();
  300. @endcode
  301. At first you have to create the default-logger-instance (create). Now you are ready to rock and can log a
  302. little bit around. After that you should kill it to release the singleton instance.
  303. If you want to integrate the assimp-log into your own GUI it my be helpful to have a mechanism writing
  304. the logs into your own log windows. The logger interface provides this by implementing an interface called LogStream.
  305. You can attach and detach this log stream to the default-logger instance or any implementation derived from Logger.
  306. Just derivate your own logger from the abstract base class LogStream and overwrite the write-method:
  307. @code
  308. // Example stream
  309. class myStream : public LogStream
  310. {
  311. public:
  312. // Write womethink using your own functionality
  313. void write(const char* message)
  314. {
  315. ::printf("%s\n", message);
  316. }
  317. };
  318. // Select the kinds of messages you want to receive on this log stream
  319. const unsigned int severity = Logger::Debugging|Logger::Info|Logger::Err|Logger::Warn;
  320. // Attaching it to the default logger
  321. Assimp::DefaultLogger::get()->attachStream( new myStream, severity );
  322. @endcode
  323. The severity level controls the kind of message which will be written into
  324. the attached stream. If you just want to log errors and warnings set the warn
  325. and error severity flag for those severities. It is also possible to remove
  326. a self defined logstream from an error severity by detaching it with the severity
  327. flag set:
  328. @code
  329. unsigned int severity = 0;
  330. severity |= Logger::Debugging;
  331. // Detach debug messages from you self defined stream
  332. Assimp::DefaultLogger::get()->attachStream( new myStream, severity );
  333. @endcode
  334. If you want to implement your own logger just derive from the abstract base class
  335. #Logger and overwrite the methods debug, info, warn and error.
  336. If you want to see the debug-messages in a debug-configured build, the Logger-interface
  337. provides a logging-severity. You can set it calling the following method:
  338. @code
  339. Assimp::DefaultLogger::get()->setLogSeverity( LogSeverity log_severity );
  340. @endcode
  341. The normal logging severity supports just the basic stuff like, info, warnings and errors.
  342. In the verbose level very fine-grained debug messages will be logged, too. Note that this
  343. kind kind of logging might decrease import performance.
  344. */
  345. /**
  346. @page data Data Structures
  347. The assimp library returns the imported data in a collection of structures. aiScene forms the root
  348. of the data, from here you gain access to all the nodes, meshes, materials, animations or textures
  349. that were read from the imported file. The aiScene is returned from a successful call to
  350. assimp::Importer::ReadFile(), aiImportFile() or aiImportFileEx() - see the @link usage Usage page @endlink
  351. for further information on how to use the library.
  352. By default, all 3D data is provided in a right-handed coordinate system such as OpenGL uses. In
  353. this coordinate system, +X points to the right, +Y points upwards and +Z points out of the screen
  354. towards the viewer. Several modeling packages such as 3D Studio Max use this coordinate system as well
  355. (or a rotated variant of it).
  356. By contrast, some other environments use left-handed coordinate systems, a prominent example being
  357. DirectX. If you need the imported data to be in a left-handed coordinate system, supply the
  358. #aiProcess_MakeLeftHanded flag to the ReadFile() function call.
  359. The output face winding is counter clockwise. Use #aiProcess_FlipWindingOrder to get CW data.
  360. @code
  361. x2
  362. x1
  363. x0
  364. @endcode
  365. Outputted polygons can be literally everything: they're probably concave, self-intersecting or non-planar,
  366. although our built-in triangulation (#aiProcess_Triangulate postprocessing step) doesn't handle the two latter.
  367. The output UV coordinate system has its origin in the lower-left corner:
  368. @code
  369. 0x|1y ---------- 1x|1y
  370. | |
  371. | |
  372. | |
  373. 0x|0y ---------- 1x|0y
  374. @endcode
  375. Use the #aiProcess_FlipUVs flag to get UV coordinates with the upper-left corner als origin.
  376. A typical 4x4 matrix including a translational part looks like this:
  377. @code
  378. X1 Y1 Z1 T1
  379. X2 Y2 Z2 T2
  380. X3 Y3 Z3 T3
  381. 0 0 0 1
  382. @endcode
  383. with <tt>(X1, X2, X3)</tt> being the local X base vector, <tt>(Y1, Y2, Y3)</tt> being the local
  384. Y base vector, <tt>(Z1, Z2, Z3)</tt> being the local Z base vector and <tt>(T1, T2, T3)</tt> being the
  385. offset of the local origin (the translational part).
  386. All matrices in the library use row-major storage order. That means that the matrix elements are
  387. stored row-by-row, i.e. they end up like this in memory:
  388. <tt>[X1, Y1, Z1, T1, X2, Y2, Z2, T2, X3, Y3, Z3, T3, 0, 0, 0, 1]</tt>.
  389. Note that this is neither the OpenGL format nor the DirectX format, because both of them specify the
  390. matrix layout such that the translational part occupies three consecutive addresses in memory (so those
  391. matrices end with <tt>[..., T1, T2, T3, 1]</tt>), whereas the translation in an Assimp matrix is found at
  392. the offsets 3, 7 and 11 (spread across the matrix). You can transpose an Assimp matrix to end up with
  393. the format that OpenGL and DirectX mandate. To be very precise: The transposition has nothing
  394. to do with a left-handed or right-handed coordinate system but 'converts' between row-major and
  395. column-major storage format.
  396. <hr>
  397. <b>11.24.09:</b> We changed the orientation of our quaternions to the most common convention to avoid confusion.
  398. However, if you're a previous user of Assimp and you update the library to revisions beyond SVNREV 502,
  399. you have to adapt your animation loading code to match the new quaternion orientation.
  400. <hr>
  401. @section hierarchy The Node Hierarchy
  402. Nodes are little named entities in the scene that have a place and orientation relative to their parents.
  403. Starting from the scene's root node all nodes can have 0 to x child nodes, thus forming a hierarchy.
  404. They form the base on which the scene is built on: a node can refer to 0..x meshes, can be referred to
  405. by a bone of a mesh or can be animated by a key sequence of an animation. DirectX calls them "frames",
  406. others call them "objects", we call them aiNode.
  407. A node can potentially refer to single or multiple meshes. The meshes are not stored inside the node, but
  408. instead in an array of aiMesh inside the aiScene. A node only refers to them by their array index. This also means
  409. that multiple nodes can refer to the same mesh, which provides a simple form of instancing. A mesh referred to
  410. by this way lives in the node's local coordinate system. If you want the mesh's orientation in global
  411. space, you'd have to concatenate the transformations from the referring node and all of its parents.
  412. Most of the file formats don't really support complex scenes, though, but a single model only. But there are
  413. more complex formats such as .3ds, .x or .collada scenes which may contain an arbitrary complex
  414. hierarchy of nodes and meshes. I for myself would suggest a recursive filter function such as the
  415. following pseudocode:
  416. @code
  417. void CopyNodesWithMeshes( aiNode node, SceneObject targetParent, Matrix4x4 accTransform)
  418. {
  419. SceneObject parent;
  420. Matrix4x4 transform;
  421. // if node has meshes, create a new scene object for it
  422. if( node.mNumMeshes > 0)
  423. {
  424. SceneObjekt newObject = new SceneObject;
  425. targetParent.addChild( newObject);
  426. // copy the meshes
  427. CopyMeshes( node, newObject);
  428. // the new object is the parent for all child nodes
  429. parent = newObject;
  430. transform.SetUnity();
  431. } else
  432. {
  433. // if no meshes, skip the node, but keep its transformation
  434. parent = targetParent;
  435. transform = node.mTransformation * accTransform;
  436. }
  437. // continue for all child nodes
  438. for( all node.mChildren)
  439. CopyNodesWithMeshes( node.mChildren[a], parent, transform);
  440. }
  441. @endcode
  442. This function copies a node into the scene graph if it has children. If yes, a new scene object
  443. is created for the import node and the node's meshes are copied over. If not, no object is created.
  444. Potential child objects will be added to the old targetParent, but there transformation will be correct
  445. in respect to the global space. This function also works great in filtering the bone nodes - nodes
  446. that form the bone hierarchy for another mesh/node, but don't have any mesh themselves.
  447. @section meshes Meshes
  448. All meshes of an imported scene are stored in an array of aiMesh* inside the aiScene. Nodes refer
  449. to them by their index in the array and providing the coordinate system for them, too. One mesh uses
  450. only a single material everywhere - if parts of the model use a different material, this part is
  451. moved to a separate mesh at the same node. The mesh refers to its material in the same way as the
  452. node refers to its meshes: materials are stored in an array inside aiScene, the mesh stores only
  453. an index into this array.
  454. An aiMesh is defined by a series of data channels. The presence of these data channels is defined
  455. by the contents of the imported file: by default there are only those data channels present in the mesh
  456. that were also found in the file. The only channels guaranteed to be always present are aiMesh::mVertices
  457. and aiMesh::mFaces. You can test for the presence of other data by testing the pointers against NULL
  458. or use the helper functions provided by aiMesh. You may also specify several post processing flags
  459. at Importer::ReadFile() to let assimp calculate or recalculate additional data channels for you.
  460. At the moment, a single aiMesh may contain a set of triangles and polygons. A single vertex does always
  461. have a position. In addition it may have one normal, one tangent and bitangent, zero to AI_MAX_NUMBER_OF_TEXTURECOORDS
  462. (4 at the moment) texture coords and zero to AI_MAX_NUMBER_OF_COLOR_SETS (4) vertex colors. In addition
  463. a mesh may or may not have a set of bones described by an array of aiBone structures. How to interpret
  464. the bone information is described later on.
  465. @section material Materials
  466. See the @link materials Material System Page. @endlink
  467. @section bones Bones
  468. A mesh may have a set of bones in the form of aiBone objects. Bones are a means to deform a mesh
  469. according to the movement of a skeleton. Each bone has a name and a set of vertices on which it has influence.
  470. Its offset matrix declares the transformation needed to transform from mesh space to the local space of this bone.
  471. Using the bones name you can find the corresponding node in the node hierarchy. This node in relation
  472. to the other bones' nodes defines the skeleton of the mesh. Unfortunately there might also be
  473. nodes which are not used by a bone in the mesh, but still affect the pose of the skeleton because
  474. they have child nodes which are bones. So when creating the skeleton hierarchy for a mesh I
  475. suggest the following method:
  476. a) Create a map or a similar container to store which nodes are necessary for the skeleton.
  477. Pre-initialise it for all nodes with a "no". <br>
  478. b) For each bone in the mesh: <br>
  479. b1) Find the corresponding node in the scene's hierarchy by comparing their names. <br>
  480. b2) Mark this node as "yes" in the necessityMap. <br>
  481. b3) Mark all of its parents the same way until you 1) find the mesh's node or 2) the parent of the mesh's node. <br>
  482. c) Recursively iterate over the node hierarchy <br>
  483. c1) If the node is marked as necessary, copy it into the skeleton and check its children <br>
  484. c2) If the node is marked as not necessary, skip it and do not iterate over its children. <br>
  485. Reasons: you need all the parent nodes to keep the transformation chain intact. For most
  486. file formats and modelling packages the node hierarchy of the skeleton is either a child
  487. of the mesh node or a sibling of the mesh node but this is by no means a requirement so you shouldn't rely on it.
  488. The node closest to the root node is your skeleton root, from there you
  489. start copying the hierarchy. You can skip every branch without a node being a bone in the mesh -
  490. that's why the algorithm skips the whole branch if the node is marked as "not necessary".
  491. You should now have a mesh in your engine with a skeleton that is a subset of the imported hierarchy.
  492. @section anims Animations
  493. An imported scene may contain zero to x aiAnimation entries. An animation in this context is a set
  494. of keyframe sequences where each sequence describes the orientation of a single node in the hierarchy
  495. over a limited time span. Animations of this kind are usually used to animate the skeleton of
  496. a skinned mesh, but there are other uses as well.
  497. An aiAnimation has a duration. The duration as well as all time stamps are given in ticks. To get
  498. the correct timing, all time stamp thus have to be divided by aiAnimation::mTicksPerSecond. Beware,
  499. though, that certain combinations of file format and exporter don't always store this information
  500. in the exported file. In this case, mTicksPerSecond is set to 0 to indicate the lack of knowledge.
  501. The aiAnimation consists of a series of aiNodeAnim's. Each bone animation affects a single node in
  502. the node hierarchy only, the name specifying which node is affected. For this node the structure
  503. stores three separate key sequences: a vector key sequence for the position, a quaternion key sequence
  504. for the rotation and another vector key sequence for the scaling. All 3d data is local to the
  505. coordinate space of the node's parent, that means in the same space as the node's transformation matrix.
  506. There might be cases where animation tracks refer to a non-existent node by their name, but this
  507. should not be the case in your every-day data.
  508. To apply such an animation you need to identify the animation tracks that refer to actual bones
  509. in your mesh. Then for every track: <br>
  510. a) Find the keys that lay right before the current anim time. <br>
  511. b) Optional: interpolate between these and the following keys. <br>
  512. c) Combine the calculated position, rotation and scaling to a transformation matrix <br>
  513. d) Set the affected node's transformation to the calculated matrix. <br>
  514. If you need hints on how to convert to or from quaternions, have a look at the
  515. <a href="http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix&Quaternion FAQ</a>. I suggest
  516. using logarithmic interpolation for the scaling keys if you happen to need them - usually you don't
  517. need them at all.
  518. @section textures Textures
  519. Normally textures used by assets are stored in separate files, however,
  520. there are file formats embedding their textures directly into the model file.
  521. Such textures are loaded into an aiTexture structure.
  522. In previous versions, the path from the query for `AI_MATKEY_TEXTURE(textureType, index)` would be
  523. `*<index>` where `<index>` is the index of the texture in aiScene::mTextures. Now this call will
  524. return a file path for embedded textures in FBX files. To test if it is an embedded texture use
  525. aiScene::GetEmbeddedTexture. If the returned pointer is not null, it is embedded und can be loaded
  526. from the data structure. If it is null, search for a separate file. Other file types still use the
  527. old behaviour.<br>
  528. If your rely on the old behaviour, you can use Assimp::Importer::SetPropertyBool with the key
  529. #AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING to force the old behaviour.
  530. There are two cases:
  531. 1. The texture is NOT compressed. Its color data is directly stored in the aiTexture structure as an
  532. array of aiTexture::mWidth * aiTexture::mHeight aiTexel structures. Each aiTexel represents a
  533. pixel (or "texel") of the texture image. The color data is stored in an unsigned RGBA8888 format,
  534. which can be easily used for both Direct3D and OpenGL (swizzling the order of the color
  535. components might be necessary). RGBA8888 has been chosen because it is well-known, easy to use
  536. and natively supported by nearly all graphics APIs.
  537. 2. This applies if aiTexture::mHeight == 0 is fulfilled. Then, texture is stored in a "compressed"
  538. format such as DDS or PNG. The term "compressed" does not mean that the texture data must
  539. actually be compressed, however the texture was found in the model file as if it was stored in a
  540. separate file on the harddisk. Appropriate decoders (such as libjpeg, libpng, D3DX, DevIL) are
  541. required to load theses textures. aiTexture::mWidth specifies the size of the texture data in
  542. bytes, aiTexture::pcData is a pointer to the raw image data and aiTexture::achFormatHint is
  543. either zeroed or contains the most common file extension of the embedded texture's format. This
  544. value is only set if assimp is able to determine the file format.
  545. */
  546. /**
  547. @page materials Material System
  548. @section General Overview
  549. All materials are stored in an array of aiMaterial inside the aiScene.
  550. Each aiMesh refers to one
  551. material by its index in the array. Due to the vastly diverging definitions and usages of material
  552. parameters there is no hard definition of a material structure. Instead a material is defined by
  553. a set of properties accessible by their names. Have a look at assimp/material.h to see what types of
  554. properties are defined. In this file there are also various functions defined to test for the
  555. presence of certain properties in a material and retrieve their values.
  556. @section mat_tex Textures
  557. Textures are organized in stacks, each stack being evaluated independently. The final color value from a particular texture stack is used in the shading equation. For example, the computed color value of the diffuse texture stack (aiTextureType_DIFFUSE) is multiplied with the amount of incoming diffuse light to obtain the final diffuse color of a pixel.
  558. @code
  559. Stack Resulting equation
  560. ------------------------
  561. | Constant base color | color
  562. ------------------------
  563. | Blend operation 0 | +
  564. ------------------------
  565. | Strength factor 0 | 0.25*
  566. ------------------------
  567. | Texture 0 | texture_0
  568. ------------------------
  569. | Blend operation 1 | *
  570. ------------------------
  571. | Strength factor 1 | 1.0*
  572. ------------------------
  573. | Texture 1 | texture_1
  574. ------------------------
  575. ... ...
  576. @endcode
  577. @section keys Constants
  578. All material key constants start with 'AI_MATKEY' (it's an ugly macro for historical reasons, don't ask).
  579. <table border="1">
  580. <tr>
  581. <th>Name</th>
  582. <th>Data Type</th>
  583. <th>Default Value</th>
  584. <th>Meaning</th>
  585. <th>Notes</th>
  586. </tr>
  587. <tr>
  588. <td><tt>NAME</tt></td>
  589. <td>aiString</td>
  590. <td>n/a</td>
  591. <td>The name of the material, if available. </td>
  592. <td>Ignored by <tt>aiProcess_RemoveRedundantMaterials</tt>. Materials are considered equal even if their names are different.</td>
  593. </tr>
  594. <tr>
  595. <td><tt>COLOR_DIFFUSE</tt></td>
  596. <td>aiColor3D</td>
  597. <td>black (0,0,0)</td>
  598. <td>Diffuse color of the material. This is typically scaled by the amount of incoming diffuse light (e.g. using gouraud shading) </td>
  599. <td>---</td>
  600. </tr>
  601. <tr>
  602. <td><tt>COLOR_SPECULAR</tt></td>
  603. <td>aiColor3D</td>
  604. <td>black (0,0,0)</td>
  605. <td>Specular color of the material. This is typically scaled by the amount of incoming specular light (e.g. using phong shading) </td>
  606. <td>---</td>
  607. </tr>
  608. <tr>
  609. <td><tt>COLOR_AMBIENT</tt></td>
  610. <td>aiColor3D</td>
  611. <td>black (0,0,0)</td>
  612. <td>Ambient color of the material. This is typically scaled by the amount of ambient light </td>
  613. <td>---</td>
  614. </tr>
  615. <tr>
  616. <td><tt>COLOR_EMISSIVE</tt></td>
  617. <td>aiColor3D</td>
  618. <td>black (0,0,0)</td>
  619. <td>Emissive color of the material. This is the amount of light emitted by the object. In real time applications it will usually not affect surrounding objects, but raytracing applications may wish to treat emissive objects as light sources. </td>
  620. <td>---</td>
  621. </tr>
  622. <tr>
  623. <td><tt>COLOR_TRANSPARENT</tt></td>
  624. <td>aiColor3D</td>
  625. <td>black (0,0,0)</td>
  626. <td>Defines the transparent color of the material, this is the color to be multiplied with the color of translucent light to construct the final 'destination color' for a particular position in the screen buffer.</td>
  627. <td>---</td>
  628. </tr>
  629. <tr>
  630. <td><tt>COLOR_REFLECTIVE</tt></td>
  631. <td>aiColor3D</td>
  632. <td>black (0,0,0)</td>
  633. <td>Defines the reflective color of the material. This is typically scaled by the amount of incoming light from the direction of mirror reflection. Usually combined with an environment lightmap of some kind for real-time applications.</td>
  634. <td>---</td>
  635. </tr>
  636. <tr>
  637. <td><tt>REFLECTIVITY</tt></td>
  638. <td>float</td>
  639. <td>0.0</td>
  640. <td>Scales the reflective color of the material.</td>
  641. <td>---</td>
  642. </tr>
  643. <tr>
  644. <td><tt>WIREFRAME</tt></td>
  645. <td>int</td>
  646. <td>false</td>
  647. <td>Specifies whether wireframe rendering must be turned on for the material. 0 for false, !0 for true. </td>
  648. <td>---</td>
  649. </tr>
  650. <tr>
  651. <td><tt>TWOSIDED</tt></td>
  652. <td>int</td>
  653. <td>false</td>
  654. <td>Specifies whether meshes using this material must be rendered without backface culling. 0 for false, !0 for true. </td>
  655. <td>Some importers set this property if they don't know whether the output face order is right. As long as it is not set, you may safely enable backface culling.</tt></td>
  656. </tr>
  657. <tr>
  658. <td><tt>SHADING_MODEL</tt></td>
  659. <td>int</td>
  660. <td>gouraud</td>
  661. <td>One of the #aiShadingMode enumerated values. Defines the library shading model to use for (real time) rendering to approximate the original look of the material as closely as possible. </td>
  662. <td>The presence of this key might indicate a more complex material. If absent, assume phong shading only if a specular exponent is given.</tt></td>
  663. </tr>
  664. <tr>
  665. <td><tt>BLEND_FUNC</tt></td>
  666. <td>int</td>
  667. <td>false</td>
  668. <td>One of the #aiBlendMode enumerated values. Defines how the final color value in the screen buffer is computed from the given color at that position and the newly computed color from the material. Simply said, alpha blending settings.</td>
  669. <td>-</td>
  670. </tr>
  671. <tr>
  672. <td><tt>OPACITY</tt></td>
  673. <td>float</td>
  674. <td>1.0</td>
  675. <td>Defines the opacity of the material in a range between 0..1.</td>
  676. <td>Use this value to decide whether you have to activate alpha blending for rendering. <tt>OPACITY</tt> != 1 usually also implies TWOSIDED=1 to avoid cull artifacts.</td>
  677. </tr>
  678. <tr>
  679. <td><tt>SHININESS</tt></td>
  680. <td>float</td>
  681. <td>0.f</td>
  682. <td>Defines the shininess of a phong-shaded material. This is actually the exponent of the phong specular equation</td>
  683. <td><tt>SHININESS</tt>=0 is equivalent to <tt>SHADING_MODEL</tt>=<tt>aiShadingMode_Gouraud</tt>.</td>
  684. </tr>
  685. <tr>
  686. <td><tt>SHININESS_STRENGTH</tt></td>
  687. <td>float</td>
  688. <td>1.0</td>
  689. <td>Scales the specular color of the material.</td>
  690. <td>This value is kept separate from the specular color by most modelers, and so do we.</td>
  691. </tr>
  692. <tr>
  693. <td><tt>REFRACTI</tt></td>
  694. <td>float</td>
  695. <td>1.0</td>
  696. <td>Defines the Index Of Refraction for the material. That's not supported by most file formats.</td>
  697. <td>Might be of interest for raytracing.</td>
  698. </tr>
  699. <tr>
  700. <td><tt>TEXTURE(t,n)</tt></td>
  701. <td>aiString</td>
  702. <td>n/a</td>
  703. <td>Defines the path of the n'th texture on the stack 't', where 'n' is any value >= 0 and 't'
  704. is one of the #aiTextureType enumerated values. A file path to an external file or an embedded
  705. texture. Use aiScene::GetEmbeddedTexture to test if it is embedded for FBX files, in other cases
  706. embedded textures start with '*' followed by an index into aiScene::mTextures.</td>
  707. <td>See the @ref mat_tex section above. Also see @ref textures for a more information about texture retrieval.</td>
  708. </tr>
  709. <tr>
  710. <td><tt>TEXBLEND(t,n)</tt></td>
  711. <td>float</td>
  712. <td>n/a</td>
  713. <td>Defines the strength the n'th texture on the stack 't'. All color components (rgb) are multiplied with this factor *before* any further processing is done.</td>
  714. <td>-</td>
  715. </tr>
  716. <tr>
  717. <td><tt>TEXOP(t,n)</tt></td>
  718. <td>int</td>
  719. <td>n/a</td>
  720. <td>One of the #aiTextureOp enumerated values. Defines the arithmetic operation to be used to combine the n'th texture on the stack 't' with the n-1'th. <tt>TEXOP(t,0)</tt> refers to the blend operation between the base color for this stack (e.g. <tt>COLOR_DIFFUSE</tt> for the diffuse stack) and the first texture.</td>
  721. <td>-</td>
  722. </tr>
  723. <tr>
  724. <td><tt>MAPPING(t,n)</tt></td>
  725. <td>int</td>
  726. <td>n/a</td>
  727. <td>Defines how the input mapping coordinates for sampling the n'th texture on the stack 't' are computed. Usually explicit UV coordinates are provided, but some model file formats might also be using basic shapes, such as spheres or cylinders, to project textures onto meshes.</td>
  728. <td>See the 'Textures' section below. #aiProcess_GenUVCoords can be used to let Assimp compute proper UV coordinates from projective mappings.</td>
  729. </tr>
  730. <tr>
  731. <td><tt>UVWSRC(t,n)</tt></td>
  732. <td>int</td>
  733. <td>n/a</td>
  734. <td>Defines the UV channel to be used as input mapping coordinates for sampling the n'th texture on the stack 't'. All meshes assigned to this material share the same UV channel setup</td>
  735. <td>Presence of this key implies <tt>MAPPING(t,n)</tt> to be #aiTextureMapping_UV. See @ref uvwsrc for more details. </td>
  736. </tr>
  737. <tr>
  738. <td><tt>MAPPINGMODE_U(t,n)</tt></td>
  739. <td>int</td>
  740. <td>n/a</td>
  741. <td>Any of the #aiTextureMapMode enumerated values. Defines the texture wrapping mode on the x axis for sampling the n'th texture on the stack 't'. 'Wrapping' occurs whenever UVs lie outside the 0..1 range. </td>
  742. <td>-</td>
  743. </tr>
  744. <tr>
  745. <td><tt>MAPPINGMODE_V(t,n)</tt></td>
  746. <td>int</td>
  747. <td>n/a</td>
  748. <td>Wrap mode on the v axis. See <tt>MAPPINGMODE_U</tt>. </td>
  749. <td>-</td>
  750. </tr>
  751. <tr>
  752. <td><tt>TEXMAP_AXIS(t,n)</tt></td>
  753. <td>aiVector3D</td>
  754. <td>n/a</td>
  755. <td></tt> Defines the base axis to to compute the mapping coordinates for the n'th texture on the stack 't' from. This is not required for UV-mapped textures. For instance, if <tt>MAPPING(t,n)</tt> is #aiTextureMapping_SPHERE, U and V would map to longitude and latitude of a sphere around the given axis. The axis is given in local mesh space.</td>
  756. <td>-</td>
  757. </tr>
  758. <tr>
  759. <td><tt>TEXFLAGS(t,n)</tt></td>
  760. <td>int</td>
  761. <td>n/a</td>
  762. <td></tt> Defines miscellaneous flag for the n'th texture on the stack 't'. This is a bitwise combination of the #aiTextureFlags enumerated values.</td>
  763. <td>-</td>
  764. </tr>
  765. </table>
  766. @section cpp C++-API
  767. Retrieving a property from a material is done using various utility functions. For C++ it's simply calling aiMaterial::Get()
  768. @code
  769. aiMaterial* mat = .....
  770. // The generic way
  771. if(AI_SUCCESS != mat->Get(<material-key>,<where-to-store>)) {
  772. // handle epic failure here
  773. }
  774. @endcode
  775. Simple, isn't it? To get the name of a material you would use
  776. @code
  777. aiString name;
  778. mat->Get(AI_MATKEY_NAME,name);
  779. @endcode
  780. Or for the diffuse color ('color' won't be modified if the property is not set)
  781. @code
  782. aiColor3D color (0.f,0.f,0.f);
  783. mat->Get(AI_MATKEY_COLOR_DIFFUSE,color);
  784. @endcode
  785. <b>Note:</b> Get() is actually a template with explicit specializations for aiColor3D, aiColor4D, aiString, float, int and some others.
  786. Make sure that the type of the second parameter matches the expected data type of the material property (no compile-time check yet!).
  787. Don't follow this advice if you wish to encounter very strange results.
  788. @section C C-API
  789. For good old C it's slightly different. Take a look at the aiGetMaterialGet<data-type> functions.
  790. @code
  791. aiMaterial* mat = .....
  792. if(AI_SUCCESS != aiGetMaterialFloat(mat,<material-key>,<where-to-store>)) {
  793. // handle epic failure here
  794. }
  795. @endcode
  796. To get the name of a material you would use
  797. @code
  798. aiString name;
  799. aiGetMaterialString(mat,AI_MATKEY_NAME,&name);
  800. @endcode
  801. Or for the diffuse color ('color' won't be modified if the property is not set)
  802. @code
  803. aiColor3D color (0.f,0.f,0.f);
  804. aiGetMaterialColor(mat,AI_MATKEY_COLOR_DIFFUSE,&color);
  805. @endcode
  806. @section uvwsrc How to map UV channels to textures (MATKEY_UVWSRC)
  807. The MATKEY_UVWSRC property is only present if the source format doesn't specify an explicit mapping from
  808. textures to UV channels. Many formats don't do this and assimp is not aware of a perfect rule either.
  809. Your handling of UV channels needs to be flexible therefore. Our recommendation is to use logic like this
  810. to handle most cases properly:
  811. @verbatim
  812. have only one uv channel?
  813. assign channel 0 to all textures and break
  814. for all textures
  815. have uvwsrc for this texture?
  816. assign channel specified in uvwsrc
  817. else
  818. assign channels in ascending order for all texture stacks,
  819. i.e. diffuse1 gets channel 1, opacity0 gets channel 0.
  820. @endverbatim
  821. @section pseudo Pseudo Code Listing
  822. For completeness, the following is a very rough pseudo-code sample showing how to evaluate Assimp materials in your
  823. shading pipeline. You'll probably want to limit your handling of all those material keys to a reasonable subset suitable for your purposes
  824. (for example most 3d engines won't support highly complex multi-layer materials, but many 3d modellers do).
  825. Also note that this sample is targeted at a (shader-based) rendering pipeline for real time graphics.
  826. @code
  827. // ---------------------------------------------------------------------------------------
  828. // Evaluate multiple textures stacked on top of each other
  829. float3 EvaluateStack(stack)
  830. {
  831. // For the 'diffuse' stack stack.base_color would be COLOR_DIFFUSE
  832. // and TEXTURE(aiTextureType_DIFFUSE,n) the n'th texture.
  833. float3 base = stack.base_color;
  834. for (every texture in stack)
  835. {
  836. // assuming we have explicit & pretransformed UVs for this texture
  837. float3 color = SampleTexture(texture,uv);
  838. // scale by texture blend factor
  839. color *= texture.blend;
  840. if (texture.op == add)
  841. base += color;
  842. else if (texture.op == multiply)
  843. base *= color;
  844. else // other blend ops go here
  845. }
  846. return base;
  847. }
  848. // ---------------------------------------------------------------------------------------
  849. // Compute the diffuse contribution for a pixel
  850. float3 ComputeDiffuseContribution()
  851. {
  852. if (shading == none)
  853. return float3(1,1,1);
  854. float3 intensity (0,0,0);
  855. for (all lights in range)
  856. {
  857. float fac = 1.f;
  858. if (shading == gouraud)
  859. fac = lambert-term ..
  860. else // other shading modes go here
  861. // handling of different types of lights, such as point or spot lights
  862. // ...
  863. // and finally sum the contribution of this single light ...
  864. intensity += light.diffuse_color * fac;
  865. }
  866. // ... and combine the final incoming light with the diffuse color
  867. return EvaluateStack(diffuse) * intensity;
  868. }
  869. // ---------------------------------------------------------------------------------------
  870. // Compute the specular contribution for a pixel
  871. float3 ComputeSpecularContribution()
  872. {
  873. if (shading == gouraud || specular_strength == 0 || specular_exponent == 0)
  874. return float3(0,0,0);
  875. float3 intensity (0,0,0);
  876. for (all lights in range)
  877. {
  878. float fac = 1.f;
  879. if (shading == phong)
  880. fac = phong-term ..
  881. else // other specular shading modes go here
  882. // handling of different types of lights, such as point or spot lights
  883. // ...
  884. // and finally sum the specular contribution of this single light ...
  885. intensity += light.specular_color * fac;
  886. }
  887. // ... and combine the final specular light with the specular color
  888. return EvaluateStack(specular) * intensity * specular_strength;
  889. }
  890. // ---------------------------------------------------------------------------------------
  891. // Compute the ambient contribution for a pixel
  892. float3 ComputeAmbientContribution()
  893. {
  894. if (shading == none)
  895. return float3(0,0,0);
  896. float3 intensity (0,0,0);
  897. for (all lights in range)
  898. {
  899. float fac = 1.f;
  900. // handling of different types of lights, such as point or spot lights
  901. // ...
  902. // and finally sum the ambient contribution of this single light ...
  903. intensity += light.ambient_color * fac;
  904. }
  905. // ... and combine the final ambient light with the ambient color
  906. return EvaluateStack(ambient) * intensity;
  907. }
  908. // ---------------------------------------------------------------------------------------
  909. // Compute the final color value for a pixel
  910. // @param prev Previous color at that position in the framebuffer
  911. float4 PimpMyPixel (float4 prev)
  912. {
  913. // .. handle displacement mapping per vertex
  914. // .. handle bump/normal mapping
  915. // Get all single light contribution terms
  916. float3 diff = ComputeDiffuseContribution();
  917. float3 spec = ComputeSpecularContribution();
  918. float3 ambi = ComputeAmbientContribution();
  919. // .. and compute the final color value for this pixel
  920. float3 color = diff + spec + ambi;
  921. float3 opac = EvaluateStack(opacity);
  922. // note the *slightly* strange meaning of additive and multiplicative blending here ...
  923. // those names will most likely be changed in future versions
  924. if (blend_func == add)
  925. return prev+color*opac;
  926. else if (blend_func == multiply)
  927. return prev*(1.0-opac)+prev*opac;
  928. return color;
  929. }
  930. @endcode
  931. @section shdacc How to access shader-code from a texture (AI_MATKEY_GLOBAL_SHADERLANG and AI_MATKEY_SHADER_VERTEX, ...)
  932. You can get assigned shader sources by using the following material keys:
  933. <li>AI_MATKEY_GLOBAL_SHADERLANG</li>To get the used shader language.
  934. <li>AI_MATKEY_SHADER_VERTEX</li> Assigned vertex shader code stored as a string.
  935. <li>AI_MATKEY_SHADER_FRAGMENT</li> Assigned fragment shader code stored as a string.
  936. <li>AI_MATKEY_SHADER_GEO</li> Assigned geometry shader code stored as a string.
  937. <li>AI_MATKEY_SHADER_TESSELATION</li> Assigned tesselation shader code stored as a string.
  938. <li>AI_MATKEY_SHADER_PRIMITIVE</li> Assigned primitive shader code stored as a string.
  939. <li>AI_MATKEY_SHADER_COMPUTE</li> Assigned compute shader code stored as a string.
  940. */
  941. /**
  942. @page perf Performance
  943. @section perf_overview Overview
  944. This page discusses general performance issues related to assimp.
  945. @section perf_profile Profiling
  946. assimp has built-in support for <i>very</i> basic profiling and time measurement. To turn it on, set the <tt>GLOB_MEASURE_TIME</tt>
  947. configuration switch to <tt>true</tt> (nonzero). Results are dumped to the log file, so you need to setup
  948. an appropriate logger implementation with at least one output stream first (see the @link logging Logging Page @endlink
  949. for the details.).
  950. Note that these measurements are based on a single run of the importer and each of the post processing steps, so
  951. a single result set is far away from being significant in a statistic sense. While precision can be improved
  952. by running the test multiple times, the low accuracy of the timings may render the results useless
  953. for smaller files.
  954. A sample report looks like this (some unrelated log messages omitted, entries grouped for clarity):
  955. @verbatim
  956. Debug, T5488: START `total`
  957. Info, T5488: Found a matching importer for this file format
  958. Debug, T5488: START `import`
  959. Info, T5488: BlendModifier: Applied the `Subdivision` modifier to `OBMonkey`
  960. Debug, T5488: END `import`, dt= 3.516 s
  961. Debug, T5488: START `preprocess`
  962. Debug, T5488: END `preprocess`, dt= 0.001 s
  963. Info, T5488: Entering post processing pipeline
  964. Debug, T5488: START `postprocess`
  965. Debug, T5488: RemoveRedundantMatsProcess begin
  966. Debug, T5488: RemoveRedundantMatsProcess finished
  967. Debug, T5488: END `postprocess`, dt= 0.001 s
  968. Debug, T5488: START `postprocess`
  969. Debug, T5488: TriangulateProcess begin
  970. Info, T5488: TriangulateProcess finished. All polygons have been triangulated.
  971. Debug, T5488: END `postprocess`, dt= 3.415 s
  972. Debug, T5488: START `postprocess`
  973. Debug, T5488: SortByPTypeProcess begin
  974. Info, T5488: Points: 0, Lines: 0, Triangles: 1, Polygons: 0 (Meshes, X = removed)
  975. Debug, T5488: SortByPTypeProcess finished
  976. Debug, T5488: START `postprocess`
  977. Debug, T5488: JoinVerticesProcess begin
  978. Debug, T5488: Mesh 0 (unnamed) | Verts in: 503808 out: 126345 | ~74.922
  979. Info, T5488: JoinVerticesProcess finished | Verts in: 503808 out: 126345 | ~74.9
  980. Debug, T5488: END `postprocess`, dt= 2.052 s
  981. Debug, T5488: START `postprocess`
  982. Debug, T5488: FlipWindingOrderProcess begin
  983. Debug, T5488: FlipWindingOrderProcess finished
  984. Debug, T5488: END `postprocess`, dt= 0.006 s
  985. Debug, T5488: START `postprocess`
  986. Debug, T5488: LimitBoneWeightsProcess begin
  987. Debug, T5488: LimitBoneWeightsProcess end
  988. Debug, T5488: END `postprocess`, dt= 0.001 s
  989. Debug, T5488: START `postprocess`
  990. Debug, T5488: ImproveCacheLocalityProcess begin
  991. Debug, T5488: Mesh 0 | ACMR in: 0.851622 out: 0.718139 | ~15.7
  992. Info, T5488: Cache relevant are 1 meshes (251904 faces). Average output ACMR is 0.718139
  993. Debug, T5488: ImproveCacheLocalityProcess finished.
  994. Debug, T5488: END `postprocess`, dt= 1.903 s
  995. Info, T5488: Leaving post processing pipeline
  996. Debug, T5488: END `total`, dt= 11.269 s
  997. @endverbatim
  998. In this particular example only one fourth of the total import time was spent on the actual importing, while the rest of the
  999. time got consumed by the #aiProcess_Triangulate, #aiProcess_JoinIdenticalVertices and #aiProcess_ImproveCacheLocality
  1000. postprocessing steps. A wise selection of postprocessing steps is therefore essential to getting good performance.
  1001. Of course this depends on the individual requirements of your application, in many of the typical use cases of assimp performance won't
  1002. matter (i.e. in an offline content pipeline).
  1003. */
  1004. /**
  1005. @page threading Threading
  1006. @section overview Overview
  1007. This page discusses both assimps scalability in threaded environments and the precautions to be taken in order to
  1008. use it from multiple threads concurrently.
  1009. @section threadsafety Thread-safety / using Assimp concurrently from several threads
  1010. The library can be accessed by multiple threads simultaneously, as long as the
  1011. following prerequisites are fulfilled:
  1012. - Users of the C++-API should ensure that they use a dedicated #Assimp::Importer instance for each thread. Constructing instances of #Assimp::Importer is expensive, so it might be a good idea to
  1013. let every thread maintain its own thread-local instance (which can be used to
  1014. load as many files as necessary).
  1015. - The C-API is thread safe.
  1016. - When supplying custom IO logic, one must make sure the underlying implementation is thread-safe.
  1017. - Custom log streams or logger replacements have to be thread-safe, too.
  1018. Multiple concurrent imports may or may not be beneficial, however. For certain file formats in conjunction with
  1019. little or no post processing IO times tend to be the performance bottleneck. Intense post processing together
  1020. with 'slow' file formats like X or Collada might scale well with multiple concurrent imports.
  1021. @section automt Internal threading
  1022. Internal multi-threading is not currently implemented.
  1023. */
  1024. /**
  1025. @page res Resources
  1026. This page lists some useful resources for assimp. Note that, even though the core team has an eye on them,
  1027. we cannot guarantee the accuracy of third-party information. If in doubt, it's best to ask either on the
  1028. mailing list or on our forums on SF.net.
  1029. - assimp comes with some sample applications, these can be found in the <i>./samples</i> folder. Don't forget to read the <i>README</i> file.
  1030. - http://www.drivenbynostalgia.com/files/AssimpOpenGLDemo.rar - OpenGl animation sample using the library's animation import facilities.
  1031. - http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/ is another utility to
  1032. simplify animation playback.
  1033. - http://ogldev.atspace.co.uk/www/tutorial22/tutorial22.html - Tutorial "Loading models using the Open Asset Import Library", out of a series of OpenGl tutorials.
  1034. */
  1035. /**
  1036. @page importer_notes Importer Notes
  1037. <hr>
  1038. @section blender Blender
  1039. This section contains implementation notes for the Blender3D importer.
  1040. @subsection bl_overview Overview
  1041. assimp provides a self-contained reimplementation of Blender's so called SDNA system (http://www.blender.org/development/architecture/notes-on-sdna/).
  1042. SDNA allows Blender to be fully backward and forward compatible and to exchange
  1043. files across all platforms. The BLEND format is thus a non-trivial binary monster and the loader tries to read the most of it,
  1044. naturally limited by the scope of the #aiScene output data structure.
  1045. Consequently, if Blender is the only modeling tool in your asset work flow, consider writing a
  1046. custom exporter from Blender if assimps format coverage does not meet the requirements.
  1047. @subsection bl_status Current status
  1048. The Blender loader does not support animations yet, but is apart from that considered relatively stable.
  1049. @subsection bl_notes Notes
  1050. When filing bugs on the Blender loader, always give the Blender version (or, even better, post the file caused the error).
  1051. <hr>
  1052. @section ifc IFC
  1053. This section contains implementation notes on the IFC-STEP importer.
  1054. @subsection ifc_overview Overview
  1055. The library provides a partial implementation of the IFC2x3 industry standard for automatized exchange of CAE/architectural
  1056. data sets. See http://en.wikipedia.org/wiki/Industry_Foundation_Classes for more information on the format. We aim
  1057. at getting as much 3D data out of the files as possible.
  1058. @subsection ifc_status Current status
  1059. IFC support is new and considered experimental. Please report any bugs you may encounter.
  1060. @subsection ifc_notes Notes
  1061. - Only the STEP-based encoding is supported. IFCZIP and IFCXML are not (but IFCZIP can simply be unzipped to get a STEP file).
  1062. - The importer leaves vertex coordinates untouched, but applies a global scaling to the root transform to
  1063. convert from whichever unit the IFC file uses to <i>metres</i>.
  1064. - If multiple geometric representations are provided, the choice which one to load is based on how expensive a representation seems
  1065. to be in terms of import time. The loader also avoids representation types for which it has known deficits.
  1066. - Not supported are arbitrary binary operations (binary clipping is implemented, though).
  1067. - Of the various relationship types that IFC knows, only aggregation, containment and material assignment are resolved and mapped to
  1068. the output graph.
  1069. - The implementation knows only about IFC2X3 and applies this rule set to all models it encounters,
  1070. regardless of their actual version. Loading of older or newer files may fail with parsing errors.
  1071. @subsection ifc_metadata Metadata
  1072. IFC file properties (IfcPropertySet) are kept as per-node metadata, see aiNode::mMetaData.
  1073. <hr>
  1074. @section ogre Ogre
  1075. *ATTENTION*: The Ogre-Loader is currently under development, many things have changed after this documentation was written, but they are not final enough to rewrite the documentation. So things may have changed by now!
  1076. This section contains implementations notes for the OgreXML importer.
  1077. @subsection overview Overview
  1078. Ogre importer is currently optimized for the Blender Ogre exporter, because that's the only one that I use. You can find the Blender Ogre exporter at: http://www.ogre3d.org/forums/viewtopic.php?f=8&t=45922
  1079. @subsection what What will be loaded?
  1080. Mesh: Faces, Positions, Normals and all TexCoords. The Materialname will be used to load the material.
  1081. Material: The right material in the file will be searched, the importer should work with materials who
  1082. have 1 technique and 1 pass in this technique. From there, the texturename (for 1 color- and 1 normalmap) and the
  1083. materialcolors (but not in custom materials) will be loaded. Also, the materialname will be set.
  1084. Skeleton: Skeleton with Bone hierarchy (Position and Rotation, but no Scaling in the skeleton is supported), names and transformations,
  1085. animations with rotation, translation and scaling keys.
  1086. @subsection export_Blender How to export Files from Blender
  1087. You can find information about how to use the Ogreexporter by your own, so here are just some options that you need, so the assimp
  1088. importer will load everything correctly:
  1089. - Use either "Rendering Material" or "Custom Material" see @ref material
  1090. - do not use "Flip Up Axies to Y"
  1091. - use "Skeleton name follow mesh"
  1092. @subsection xml XML Format
  1093. There is a binary and a XML mesh Format from Ogre. This loader can only
  1094. Handle xml files, but don't panic, there is a command line converter, which you can use
  1095. to create XML files from Binary Files. Just look on the Ogre page for it.
  1096. Currently you can only load meshes. So you will need to import the *.mesh.xml file, the loader will
  1097. try to find the appendant material and skeleton file.
  1098. The skeleton file must have the same name as the mesh file, e.g. fish.mesh.xml and fish.skeleton.xml.
  1099. @subsection material Materials
  1100. The material file can have the same name as the mesh file (if the file is model.mesh or model.mesh.xml the
  1101. loader will try to load model.material),
  1102. or you can use Importer::Importer::SetPropertyString(AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE, "materiafile.material")
  1103. to specify the name of the material file. This is especially useful if multiply materials a stored in a single file.
  1104. The importer will first try to load the material with the same name as the mesh and only if this can't be open try
  1105. to load the alternate material file. The default material filename is "Scene.material".
  1106. We suggest that you use custom materials, because they support multiple textures (like colormap and normalmap). First of all you
  1107. should read the custom material sektion in the Ogre Blender exporter Help File, and than use the assimp.tlp template, which you
  1108. can find in scripts/OgreImpoter/Assimp.tlp in the assimp source. If you don't set all values, don't worry, they will be ignored during import.
  1109. If you want more properties in custom materials, you can easily expand the ogre material loader, it will be just a few lines for each property.
  1110. Just look in OgreImporterMaterial.cpp
  1111. @subsection Importer Properties
  1112. - IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME: Normally, a texture is loaded as a colormap, if no
  1113. target is specified in the
  1114. materialfile. Is this switch is enabled, texture names ending with _n, _l, _s
  1115. are used as normalmaps, lightmaps or specularmaps.
  1116. <br>
  1117. Property type: Bool. Default value: false.
  1118. - IMPORT_OGRE_MATERIAL_FILE: Ogre Meshes contain only the MaterialName, not the MaterialFile.
  1119. If there
  1120. is no material file with the same name as the material, Ogre Importer will
  1121. try to load this file and search the material in it.
  1122. <br>
  1123. Property type: String. Default value: guessed.
  1124. @subsection todo Todo
  1125. - Load colors in custom materials
  1126. - extend custom and normal material loading
  1127. - fix bone hierarchy bug
  1128. - test everything elaboratly
  1129. - check for non existent animation keys (what happens if a one time not all bones have a key?)
  1130. */
  1131. /**
  1132. @page extend Extending the Library
  1133. @section General
  1134. Or - how to write your own loaders. It's easy. You just need to implement the #Assimp::BaseImporter class,
  1135. which defines a few abstract methods, register your loader, test it carefully and provide test models for it.
  1136. OK, that sounds too easy :-). The whole procedure for a new loader merely looks like this:
  1137. <ul>
  1138. <li>Create a header (<tt><i>FormatName</i>Importer.h</tt>) and a unit (<tt><i>FormatName</i>Importer.cpp</tt>) in the <tt>&lt;root&gt;/code/</tt> directory</li>
  1139. <li>Add them to the following workspaces: vc8 and vc9 (the files are in the workspaces directory), CMAKE (code/CMakeLists.txt, create a new
  1140. source group for your importer and put them also to ADD_LIBRARY( assimp SHARED))</li>
  1141. <li>Include <i>AssimpPCH.h</i> - this is the PCH file, and it includes already most Assimp-internal stuff. </li>
  1142. <li>Open Importer.cpp and include your header just below the <i>(include_new_importers_here)</i> line,
  1143. guarded by a #define
  1144. @code
  1145. #if (!defined assimp_BUILD_NO_FormatName_IMPORTER)
  1146. ...
  1147. #endif
  1148. @endcode
  1149. Wrap the same guard around your .cpp!</li>
  1150. <li>Now advance to the <i>(register_new_importers_here)</i> line in the Importer.cpp and register your importer there - just like all the others do.</li>
  1151. <li>Setup a suitable test environment (i.e. use AssimpView or your own application), make sure to enable
  1152. the #aiProcess_ValidateDataStructure flag and enable verbose logging. That is, simply call before you import anything:
  1153. @code
  1154. DefaultLogger::create("AssimpLog.txt",Logger::VERBOSE)
  1155. @endcode
  1156. </li>
  1157. <li>
  1158. Implement the Assimp::BaseImporter::CanRead(), Assimp::BaseImporter::InternReadFile() and Assimp::BaseImporter::GetExtensionList().
  1159. Just copy'n'paste the template from Appendix A and adapt it for your needs.
  1160. </li>
  1161. <li>For error handling, throw a dynamic allocated ImportErrorException (see Appendix A) for critical errors, and log errors, warnings, infos and debuginfos
  1162. with DefaultLogger::get()->[error, warn, debug, info].
  1163. </li>
  1164. <li>
  1165. Make sure that your loader compiles against all build configurations on all supported platforms. You can use our CI-build to check several platforms
  1166. like Windows and Linux ( 32 bit and 64 bit ).
  1167. </li>
  1168. <li>
  1169. Provide some _free_ test models in <tt>&lt;root&gt;/test/models/&lt;FormatName&gt;/</tt> and credit their authors.
  1170. Test files for a file format shouldn't be too large (<i>~500 KiB in total</i>), and not too repetive. Try to cover all format features with test data.
  1171. </li>
  1172. <li>
  1173. Done! Please, share your loader that everyone can profit from it!
  1174. </li>
  1175. </ul>
  1176. @section properties Properties
  1177. You can use properties to chance the behavior of you importer. In order to do so, you have to override BaseImporter::SetupProperties, and specify
  1178. you custom properties in config.h. Just have a look to the other AI_CONFIG_IMPORT_* defines and you will understand, how it works.
  1179. The properties can be set with Importer::SetProperty***() and can be accessed in your SetupProperties function with Importer::GetProperty***(). You can
  1180. store the properties as a member variable of your importer, they are thread safe.
  1181. @section tnote Notes for text importers
  1182. <ul>
  1183. <li>Try to make your parser as flexible as possible. Don't rely on particular layout, whitespace/tab style,
  1184. except if the file format has a strict definition, in which case you should always warn about spec violations.
  1185. But the general rule of thumb is <i>be strict in what you write and tolerant in what you accept</i>.</li>
  1186. <li>Call Assimp::BaseImporter::ConvertToUTF8() before you parse anything to convert foreign encodings to UTF-8.
  1187. That's not necessary for XML importers, which must use the provided IrrXML for reading. </li>
  1188. </ul>
  1189. @section bnote Notes for binary importers
  1190. <ul>
  1191. <li>
  1192. Take care of endianness issues! Assimp importers mostly support big-endian platforms, which define the <tt>AI_BUILD_BIG_ENDIAN</tt> constant.
  1193. See the next section for a list of utilities to simplify this task.
  1194. </li>
  1195. <li>
  1196. Don't trust the input data! Check all offsets!
  1197. </li>
  1198. </ul>
  1199. @section util Utilities
  1200. Mixed stuff for internal use by loaders, mostly documented (most of them are already included by <i>AssimpPCH.h</i>):
  1201. <ul>
  1202. <li><b>ByteSwapper</b> (<i>ByteSwapper.h</i>) - manual byte swapping stuff for binary loaders.</li>
  1203. <li><b>StreamReader</b> (<i>StreamReader.h</i>) - safe, endianess-correct, binary reading.</li>
  1204. <li><b>IrrXML</b> (<i>irrXMLWrapper.h</i>) - for XML-parsing (SAX.</li>
  1205. <li><b>CommentRemover</b> (<i>RemoveComments.h</i>) - remove single-line and multi-line comments from a text file.</li>
  1206. <li>fast_atof, strtoul10, strtoul16, SkipSpaceAndLineEnd, SkipToNextToken .. large family of low-level
  1207. parsing functions, mostly declared in <i>fast_atof.h</i>, <i>StringComparison.h</i> and <i>ParsingUtils.h</i> (a collection that grew
  1208. historically, so don't expect perfect organization). </li>
  1209. <li><b>ComputeNormalsWithSmoothingsGroups()</b> (<i>SmoothingGroups.h</i>) - Computes normal vectors from plain old smoothing groups. </li>
  1210. <li><b>SkeletonMeshBuilder</b> (<i>SkeletonMeshBuilder.h</i>) - generate a dummy mesh from a given (animation) skeleton. </li>
  1211. <li><b>StandardShapes</b> (<i>StandardShapes.h</i>) - generate meshes for standard solids, such as platonic primitives, cylinders or spheres. </li>
  1212. <li><b>BatchLoader</b> (<i>BaseImporter.h</i>) - manage imports from external files. Useful for file formats
  1213. which spread their data across multiple files. </li>
  1214. <li><b>SceneCombiner</b> (<i>SceneCombiner.h</i>) - exhaustive toolset to merge multiple scenes. Useful for file formats
  1215. which spread their data across multiple files. </li>
  1216. </ul>
  1217. @section mat Filling materials
  1218. The required definitions zo set/remove/query keys in #aiMaterial structures are declared in <i>MaterialSystem.h</i>, in a
  1219. #aiMaterial derivate called #aiMaterial. The header is included by AssimpPCH.h, so you don't need to bother.
  1220. @code
  1221. aiMaterial* mat = new aiMaterial();
  1222. const float spec = 16.f;
  1223. mat->AddProperty(&spec, 1, AI_MATKEY_SHININESS);
  1224. //set the name of the material:
  1225. NewMaterial->AddProperty(&aiString(MaterialName.c_str()), AI_MATKEY_NAME);//MaterialName is a std::string
  1226. //set the first diffuse texture
  1227. NewMaterial->AddProperty(&aiString(Texturename.c_str()), AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));//again, Texturename is a std::string
  1228. @endcode
  1229. @section appa Appendix A - Template for BaseImporter's abstract methods
  1230. @code
  1231. // -------------------------------------------------------------------------------
  1232. // Returns whether the class can handle the format of the given file.
  1233. bool xxxxImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
  1234. bool checkSig) const
  1235. {
  1236. const std::string extension = GetExtension(pFile);
  1237. if(extension == "xxxx") {
  1238. return true;
  1239. }
  1240. if (!extension.length() || checkSig) {
  1241. // no extension given, or we're called a second time because no
  1242. // suitable loader was found yet. This means, we're trying to open
  1243. // the file and look for and hints to identify the file format.
  1244. // #Assimp::BaseImporter provides some utilities:
  1245. //
  1246. // #Assimp::BaseImporter::SearchFileHeaderForToken - for text files.
  1247. // It reads the first lines of the file and does a substring check
  1248. // against a given list of 'magic' strings.
  1249. //
  1250. // #Assimp::BaseImporter::CheckMagicToken - for binary files. It goes
  1251. // to a particular offset in the file and and compares the next words
  1252. // against a given list of 'magic' tokens.
  1253. // These checks MUST be done (even if !checkSig) if the file extension
  1254. // is not exclusive to your format. For example, .xml is very common
  1255. // and (co)used by many formats.
  1256. }
  1257. return false;
  1258. }
  1259. // -------------------------------------------------------------------------------
  1260. // Get list of file extensions handled by this loader
  1261. void xxxxImporter::GetExtensionList(std::set<std::string>& extensions)
  1262. {
  1263. extensions.insert("xxx");
  1264. }
  1265. // -------------------------------------------------------------------------------
  1266. void xxxxImporter::InternReadFile( const std::string& pFile,
  1267. aiScene* pScene, IOSystem* pIOHandler)
  1268. {
  1269. std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
  1270. // Check whether we can read from the file
  1271. if( file.get() == NULL) {
  1272. throw DeadlyImportError( "Failed to open xxxx file ", pFile, ".");
  1273. }
  1274. // Your task: fill pScene
  1275. // Throw a ImportErrorException with a meaningful (!) error message if
  1276. // something goes wrong.
  1277. }
  1278. @endcode
  1279. */
  1280. /**
  1281. @page AnimationOverview Animation Overview
  1282. \section Transformations
  1283. This diagram shows how you can calculate your transformationmatrices for an animated character:
  1284. <img src="AnimationOverview.png" />
  1285. **/