aiMaterial.h 47 KB

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