material.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2012, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file material.h
  35. * @brief Defines the material system of the library
  36. */
  37. #ifndef AI_MATERIAL_H_INC
  38. #define AI_MATERIAL_H_INC
  39. #include "types.h"
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. // Name for default materials (2nd is used if meshes have UV coords)
  44. #define AI_DEFAULT_MATERIAL_NAME "DefaultMaterial"
  45. // ---------------------------------------------------------------------------
  46. /** @brief Defines how the Nth texture of a specific type is combined with
  47. * the result of all previous layers.
  48. *
  49. * Example (left: key, right: value): <br>
  50. * @code
  51. * DiffColor0 - gray
  52. * DiffTextureOp0 - aiTextureOpMultiply
  53. * DiffTexture0 - tex1.png
  54. * DiffTextureOp0 - aiTextureOpAdd
  55. * DiffTexture1 - tex2.png
  56. * @endcode
  57. * Written as equation, the final diffuse term for a specific pixel would be:
  58. * @code
  59. * diffFinal = DiffColor0 * sampleTex(DiffTexture0,UV0) +
  60. * sampleTex(DiffTexture1,UV0) * diffContrib;
  61. * @endcode
  62. * where 'diffContrib' is the intensity of the incoming light for that pixel.
  63. */
  64. enum aiTextureOp
  65. {
  66. /** T = T1 * T2 */
  67. aiTextureOp_Multiply = 0x0,
  68. /** T = T1 + T2 */
  69. aiTextureOp_Add = 0x1,
  70. /** T = T1 - T2 */
  71. aiTextureOp_Subtract = 0x2,
  72. /** T = T1 / T2 */
  73. aiTextureOp_Divide = 0x3,
  74. /** T = (T1 + T2) - (T1 * T2) */
  75. aiTextureOp_SmoothAdd = 0x4,
  76. /** T = T1 + (T2-0.5) */
  77. aiTextureOp_SignedAdd = 0x5,
  78. /** @cond never
  79. * This value is not used. It forces the compiler to use at least
  80. * 32 Bit integers to represent this enum.
  81. */
  82. #ifndef SWIG
  83. _aiTextureOp_Force32Bit = 0x9fffffff
  84. #endif
  85. //! @endcond
  86. };
  87. // ---------------------------------------------------------------------------
  88. /** @brief Defines how UV coordinates outside the [0...1] range are handled.
  89. *
  90. * Commonly refered to as 'wrapping mode'.
  91. */
  92. enum aiTextureMapMode
  93. {
  94. /** A texture coordinate u|v is translated to u%1|v%1
  95. */
  96. aiTextureMapMode_Wrap = 0x0,
  97. /** Texture coordinates outside [0...1]
  98. * are clamped to the nearest valid value.
  99. */
  100. aiTextureMapMode_Clamp = 0x1,
  101. /** If the texture coordinates for a pixel are outside [0...1]
  102. * the texture is not applied to that pixel
  103. */
  104. aiTextureMapMode_Decal = 0x3,
  105. /** A texture coordinate u|v becomes u%1|v%1 if (u-(u%1))%2 is zero and
  106. * 1-(u%1)|1-(v%1) otherwise
  107. */
  108. aiTextureMapMode_Mirror = 0x2,
  109. /** @cond never
  110. * This value is not used. It forces the compiler to use at least
  111. * 32 Bit integers to represent this enum.
  112. */
  113. #ifndef SWIG
  114. _aiTextureMapMode_Force32Bit = 0x9fffffff
  115. #endif
  116. //! @endcond
  117. };
  118. // ---------------------------------------------------------------------------
  119. /** @brief Defines how the mapping coords for a texture are generated.
  120. *
  121. * Real-time applications typically require full UV coordinates, so the use of
  122. * the aiProcess_GenUVCoords step is highly recommended. It generates proper
  123. * UV channels for non-UV mapped objects, as long as an accurate description
  124. * how the mapping should look like (e.g spherical) is given.
  125. * See the #AI_MATKEY_MAPPING property for more details.
  126. */
  127. enum aiTextureMapping
  128. {
  129. /** The mapping coordinates are taken from an UV channel.
  130. *
  131. * The #AI_MATKEY_UVWSRC key specifies from which UV channel
  132. * the texture coordinates are to be taken from (remember,
  133. * meshes can have more than one UV channel).
  134. */
  135. aiTextureMapping_UV = 0x0,
  136. /** Spherical mapping */
  137. aiTextureMapping_SPHERE = 0x1,
  138. /** Cylindrical mapping */
  139. aiTextureMapping_CYLINDER = 0x2,
  140. /** Cubic mapping */
  141. aiTextureMapping_BOX = 0x3,
  142. /** Planar mapping */
  143. aiTextureMapping_PLANE = 0x4,
  144. /** Undefined mapping. Have fun. */
  145. aiTextureMapping_OTHER = 0x5,
  146. /** @cond never
  147. * This value is not used. It forces the compiler to use at least
  148. * 32 Bit integers to represent this enum.
  149. */
  150. #ifndef SWIG
  151. _aiTextureMapping_Force32Bit = 0x9fffffff
  152. #endif
  153. //! @endcond
  154. };
  155. // ---------------------------------------------------------------------------
  156. /** @brief Defines the purpose of a texture
  157. *
  158. * This is a very difficult topic. Different 3D packages support different
  159. * kinds of textures. For very common texture types, such as bumpmaps, the
  160. * rendering results depend on implementation details in the rendering
  161. * pipelines of these applications. Assimp loads all texture references from
  162. * the model file and tries to determine which of the predefined texture
  163. * types below is the best choice to match the original use of the texture
  164. * as closely as possible.<br>
  165. *
  166. * In content pipelines you'll usually define how textures have to be handled,
  167. * and the artists working on models have to conform to this specification,
  168. * regardless which 3D tool they're using.
  169. */
  170. enum aiTextureType
  171. {
  172. /** Dummy value.
  173. *
  174. * No texture, but the value to be used as 'texture semantic'
  175. * (#aiMaterialProperty::mSemantic) for all material properties
  176. * *not* related to textures.
  177. */
  178. aiTextureType_NONE = 0x0,
  179. /** The texture is combined with the result of the diffuse
  180. * lighting equation.
  181. */
  182. aiTextureType_DIFFUSE = 0x1,
  183. /** The texture is combined with the result of the specular
  184. * lighting equation.
  185. */
  186. aiTextureType_SPECULAR = 0x2,
  187. /** The texture is combined with the result of the ambient
  188. * lighting equation.
  189. */
  190. aiTextureType_AMBIENT = 0x3,
  191. /** The texture is added to the result of the lighting
  192. * calculation. It isn't influenced by incoming light.
  193. */
  194. aiTextureType_EMISSIVE = 0x4,
  195. /** The texture is a height map.
  196. *
  197. * By convention, higher gray-scale values stand for
  198. * higher elevations from the base height.
  199. */
  200. aiTextureType_HEIGHT = 0x5,
  201. /** The texture is a (tangent space) normal-map.
  202. *
  203. * Again, there are several conventions for tangent-space
  204. * normal maps. Assimp does (intentionally) not
  205. * distinguish here.
  206. */
  207. aiTextureType_NORMALS = 0x6,
  208. /** The texture defines the glossiness of the material.
  209. *
  210. * The glossiness is in fact the exponent of the specular
  211. * (phong) lighting equation. Usually there is a conversion
  212. * function defined to map the linear color values in the
  213. * texture to a suitable exponent. Have fun.
  214. */
  215. aiTextureType_SHININESS = 0x7,
  216. /** The texture defines per-pixel opacity.
  217. *
  218. * Usually 'white' means opaque and 'black' means
  219. * 'transparency'. Or quite the opposite. Have fun.
  220. */
  221. aiTextureType_OPACITY = 0x8,
  222. /** Displacement texture
  223. *
  224. * The exact purpose and format is application-dependent.
  225. * Higher color values stand for higher vertex displacements.
  226. */
  227. aiTextureType_DISPLACEMENT = 0x9,
  228. /** Lightmap texture (aka Ambient Occlusion)
  229. *
  230. * Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
  231. * covered by this material property. The texture contains a
  232. * scaling value for the final color value of a pixel. Its
  233. * intensity is not affected by incoming light.
  234. */
  235. aiTextureType_LIGHTMAP = 0xA,
  236. /** Reflection texture
  237. *
  238. * Contains the color of a perfect mirror reflection.
  239. * Rarely used, almost never for real-time applications.
  240. */
  241. aiTextureType_REFLECTION = 0xB,
  242. /** Unknown texture
  243. *
  244. * A texture reference that does not match any of the definitions
  245. * above is considered to be 'unknown'. It is still imported,
  246. * but is excluded from any further postprocessing.
  247. */
  248. aiTextureType_UNKNOWN = 0xC,
  249. /** @cond never
  250. * This value is not used. It forces the compiler to use at least
  251. * 32 Bit integers to represent this enum.
  252. */
  253. #ifndef SWIG
  254. _aiTextureType_Force32Bit = 0x9fffffff
  255. #endif
  256. //! @endcond
  257. };
  258. #define AI_TEXTURE_TYPE_MAX aiTextureType_UNKNOWN
  259. // ---------------------------------------------------------------------------
  260. /** @brief Defines all shading models supported by the library
  261. *
  262. * The list of shading modes has been taken from Blender.
  263. * See Blender documentation for more information. The API does
  264. * not distinguish between "specular" and "diffuse" shaders (thus the
  265. * specular term for diffuse shading models like Oren-Nayar remains
  266. * undefined). <br>
  267. * Again, this value is just a hint. Assimp tries to select the shader whose
  268. * most common implementation matches the original rendering results of the
  269. * 3D modeller which wrote a particular model as closely as possible.
  270. */
  271. enum aiShadingMode
  272. {
  273. /** Flat shading. Shading is done on per-face base,
  274. * diffuse only. Also known as 'faceted shading'.
  275. */
  276. aiShadingMode_Flat = 0x1,
  277. /** Simple Gouraud shading.
  278. */
  279. aiShadingMode_Gouraud = 0x2,
  280. /** Phong-Shading -
  281. */
  282. aiShadingMode_Phong = 0x3,
  283. /** Phong-Blinn-Shading
  284. */
  285. aiShadingMode_Blinn = 0x4,
  286. /** Toon-Shading per pixel
  287. *
  288. * Also known as 'comic' shader.
  289. */
  290. aiShadingMode_Toon = 0x5,
  291. /** OrenNayar-Shading per pixel
  292. *
  293. * Extension to standard Lambertian shading, taking the
  294. * roughness of the material into account
  295. */
  296. aiShadingMode_OrenNayar = 0x6,
  297. /** Minnaert-Shading per pixel
  298. *
  299. * Extension to standard Lambertian shading, taking the
  300. * "darkness" of the material into account
  301. */
  302. aiShadingMode_Minnaert = 0x7,
  303. /** CookTorrance-Shading per pixel
  304. *
  305. * Special shader for metallic surfaces.
  306. */
  307. aiShadingMode_CookTorrance = 0x8,
  308. /** No shading at all. Constant light influence of 1.0.
  309. */
  310. aiShadingMode_NoShading = 0x9,
  311. /** Fresnel shading
  312. */
  313. aiShadingMode_Fresnel = 0xa,
  314. /** @cond never
  315. * This value is not used. It forces the compiler to use at least
  316. * 32 Bit integers to represent this enum.
  317. */
  318. #ifndef SWIG
  319. _aiShadingMode_Force32Bit = 0x9fffffff
  320. #endif
  321. //! @endcond
  322. };
  323. // ---------------------------------------------------------------------------
  324. /** @brief Defines some mixed flags for a particular texture.
  325. *
  326. * Usually you'll instruct your cg artists how textures have to look like ...
  327. * and how they will be processed in your application. However, if you use
  328. * Assimp for completely generic loading purposes you might also need to
  329. * process these flags in order to display as many 'unknown' 3D models as
  330. * possible correctly.
  331. *
  332. * This corresponds to the #AI_MATKEY_TEXFLAGS property.
  333. */
  334. enum aiTextureFlags
  335. {
  336. /** The texture's color values have to be inverted (componentwise 1-n)
  337. */
  338. aiTextureFlags_Invert = 0x1,
  339. /** Explicit request to the application to process the alpha channel
  340. * of the texture.
  341. *
  342. * Mutually exclusive with #aiTextureFlags_IgnoreAlpha. These
  343. * flags are set if the library can say for sure that the alpha
  344. * channel is used/is not used. If the model format does not
  345. * define this, it is left to the application to decide whether
  346. * the texture alpha channel - if any - is evaluated or not.
  347. */
  348. aiTextureFlags_UseAlpha = 0x2,
  349. /** Explicit request to the application to ignore the alpha channel
  350. * of the texture.
  351. *
  352. * Mutually exclusive with #aiTextureFlags_UseAlpha.
  353. */
  354. aiTextureFlags_IgnoreAlpha = 0x4,
  355. /** @cond never
  356. * This value is not used. It forces the compiler to use at least
  357. * 32 Bit integers to represent this enum.
  358. */
  359. #ifndef SWIG
  360. _aiTextureFlags_Force32Bit = 0x9fffffff
  361. #endif
  362. //! @endcond
  363. };
  364. // ---------------------------------------------------------------------------
  365. /** @brief Defines alpha-blend flags.
  366. *
  367. * If you're familiar with OpenGL or D3D, these flags aren't new to you.
  368. * They define *how* the final color value of a pixel is computed, basing
  369. * on the previous color at that pixel and the new color value from the
  370. * material.
  371. * The blend formula is:
  372. * @code
  373. * SourceColor * SourceBlend + DestColor * DestBlend
  374. * @endcode
  375. * where <DestColor> is the previous color in the framebuffer at this
  376. * position and <SourceColor> is the material colro before the transparency
  377. * calculation.<br>
  378. * This corresponds to the #AI_MATKEY_BLEND_FUNC property.
  379. */
  380. enum aiBlendMode
  381. {
  382. /**
  383. * Formula:
  384. * @code
  385. * SourceColor*SourceAlpha + DestColor*(1-SourceAlpha)
  386. * @endcode
  387. */
  388. aiBlendMode_Default = 0x0,
  389. /** Additive blending
  390. *
  391. * Formula:
  392. * @code
  393. * SourceColor*1 + DestColor*1
  394. * @endcode
  395. */
  396. aiBlendMode_Additive = 0x1,
  397. // we don't need more for the moment, but we might need them
  398. // in future versions ...
  399. /** @cond never
  400. * This value is not used. It forces the compiler to use at least
  401. * 32 Bit integers to represent this enum.
  402. */
  403. #ifndef SWIG
  404. _aiBlendMode_Force32Bit = 0x9fffffff
  405. #endif
  406. //! @endcond
  407. };
  408. #include "./Compiler/pushpack1.h"
  409. // ---------------------------------------------------------------------------
  410. /** @brief Defines how an UV channel is transformed.
  411. *
  412. * This is just a helper structure for the #AI_MATKEY_UVTRANSFORM key.
  413. * See its documentation for more details.
  414. *
  415. * Typically you'll want to build a matrix of this information. However,
  416. * we keep separate scaling/translation/rotation values to make it
  417. * easier to process and optimize UV transformations internally.
  418. */
  419. struct aiUVTransform
  420. {
  421. /** Translation on the u and v axes.
  422. *
  423. * The default value is (0|0).
  424. */
  425. C_STRUCT aiVector2D mTranslation;
  426. /** Scaling on the u and v axes.
  427. *
  428. * The default value is (1|1).
  429. */
  430. C_STRUCT aiVector2D mScaling;
  431. /** Rotation - in counter-clockwise direction.
  432. *
  433. * The rotation angle is specified in radians. The
  434. * rotation center is 0.5f|0.5f. The default value
  435. * 0.f.
  436. */
  437. float mRotation;
  438. #ifdef __cplusplus
  439. aiUVTransform()
  440. : mScaling (1.f,1.f)
  441. , mRotation (0.f)
  442. {
  443. // nothing to be done here ...
  444. }
  445. #endif
  446. } PACK_STRUCT;
  447. #include "./Compiler/poppack1.h"
  448. //! @cond AI_DOX_INCLUDE_INTERNAL
  449. // ---------------------------------------------------------------------------
  450. /** @brief A very primitive RTTI system for the contents of material
  451. * properties.
  452. */
  453. enum aiPropertyTypeInfo
  454. {
  455. /** Array of single-precision (32 Bit) floats
  456. *
  457. * It is possible to use aiGetMaterialInteger[Array]() (or the C++-API
  458. * aiMaterial::Get()) to query properties stored in floating-point format.
  459. * The material system performs the type conversion automatically.
  460. */
  461. aiPTI_Float = 0x1,
  462. /** The material property is an aiString.
  463. *
  464. * Arrays of strings aren't possible, aiGetMaterialString() (or the
  465. * C++-API aiMaterial::Get()) *must* be used to query a string property.
  466. */
  467. aiPTI_String = 0x3,
  468. /** Array of (32 Bit) integers
  469. *
  470. * It is possible to use aiGetMaterialFloat[Array]() (or the C++-API
  471. * aiMaterial::Get()) to query properties stored in integer format.
  472. * The material system performs the type conversion automatically.
  473. */
  474. aiPTI_Integer = 0x4,
  475. /** Simple binary buffer, content undefined. Not convertible to anything.
  476. */
  477. aiPTI_Buffer = 0x5,
  478. /** This value is not used. It is just there to force the
  479. * compiler to map this enum to a 32 Bit integer.
  480. */
  481. #ifndef SWIG
  482. _aiPTI_Force32Bit = 0x9fffffff
  483. #endif
  484. };
  485. // ---------------------------------------------------------------------------
  486. /** @brief Data structure for a single material property
  487. *
  488. * As an user, you'll probably never need to deal with this data structure.
  489. * Just use the provided aiGetMaterialXXX() or aiMaterial::Get() family
  490. * of functions to query material properties easily. Processing them
  491. * manually is faster, but it is not the recommended way. It isn't worth
  492. * the effort. <br>
  493. * Material property names follow a simple scheme:
  494. * @code
  495. * $<name>
  496. * ?<name>
  497. * A public property, there must be corresponding AI_MATKEY_XXX define
  498. * 2nd: Public, but ignored by the #aiProcess_RemoveRedundantMaterials
  499. * post-processing step.
  500. * ~<name>
  501. * A temporary property for internal use.
  502. * @endcode
  503. * @see aiMaterial
  504. */
  505. struct aiMaterialProperty
  506. {
  507. /** Specifies the name of the property (key)
  508. * Keys are generally case insensitive.
  509. */
  510. C_STRUCT aiString mKey;
  511. /** Textures: Specifies their exact usage semantic.
  512. * For non-texture properties, this member is always 0
  513. * (or, better-said, #aiTextureType_NONE).
  514. */
  515. unsigned int mSemantic;
  516. /** Textures: Specifies the index of the texture.
  517. * For non-texture properties, this member is always 0.
  518. */
  519. unsigned int mIndex;
  520. /** Size of the buffer mData is pointing to, in bytes.
  521. * This value may not be 0.
  522. */
  523. unsigned int mDataLength;
  524. /** Type information for the property.
  525. *
  526. * Defines the data layout inside the data buffer. This is used
  527. * by the library internally to perform debug checks and to
  528. * utilize proper type conversions.
  529. * (It's probably a hacky solution, but it works.)
  530. */
  531. C_ENUM aiPropertyTypeInfo mType;
  532. /** Binary buffer to hold the property's value.
  533. * The size of the buffer is always mDataLength.
  534. */
  535. char* mData;
  536. #ifdef __cplusplus
  537. aiMaterialProperty() {
  538. mData = NULL;
  539. mIndex = mSemantic = 0;
  540. }
  541. ~aiMaterialProperty() {
  542. delete[] mData;
  543. }
  544. #endif
  545. };
  546. //! @endcond
  547. #ifdef __cplusplus
  548. } // We need to leave the "C" block here to allow template member functions
  549. #endif
  550. // ---------------------------------------------------------------------------
  551. /** @brief Data structure for a material
  552. *
  553. * Material data is stored using a key-value structure. A single key-value
  554. * pair is called a 'material property'. C++ users should use the provided
  555. * member functions of aiMaterial to process material properties, C users
  556. * have to stick with the aiMaterialGetXXX family of unbound functions.
  557. * The library defines a set of standard keys (AI_MATKEY_XXX).
  558. */
  559. struct ASSIMP_API aiMaterial
  560. {
  561. #ifdef __cplusplus
  562. public:
  563. aiMaterial();
  564. ~aiMaterial();
  565. // -------------------------------------------------------------------
  566. /** @brief Retrieve an array of Type values with a specific key
  567. * from the material
  568. *
  569. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  570. * @param type .. set by AI_MATKEY_XXX
  571. * @param idx .. set by AI_MATKEY_XXX
  572. * @param pOut Pointer to a buffer to receive the result.
  573. * @param pMax Specifies the size of the given buffer, in Type's.
  574. * Receives the number of values (not bytes!) read.
  575. * NULL is a valid value for this parameter.
  576. */
  577. template <typename Type>
  578. aiReturn Get(const char* pKey,unsigned int type,
  579. unsigned int idx, Type* pOut, unsigned int* pMax) const;
  580. // -------------------------------------------------------------------
  581. /** @brief Retrieve a Type value with a specific key
  582. * from the material
  583. *
  584. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  585. * @param type Specifies the type of the texture to be retrieved (
  586. * e.g. diffuse, specular, height map ...)
  587. * @param idx Index of the texture to be retrieved.
  588. * @param pOut Reference to receive the output value
  589. */
  590. template <typename Type>
  591. aiReturn Get(const char* pKey,unsigned int type,
  592. unsigned int idx,Type& pOut) const;
  593. // -------------------------------------------------------------------
  594. /** Get the number of textures for a particular texture type.
  595. * @param type Texture type to check for
  596. * @return Number of textures for this type.
  597. * @note A texture can be easily queried using #GetTexture() */
  598. unsigned int GetTextureCount(aiTextureType type) const;
  599. // -------------------------------------------------------------------
  600. /** Helper function to get all parameters pertaining to a
  601. * particular texture slot from a material.
  602. *
  603. * This function is provided just for convenience, you could also
  604. * read the single material properties manually.
  605. * @param type Specifies the type of the texture to be retrieved (
  606. * e.g. diffuse, specular, height map ...)
  607. * @param index Index of the texture to be retrieved. The function fails
  608. * if there is no texture of that type with this index.
  609. * #GetTextureCount() can be used to determine the number of textures
  610. * per texture type.
  611. * @param path Receives the path to the texture.
  612. * NULL is a valid value.
  613. * @param mapping The texture mapping.
  614. * NULL is allowed as value.
  615. * @param uvindex Receives the UV index of the texture.
  616. * NULL is a valid value.
  617. * @param blend Receives the blend factor for the texture
  618. * NULL is a valid value.
  619. * @param op Receives the texture operation to be performed between
  620. * this texture and the previous texture. NULL is allowed as value.
  621. * @param mapmode Receives the mapping modes to be used for the texture.
  622. * The parameter may be NULL but if it is a valid pointer it MUST
  623. * point to an array of 3 aiTextureMapMode's (one for each
  624. * axis: UVW order (=XYZ)).
  625. */
  626. // -------------------------------------------------------------------
  627. aiReturn GetTexture(aiTextureType type,
  628. unsigned int index,
  629. C_STRUCT aiString* path,
  630. aiTextureMapping* mapping = NULL,
  631. unsigned int* uvindex = NULL,
  632. float* blend = NULL,
  633. aiTextureOp* op = NULL,
  634. aiTextureMapMode* mapmode = NULL) const;
  635. // Setters
  636. // ------------------------------------------------------------------------------
  637. /** @brief Add a property with a given key and type info to the material
  638. * structure
  639. *
  640. * @param pInput Pointer to input data
  641. * @param pSizeInBytes Size of input data
  642. * @param pKey Key/Usage of the property (AI_MATKEY_XXX)
  643. * @param type Set by the AI_MATKEY_XXX macro
  644. * @param index Set by the AI_MATKEY_XXX macro
  645. * @param pType Type information hint */
  646. aiReturn AddBinaryProperty (const void* pInput,
  647. unsigned int pSizeInBytes,
  648. const char* pKey,
  649. unsigned int type ,
  650. unsigned int index ,
  651. aiPropertyTypeInfo pType);
  652. // ------------------------------------------------------------------------------
  653. /** @brief Add a string property with a given key and type info to the
  654. * material structure
  655. *
  656. * @param pInput Input string
  657. * @param pKey Key/Usage of the property (AI_MATKEY_XXX)
  658. * @param type Set by the AI_MATKEY_XXX macro
  659. * @param index Set by the AI_MATKEY_XXX macro */
  660. aiReturn AddProperty (const aiString* pInput,
  661. const char* pKey,
  662. unsigned int type = 0,
  663. unsigned int index = 0);
  664. // ------------------------------------------------------------------------------
  665. /** @brief Add a property with a given key to the material structure
  666. * @param pInput Pointer to the input data
  667. * @param pNumValues Number of values in the array
  668. * @param pKey Key/Usage of the property (AI_MATKEY_XXX)
  669. * @param type Set by the AI_MATKEY_XXX macro
  670. * @param index Set by the AI_MATKEY_XXX macro */
  671. template<class TYPE>
  672. aiReturn AddProperty (const TYPE* pInput,
  673. unsigned int pNumValues,
  674. const char* pKey,
  675. unsigned int type = 0,
  676. unsigned int index = 0);
  677. // ------------------------------------------------------------------------------
  678. /** @brief Remove a given key from the list.
  679. *
  680. * The function fails if the key isn't found
  681. * @param pKey Key to be deleted */
  682. aiReturn RemoveProperty (const char* pKey,
  683. unsigned int type = 0,
  684. unsigned int index = 0);
  685. // ------------------------------------------------------------------------------
  686. /** @brief Removes all properties from the material.
  687. *
  688. * The data array remains allocated so adding new properties is quite fast. */
  689. void Clear();
  690. // ------------------------------------------------------------------------------
  691. /** Copy the property list of a material
  692. * @param pcDest Destination material
  693. * @param pcSrc Source material
  694. */
  695. static void CopyPropertyList(aiMaterial* pcDest,
  696. const aiMaterial* pcSrc);
  697. #endif
  698. /** List of all material properties loaded. */
  699. C_STRUCT aiMaterialProperty** mProperties;
  700. /** Number of properties in the data base */
  701. unsigned int mNumProperties;
  702. /** Storage allocated */
  703. unsigned int mNumAllocated;
  704. };
  705. // Go back to extern "C" again
  706. #ifdef __cplusplus
  707. extern "C" {
  708. #endif
  709. // ---------------------------------------------------------------------------
  710. #define AI_MATKEY_NAME "?mat.name",0,0
  711. #define AI_MATKEY_TWOSIDED "$mat.twosided",0,0
  712. #define AI_MATKEY_SHADING_MODEL "$mat.shadingm",0,0
  713. #define AI_MATKEY_ENABLE_WIREFRAME "$mat.wireframe",0,0
  714. #define AI_MATKEY_BLEND_FUNC "$mat.blend",0,0
  715. #define AI_MATKEY_OPACITY "$mat.opacity",0,0
  716. #define AI_MATKEY_BUMPSCALING "$mat.bumpscaling",0,0
  717. #define AI_MATKEY_SHININESS "$mat.shininess",0,0
  718. #define AI_MATKEY_REFLECTIVITY "$mat.reflectivity",0,0
  719. #define AI_MATKEY_SHININESS_STRENGTH "$mat.shinpercent",0,0
  720. #define AI_MATKEY_REFRACTI "$mat.refracti",0,0
  721. #define AI_MATKEY_COLOR_DIFFUSE "$clr.diffuse",0,0
  722. #define AI_MATKEY_COLOR_AMBIENT "$clr.ambient",0,0
  723. #define AI_MATKEY_COLOR_SPECULAR "$clr.specular",0,0
  724. #define AI_MATKEY_COLOR_EMISSIVE "$clr.emissive",0,0
  725. #define AI_MATKEY_COLOR_TRANSPARENT "$clr.transparent",0,0
  726. #define AI_MATKEY_COLOR_REFLECTIVE "$clr.reflective",0,0
  727. #define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "?bg.global",0,0
  728. // ---------------------------------------------------------------------------
  729. // Pure key names for all texture-related properties
  730. //! @cond MATS_DOC_FULL
  731. #define _AI_MATKEY_TEXTURE_BASE "$tex.file"
  732. #define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"
  733. #define _AI_MATKEY_TEXOP_BASE "$tex.op"
  734. #define _AI_MATKEY_MAPPING_BASE "$tex.mapping"
  735. #define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"
  736. #define _AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu"
  737. #define _AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev"
  738. #define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"
  739. #define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"
  740. #define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
  741. //! @endcond
  742. // ---------------------------------------------------------------------------
  743. #define AI_MATKEY_TEXTURE(type, N) _AI_MATKEY_TEXTURE_BASE,type,N
  744. // For backward compatibility and simplicity
  745. //! @cond MATS_DOC_FULL
  746. #define AI_MATKEY_TEXTURE_DIFFUSE(N) \
  747. AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE,N)
  748. #define AI_MATKEY_TEXTURE_SPECULAR(N) \
  749. AI_MATKEY_TEXTURE(aiTextureType_SPECULAR,N)
  750. #define AI_MATKEY_TEXTURE_AMBIENT(N) \
  751. AI_MATKEY_TEXTURE(aiTextureType_AMBIENT,N)
  752. #define AI_MATKEY_TEXTURE_EMISSIVE(N) \
  753. AI_MATKEY_TEXTURE(aiTextureType_EMISSIVE,N)
  754. #define AI_MATKEY_TEXTURE_NORMALS(N) \
  755. AI_MATKEY_TEXTURE(aiTextureType_NORMALS,N)
  756. #define AI_MATKEY_TEXTURE_HEIGHT(N) \
  757. AI_MATKEY_TEXTURE(aiTextureType_HEIGHT,N)
  758. #define AI_MATKEY_TEXTURE_SHININESS(N) \
  759. AI_MATKEY_TEXTURE(aiTextureType_SHININESS,N)
  760. #define AI_MATKEY_TEXTURE_OPACITY(N) \
  761. AI_MATKEY_TEXTURE(aiTextureType_OPACITY,N)
  762. #define AI_MATKEY_TEXTURE_DISPLACEMENT(N) \
  763. AI_MATKEY_TEXTURE(aiTextureType_DISPLACEMENT,N)
  764. #define AI_MATKEY_TEXTURE_LIGHTMAP(N) \
  765. AI_MATKEY_TEXTURE(aiTextureType_LIGHTMAP,N)
  766. #define AI_MATKEY_TEXTURE_REFLECTION(N) \
  767. AI_MATKEY_TEXTURE(aiTextureType_REFLECTION,N)
  768. //! @endcond
  769. // ---------------------------------------------------------------------------
  770. #define AI_MATKEY_UVWSRC(type, N) _AI_MATKEY_UVWSRC_BASE,type,N
  771. // For backward compatibility and simplicity
  772. //! @cond MATS_DOC_FULL
  773. #define AI_MATKEY_UVWSRC_DIFFUSE(N) \
  774. AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE,N)
  775. #define AI_MATKEY_UVWSRC_SPECULAR(N) \
  776. AI_MATKEY_UVWSRC(aiTextureType_SPECULAR,N)
  777. #define AI_MATKEY_UVWSRC_AMBIENT(N) \
  778. AI_MATKEY_UVWSRC(aiTextureType_AMBIENT,N)
  779. #define AI_MATKEY_UVWSRC_EMISSIVE(N) \
  780. AI_MATKEY_UVWSRC(aiTextureType_EMISSIVE,N)
  781. #define AI_MATKEY_UVWSRC_NORMALS(N) \
  782. AI_MATKEY_UVWSRC(aiTextureType_NORMALS,N)
  783. #define AI_MATKEY_UVWSRC_HEIGHT(N) \
  784. AI_MATKEY_UVWSRC(aiTextureType_HEIGHT,N)
  785. #define AI_MATKEY_UVWSRC_SHININESS(N) \
  786. AI_MATKEY_UVWSRC(aiTextureType_SHININESS,N)
  787. #define AI_MATKEY_UVWSRC_OPACITY(N) \
  788. AI_MATKEY_UVWSRC(aiTextureType_OPACITY,N)
  789. #define AI_MATKEY_UVWSRC_DISPLACEMENT(N) \
  790. AI_MATKEY_UVWSRC(aiTextureType_DISPLACEMENT,N)
  791. #define AI_MATKEY_UVWSRC_LIGHTMAP(N) \
  792. AI_MATKEY_UVWSRC(aiTextureType_LIGHTMAP,N)
  793. #define AI_MATKEY_UVWSRC_REFLECTION(N) \
  794. AI_MATKEY_UVWSRC(aiTextureType_REFLECTION,N)
  795. //! @endcond
  796. // ---------------------------------------------------------------------------
  797. #define AI_MATKEY_TEXOP(type, N) _AI_MATKEY_TEXOP_BASE,type,N
  798. // For backward compatibility and simplicity
  799. //! @cond MATS_DOC_FULL
  800. #define AI_MATKEY_TEXOP_DIFFUSE(N) \
  801. AI_MATKEY_TEXOP(aiTextureType_DIFFUSE,N)
  802. #define AI_MATKEY_TEXOP_SPECULAR(N) \
  803. AI_MATKEY_TEXOP(aiTextureType_SPECULAR,N)
  804. #define AI_MATKEY_TEXOP_AMBIENT(N) \
  805. AI_MATKEY_TEXOP(aiTextureType_AMBIENT,N)
  806. #define AI_MATKEY_TEXOP_EMISSIVE(N) \
  807. AI_MATKEY_TEXOP(aiTextureType_EMISSIVE,N)
  808. #define AI_MATKEY_TEXOP_NORMALS(N) \
  809. AI_MATKEY_TEXOP(aiTextureType_NORMALS,N)
  810. #define AI_MATKEY_TEXOP_HEIGHT(N) \
  811. AI_MATKEY_TEXOP(aiTextureType_HEIGHT,N)
  812. #define AI_MATKEY_TEXOP_SHININESS(N) \
  813. AI_MATKEY_TEXOP(aiTextureType_SHININESS,N)
  814. #define AI_MATKEY_TEXOP_OPACITY(N) \
  815. AI_MATKEY_TEXOP(aiTextureType_OPACITY,N)
  816. #define AI_MATKEY_TEXOP_DISPLACEMENT(N) \
  817. AI_MATKEY_TEXOP(aiTextureType_DISPLACEMENT,N)
  818. #define AI_MATKEY_TEXOP_LIGHTMAP(N) \
  819. AI_MATKEY_TEXOP(aiTextureType_LIGHTMAP,N)
  820. #define AI_MATKEY_TEXOP_REFLECTION(N) \
  821. AI_MATKEY_TEXOP(aiTextureType_REFLECTION,N)
  822. //! @endcond
  823. // ---------------------------------------------------------------------------
  824. #define AI_MATKEY_MAPPING(type, N) _AI_MATKEY_MAPPING_BASE,type,N
  825. // For backward compatibility and simplicity
  826. //! @cond MATS_DOC_FULL
  827. #define AI_MATKEY_MAPPING_DIFFUSE(N) \
  828. AI_MATKEY_MAPPING(aiTextureType_DIFFUSE,N)
  829. #define AI_MATKEY_MAPPING_SPECULAR(N) \
  830. AI_MATKEY_MAPPING(aiTextureType_SPECULAR,N)
  831. #define AI_MATKEY_MAPPING_AMBIENT(N) \
  832. AI_MATKEY_MAPPING(aiTextureType_AMBIENT,N)
  833. #define AI_MATKEY_MAPPING_EMISSIVE(N) \
  834. AI_MATKEY_MAPPING(aiTextureType_EMISSIVE,N)
  835. #define AI_MATKEY_MAPPING_NORMALS(N) \
  836. AI_MATKEY_MAPPING(aiTextureType_NORMALS,N)
  837. #define AI_MATKEY_MAPPING_HEIGHT(N) \
  838. AI_MATKEY_MAPPING(aiTextureType_HEIGHT,N)
  839. #define AI_MATKEY_MAPPING_SHININESS(N) \
  840. AI_MATKEY_MAPPING(aiTextureType_SHININESS,N)
  841. #define AI_MATKEY_MAPPING_OPACITY(N) \
  842. AI_MATKEY_MAPPING(aiTextureType_OPACITY,N)
  843. #define AI_MATKEY_MAPPING_DISPLACEMENT(N) \
  844. AI_MATKEY_MAPPING(aiTextureType_DISPLACEMENT,N)
  845. #define AI_MATKEY_MAPPING_LIGHTMAP(N) \
  846. AI_MATKEY_MAPPING(aiTextureType_LIGHTMAP,N)
  847. #define AI_MATKEY_MAPPING_REFLECTION(N) \
  848. AI_MATKEY_MAPPING(aiTextureType_REFLECTION,N)
  849. //! @endcond
  850. // ---------------------------------------------------------------------------
  851. #define AI_MATKEY_TEXBLEND(type, N) _AI_MATKEY_TEXBLEND_BASE,type,N
  852. // For backward compatibility and simplicity
  853. //! @cond MATS_DOC_FULL
  854. #define AI_MATKEY_TEXBLEND_DIFFUSE(N) \
  855. AI_MATKEY_TEXBLEND(aiTextureType_DIFFUSE,N)
  856. #define AI_MATKEY_TEXBLEND_SPECULAR(N) \
  857. AI_MATKEY_TEXBLEND(aiTextureType_SPECULAR,N)
  858. #define AI_MATKEY_TEXBLEND_AMBIENT(N) \
  859. AI_MATKEY_TEXBLEND(aiTextureType_AMBIENT,N)
  860. #define AI_MATKEY_TEXBLEND_EMISSIVE(N) \
  861. AI_MATKEY_TEXBLEND(aiTextureType_EMISSIVE,N)
  862. #define AI_MATKEY_TEXBLEND_NORMALS(N) \
  863. AI_MATKEY_TEXBLEND(aiTextureType_NORMALS,N)
  864. #define AI_MATKEY_TEXBLEND_HEIGHT(N) \
  865. AI_MATKEY_TEXBLEND(aiTextureType_HEIGHT,N)
  866. #define AI_MATKEY_TEXBLEND_SHININESS(N) \
  867. AI_MATKEY_TEXBLEND(aiTextureType_SHININESS,N)
  868. #define AI_MATKEY_TEXBLEND_OPACITY(N) \
  869. AI_MATKEY_TEXBLEND(aiTextureType_OPACITY,N)
  870. #define AI_MATKEY_TEXBLEND_DISPLACEMENT(N) \
  871. AI_MATKEY_TEXBLEND(aiTextureType_DISPLACEMENT,N)
  872. #define AI_MATKEY_TEXBLEND_LIGHTMAP(N) \
  873. AI_MATKEY_TEXBLEND(aiTextureType_LIGHTMAP,N)
  874. #define AI_MATKEY_TEXBLEND_REFLECTION(N) \
  875. AI_MATKEY_TEXBLEND(aiTextureType_REFLECTION,N)
  876. //! @endcond
  877. // ---------------------------------------------------------------------------
  878. #define AI_MATKEY_MAPPINGMODE_U(type, N) _AI_MATKEY_MAPPINGMODE_U_BASE,type,N
  879. // For backward compatibility and simplicity
  880. //! @cond MATS_DOC_FULL
  881. #define AI_MATKEY_MAPPINGMODE_U_DIFFUSE(N) \
  882. AI_MATKEY_MAPPINGMODE_U(aiTextureType_DIFFUSE,N)
  883. #define AI_MATKEY_MAPPINGMODE_U_SPECULAR(N) \
  884. AI_MATKEY_MAPPINGMODE_U(aiTextureType_SPECULAR,N)
  885. #define AI_MATKEY_MAPPINGMODE_U_AMBIENT(N) \
  886. AI_MATKEY_MAPPINGMODE_U(aiTextureType_AMBIENT,N)
  887. #define AI_MATKEY_MAPPINGMODE_U_EMISSIVE(N) \
  888. AI_MATKEY_MAPPINGMODE_U(aiTextureType_EMISSIVE,N)
  889. #define AI_MATKEY_MAPPINGMODE_U_NORMALS(N) \
  890. AI_MATKEY_MAPPINGMODE_U(aiTextureType_NORMALS,N)
  891. #define AI_MATKEY_MAPPINGMODE_U_HEIGHT(N) \
  892. AI_MATKEY_MAPPINGMODE_U(aiTextureType_HEIGHT,N)
  893. #define AI_MATKEY_MAPPINGMODE_U_SHININESS(N) \
  894. AI_MATKEY_MAPPINGMODE_U(aiTextureType_SHININESS,N)
  895. #define AI_MATKEY_MAPPINGMODE_U_OPACITY(N) \
  896. AI_MATKEY_MAPPINGMODE_U(aiTextureType_OPACITY,N)
  897. #define AI_MATKEY_MAPPINGMODE_U_DISPLACEMENT(N) \
  898. AI_MATKEY_MAPPINGMODE_U(aiTextureType_DISPLACEMENT,N)
  899. #define AI_MATKEY_MAPPINGMODE_U_LIGHTMAP(N) \
  900. AI_MATKEY_MAPPINGMODE_U(aiTextureType_LIGHTMAP,N)
  901. #define AI_MATKEY_MAPPINGMODE_U_REFLECTION(N) \
  902. AI_MATKEY_MAPPINGMODE_U(aiTextureType_REFLECTION,N)
  903. //! @endcond
  904. // ---------------------------------------------------------------------------
  905. #define AI_MATKEY_MAPPINGMODE_V(type, N) _AI_MATKEY_MAPPINGMODE_V_BASE,type,N
  906. // For backward compatibility and simplicity
  907. //! @cond MATS_DOC_FULL
  908. #define AI_MATKEY_MAPPINGMODE_V_DIFFUSE(N) \
  909. AI_MATKEY_MAPPINGMODE_V(aiTextureType_DIFFUSE,N)
  910. #define AI_MATKEY_MAPPINGMODE_V_SPECULAR(N) \
  911. AI_MATKEY_MAPPINGMODE_V(aiTextureType_SPECULAR,N)
  912. #define AI_MATKEY_MAPPINGMODE_V_AMBIENT(N) \
  913. AI_MATKEY_MAPPINGMODE_V(aiTextureType_AMBIENT,N)
  914. #define AI_MATKEY_MAPPINGMODE_V_EMISSIVE(N) \
  915. AI_MATKEY_MAPPINGMODE_V(aiTextureType_EMISSIVE,N)
  916. #define AI_MATKEY_MAPPINGMODE_V_NORMALS(N) \
  917. AI_MATKEY_MAPPINGMODE_V(aiTextureType_NORMALS,N)
  918. #define AI_MATKEY_MAPPINGMODE_V_HEIGHT(N) \
  919. AI_MATKEY_MAPPINGMODE_V(aiTextureType_HEIGHT,N)
  920. #define AI_MATKEY_MAPPINGMODE_V_SHININESS(N) \
  921. AI_MATKEY_MAPPINGMODE_V(aiTextureType_SHININESS,N)
  922. #define AI_MATKEY_MAPPINGMODE_V_OPACITY(N) \
  923. AI_MATKEY_MAPPINGMODE_V(aiTextureType_OPACITY,N)
  924. #define AI_MATKEY_MAPPINGMODE_V_DISPLACEMENT(N) \
  925. AI_MATKEY_MAPPINGMODE_V(aiTextureType_DISPLACEMENT,N)
  926. #define AI_MATKEY_MAPPINGMODE_V_LIGHTMAP(N) \
  927. AI_MATKEY_MAPPINGMODE_V(aiTextureType_LIGHTMAP,N)
  928. #define AI_MATKEY_MAPPINGMODE_V_REFLECTION(N) \
  929. AI_MATKEY_MAPPINGMODE_V(aiTextureType_REFLECTION,N)
  930. //! @endcond
  931. // ---------------------------------------------------------------------------
  932. #define AI_MATKEY_TEXMAP_AXIS(type, N) _AI_MATKEY_TEXMAP_AXIS_BASE,type,N
  933. // For backward compatibility and simplicity
  934. //! @cond MATS_DOC_FULL
  935. #define AI_MATKEY_TEXMAP_AXIS_DIFFUSE(N) \
  936. AI_MATKEY_TEXMAP_AXIS(aiTextureType_DIFFUSE,N)
  937. #define AI_MATKEY_TEXMAP_AXIS_SPECULAR(N) \
  938. AI_MATKEY_TEXMAP_AXIS(aiTextureType_SPECULAR,N)
  939. #define AI_MATKEY_TEXMAP_AXIS_AMBIENT(N) \
  940. AI_MATKEY_TEXMAP_AXIS(aiTextureType_AMBIENT,N)
  941. #define AI_MATKEY_TEXMAP_AXIS_EMISSIVE(N) \
  942. AI_MATKEY_TEXMAP_AXIS(aiTextureType_EMISSIVE,N)
  943. #define AI_MATKEY_TEXMAP_AXIS_NORMALS(N) \
  944. AI_MATKEY_TEXMAP_AXIS(aiTextureType_NORMALS,N)
  945. #define AI_MATKEY_TEXMAP_AXIS_HEIGHT(N) \
  946. AI_MATKEY_TEXMAP_AXIS(aiTextureType_HEIGHT,N)
  947. #define AI_MATKEY_TEXMAP_AXIS_SHININESS(N) \
  948. AI_MATKEY_TEXMAP_AXIS(aiTextureType_SHININESS,N)
  949. #define AI_MATKEY_TEXMAP_AXIS_OPACITY(N) \
  950. AI_MATKEY_TEXMAP_AXIS(aiTextureType_OPACITY,N)
  951. #define AI_MATKEY_TEXMAP_AXIS_DISPLACEMENT(N) \
  952. AI_MATKEY_TEXMAP_AXIS(aiTextureType_DISPLACEMENT,N)
  953. #define AI_MATKEY_TEXMAP_AXIS_LIGHTMAP(N) \
  954. AI_MATKEY_TEXMAP_AXIS(aiTextureType_LIGHTMAP,N)
  955. #define AI_MATKEY_TEXMAP_AXIS_REFLECTION(N) \
  956. AI_MATKEY_TEXMAP_AXIS(aiTextureType_REFLECTION,N)
  957. //! @endcond
  958. // ---------------------------------------------------------------------------
  959. #define AI_MATKEY_UVTRANSFORM(type, N) _AI_MATKEY_UVTRANSFORM_BASE,type,N
  960. // For backward compatibility and simplicity
  961. //! @cond MATS_DOC_FULL
  962. #define AI_MATKEY_UVTRANSFORM_DIFFUSE(N) \
  963. AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE,N)
  964. #define AI_MATKEY_UVTRANSFORM_SPECULAR(N) \
  965. AI_MATKEY_UVTRANSFORM(aiTextureType_SPECULAR,N)
  966. #define AI_MATKEY_UVTRANSFORM_AMBIENT(N) \
  967. AI_MATKEY_UVTRANSFORM(aiTextureType_AMBIENT,N)
  968. #define AI_MATKEY_UVTRANSFORM_EMISSIVE(N) \
  969. AI_MATKEY_UVTRANSFORM(aiTextureType_EMISSIVE,N)
  970. #define AI_MATKEY_UVTRANSFORM_NORMALS(N) \
  971. AI_MATKEY_UVTRANSFORM(aiTextureType_NORMALS,N)
  972. #define AI_MATKEY_UVTRANSFORM_HEIGHT(N) \
  973. AI_MATKEY_UVTRANSFORM(aiTextureType_HEIGHT,N)
  974. #define AI_MATKEY_UVTRANSFORM_SHININESS(N) \
  975. AI_MATKEY_UVTRANSFORM(aiTextureType_SHININESS,N)
  976. #define AI_MATKEY_UVTRANSFORM_OPACITY(N) \
  977. AI_MATKEY_UVTRANSFORM(aiTextureType_OPACITY,N)
  978. #define AI_MATKEY_UVTRANSFORM_DISPLACEMENT(N) \
  979. AI_MATKEY_UVTRANSFORM(aiTextureType_DISPLACEMENT,N)
  980. #define AI_MATKEY_UVTRANSFORM_LIGHTMAP(N) \
  981. AI_MATKEY_UVTRANSFORM(aiTextureType_LIGHTMAP,N)
  982. #define AI_MATKEY_UVTRANSFORM_REFLECTION(N) \
  983. AI_MATKEY_UVTRANSFORM(aiTextureType_REFLECTION,N)
  984. #define AI_MATKEY_UVTRANSFORM_UNKNOWN(N) \
  985. AI_MATKEY_UVTRANSFORM(aiTextureType_UNKNOWN,N)
  986. //! @endcond
  987. // ---------------------------------------------------------------------------
  988. #define AI_MATKEY_TEXFLAGS(type, N) _AI_MATKEY_TEXFLAGS_BASE,type,N
  989. // For backward compatibility and simplicity
  990. //! @cond MATS_DOC_FULL
  991. #define AI_MATKEY_TEXFLAGS_DIFFUSE(N) \
  992. AI_MATKEY_TEXFLAGS(aiTextureType_DIFFUSE,N)
  993. #define AI_MATKEY_TEXFLAGS_SPECULAR(N) \
  994. AI_MATKEY_TEXFLAGS(aiTextureType_SPECULAR,N)
  995. #define AI_MATKEY_TEXFLAGS_AMBIENT(N) \
  996. AI_MATKEY_TEXFLAGS(aiTextureType_AMBIENT,N)
  997. #define AI_MATKEY_TEXFLAGS_EMISSIVE(N) \
  998. AI_MATKEY_TEXFLAGS(aiTextureType_EMISSIVE,N)
  999. #define AI_MATKEY_TEXFLAGS_NORMALS(N) \
  1000. AI_MATKEY_TEXFLAGS(aiTextureType_NORMALS,N)
  1001. #define AI_MATKEY_TEXFLAGS_HEIGHT(N) \
  1002. AI_MATKEY_TEXFLAGS(aiTextureType_HEIGHT,N)
  1003. #define AI_MATKEY_TEXFLAGS_SHININESS(N) \
  1004. AI_MATKEY_TEXFLAGS(aiTextureType_SHININESS,N)
  1005. #define AI_MATKEY_TEXFLAGS_OPACITY(N) \
  1006. AI_MATKEY_TEXFLAGS(aiTextureType_OPACITY,N)
  1007. #define AI_MATKEY_TEXFLAGS_DISPLACEMENT(N) \
  1008. AI_MATKEY_TEXFLAGS(aiTextureType_DISPLACEMENT,N)
  1009. #define AI_MATKEY_TEXFLAGS_LIGHTMAP(N) \
  1010. AI_MATKEY_TEXFLAGS(aiTextureType_LIGHTMAP,N)
  1011. #define AI_MATKEY_TEXFLAGS_REFLECTION(N) \
  1012. AI_MATKEY_TEXFLAGS(aiTextureType_REFLECTION,N)
  1013. #define AI_MATKEY_TEXFLAGS_UNKNOWN(N) \
  1014. AI_MATKEY_TEXFLAGS(aiTextureType_UNKNOWN,N)
  1015. // ---------------------------------------------------------------------------
  1016. /** @brief Retrieve a material property with a specific key from the material
  1017. *
  1018. * @param pMat Pointer to the input material. May not be NULL
  1019. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  1020. * @param type Specifies the type of the texture to be retrieved (
  1021. * e.g. diffuse, specular, height map ...)
  1022. * @param index Index of the texture to be retrieved.
  1023. * @param pPropOut Pointer to receive a pointer to a valid aiMaterialProperty
  1024. * structure or NULL if the key has not been found. */
  1025. // ---------------------------------------------------------------------------
  1026. ASSIMP_API C_ENUM aiReturn aiGetMaterialProperty(
  1027. const C_STRUCT aiMaterial* pMat,
  1028. const char* pKey,
  1029. unsigned int type,
  1030. unsigned int index,
  1031. const C_STRUCT aiMaterialProperty** pPropOut);
  1032. // ---------------------------------------------------------------------------
  1033. /** @brief Retrieve an array of float values with a specific key
  1034. * from the material
  1035. *
  1036. * Pass one of the AI_MATKEY_XXX constants for the last three parameters (the
  1037. * example reads the #AI_MATKEY_UVTRANSFORM property of the first diffuse texture)
  1038. * @code
  1039. * aiUVTransform trafo;
  1040. * unsigned int max = sizeof(aiUVTransform);
  1041. * if (AI_SUCCESS != aiGetMaterialFloatArray(mat, AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE,0),
  1042. * (float*)&trafo, &max) || sizeof(aiUVTransform) != max)
  1043. * {
  1044. * // error handling
  1045. * }
  1046. * @endcode
  1047. *
  1048. * @param pMat Pointer to the input material. May not be NULL
  1049. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  1050. * @param pOut Pointer to a buffer to receive the result.
  1051. * @param pMax Specifies the size of the given buffer, in float's.
  1052. * Receives the number of values (not bytes!) read.
  1053. * @param type (see the code sample above)
  1054. * @param index (see the code sample above)
  1055. * @return Specifies whether the key has been found. If not, the output
  1056. * arrays remains unmodified and pMax is set to 0.*/
  1057. // ---------------------------------------------------------------------------
  1058. ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
  1059. const C_STRUCT aiMaterial* pMat,
  1060. const char* pKey,
  1061. unsigned int type,
  1062. unsigned int index,
  1063. float* pOut,
  1064. unsigned int* pMax);
  1065. #ifdef __cplusplus
  1066. // ---------------------------------------------------------------------------
  1067. /** @brief Retrieve a single float property with a specific key from the material.
  1068. *
  1069. * Pass one of the AI_MATKEY_XXX constants for the last three parameters (the
  1070. * example reads the #AI_MATKEY_SHININESS_STRENGTH property of the first diffuse texture)
  1071. * @code
  1072. * float specStrength = 1.f; // default value, remains unmodified if we fail.
  1073. * aiGetMaterialFloat(mat, AI_MATKEY_SHININESS_STRENGTH,
  1074. * (float*)&specStrength);
  1075. * @endcode
  1076. *
  1077. * @param pMat Pointer to the input material. May not be NULL
  1078. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  1079. * @param pOut Receives the output float.
  1080. * @param type (see the code sample above)
  1081. * @param index (see the code sample above)
  1082. * @return Specifies whether the key has been found. If not, the output
  1083. * float remains unmodified.*/
  1084. // ---------------------------------------------------------------------------
  1085. inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat,
  1086. const char* pKey,
  1087. unsigned int type,
  1088. unsigned int index,
  1089. float* pOut)
  1090. {
  1091. return aiGetMaterialFloatArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0);
  1092. }
  1093. #else
  1094. // Use our friend, the C preprocessor
  1095. #define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \
  1096. aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL)
  1097. #endif //!__cplusplus
  1098. // ---------------------------------------------------------------------------
  1099. /** @brief Retrieve an array of integer values with a specific key
  1100. * from a material
  1101. *
  1102. * See the sample for aiGetMaterialFloatArray for more information.*/
  1103. ASSIMP_API C_ENUM aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial* pMat,
  1104. const char* pKey,
  1105. unsigned int type,
  1106. unsigned int index,
  1107. int* pOut,
  1108. unsigned int* pMax);
  1109. #ifdef __cplusplus
  1110. // ---------------------------------------------------------------------------
  1111. /** @brief Retrieve an integer property with a specific key from a material
  1112. *
  1113. * See the sample for aiGetMaterialFloat for more information.*/
  1114. // ---------------------------------------------------------------------------
  1115. inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial* pMat,
  1116. const char* pKey,
  1117. unsigned int type,
  1118. unsigned int index,
  1119. int* pOut)
  1120. {
  1121. return aiGetMaterialIntegerArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0);
  1122. }
  1123. #else
  1124. // use our friend, the C preprocessor
  1125. #define aiGetMaterialInteger (pMat, type, index, pKey, pOut) \
  1126. aiGetMaterialIntegerArray(pMat, type, index, pKey, pOut, NULL)
  1127. #endif //!__cplusplus
  1128. // ---------------------------------------------------------------------------
  1129. /** @brief Retrieve a color value from the material property table
  1130. *
  1131. * See the sample for aiGetMaterialFloat for more information*/
  1132. // ---------------------------------------------------------------------------
  1133. ASSIMP_API C_ENUM aiReturn aiGetMaterialColor(const C_STRUCT aiMaterial* pMat,
  1134. const char* pKey,
  1135. unsigned int type,
  1136. unsigned int index,
  1137. C_STRUCT aiColor4D* pOut);
  1138. // ---------------------------------------------------------------------------
  1139. /** @brief Retrieve a string from the material property table
  1140. *
  1141. * See the sample for aiGetMaterialFloat for more information.*/
  1142. // ---------------------------------------------------------------------------
  1143. ASSIMP_API C_ENUM aiReturn aiGetMaterialString(const C_STRUCT aiMaterial* pMat,
  1144. const char* pKey,
  1145. unsigned int type,
  1146. unsigned int index,
  1147. C_STRUCT aiString* pOut);
  1148. // ---------------------------------------------------------------------------
  1149. /** Get the number of textures for a particular texture type.
  1150. * @param[in] pMat Pointer to the input material. May not be NULL
  1151. * @param type Texture type to check for
  1152. * @return Number of textures for this type.
  1153. * @note A texture can be easily queried using #aiGetMaterialTexture() */
  1154. // ---------------------------------------------------------------------------
  1155. ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat,
  1156. C_ENUM aiTextureType type);
  1157. // ---------------------------------------------------------------------------
  1158. /** @brief Helper function to get all values pertaining to a particular
  1159. * texture slot from a material structure.
  1160. *
  1161. * This function is provided just for convenience. You could also read the
  1162. * texture by parsing all of its properties manually. This function bundles
  1163. * all of them in a huge function monster.
  1164. *
  1165. * @param[in] mat Pointer to the input material. May not be NULL
  1166. * @param[in] type Specifies the texture stack to read from (e.g. diffuse,
  1167. * specular, height map ...).
  1168. * @param[in] index Index of the texture. The function fails if the
  1169. * requested index is not available for this texture type.
  1170. * #aiGetMaterialTextureCount() can be used to determine the number of
  1171. * textures in a particular texture stack.
  1172. * @param[out] path Receives the output path
  1173. * This parameter must be non-null.
  1174. * @param mapping The texture mapping mode to be used.
  1175. * Pass NULL if you're not interested in this information.
  1176. * @param[out] uvindex For UV-mapped textures: receives the index of the UV
  1177. * source channel. Unmodified otherwise.
  1178. * Pass NULL if you're not interested in this information.
  1179. * @param[out] blend Receives the blend factor for the texture
  1180. * Pass NULL if you're not interested in this information.
  1181. * @param[out] op Receives the texture blend operation to be perform between
  1182. * this texture and the previous texture.
  1183. * Pass NULL if you're not interested in this information.
  1184. * @param[out] mapmode Receives the mapping modes to be used for the texture.
  1185. * Pass NULL if you're not interested in this information. Otherwise,
  1186. * pass a pointer to an array of two aiTextureMapMode's (one for each
  1187. * axis, UV order).
  1188. * @return AI_SUCCESS on success, otherwise something else. Have fun.*/
  1189. // ---------------------------------------------------------------------------
  1190. #ifdef __cplusplus
  1191. ASSIMP_API aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
  1192. aiTextureType type,
  1193. unsigned int index,
  1194. aiString* path,
  1195. aiTextureMapping* mapping = NULL,
  1196. unsigned int* uvindex = NULL,
  1197. float* blend = NULL,
  1198. aiTextureOp* op = NULL,
  1199. aiTextureMapMode* mapmode = NULL,
  1200. unsigned int* flags = NULL);
  1201. #else
  1202. C_ENUM aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
  1203. C_ENUM aiTextureType type,
  1204. unsigned int index,
  1205. C_STRUCT aiString* path,
  1206. C_ENUM aiTextureMapping* mapping /*= NULL*/,
  1207. unsigned int* uvindex /*= NULL*/,
  1208. float* blend /*= NULL*/,
  1209. C_ENUM aiTextureOp* op /*= NULL*/,
  1210. C_ENUM aiTextureMapMode* mapmode /*= NULL*/,
  1211. unsigned int* flags /*= NULL*/);
  1212. #endif // !#ifdef __cplusplus
  1213. #ifdef __cplusplus
  1214. }
  1215. #include "material.inl"
  1216. #endif //!__cplusplus
  1217. #endif //!!AI_MATERIAL_H_INC