Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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