material.h 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572
  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 = INT_MAX
  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 = INT_MAX
  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 = INT_MAX
  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 = INT_MAX
  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 = INT_MAX
  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 = INT_MAX
  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 = INT_MAX
  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 = INT_MAX
  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. : mSemantic( 0 )
  539. , mIndex( 0 )
  540. , mDataLength( 0 )
  541. , mType( aiPTI_Float )
  542. , mData( NULL )
  543. {
  544. }
  545. ~aiMaterialProperty() {
  546. delete[] mData;
  547. }
  548. #endif
  549. };
  550. //! @endcond
  551. #ifdef __cplusplus
  552. } // We need to leave the "C" block here to allow template member functions
  553. #endif
  554. // ---------------------------------------------------------------------------
  555. /** @brief Data structure for a material
  556. *
  557. * Material data is stored using a key-value structure. A single key-value
  558. * pair is called a 'material property'. C++ users should use the provided
  559. * member functions of aiMaterial to process material properties, C users
  560. * have to stick with the aiMaterialGetXXX family of unbound functions.
  561. * The library defines a set of standard keys (AI_MATKEY_XXX).
  562. */
  563. #ifdef __cplusplus
  564. struct ASSIMP_API aiMaterial
  565. #else
  566. struct aiMaterial
  567. #endif
  568. {
  569. #ifdef __cplusplus
  570. public:
  571. aiMaterial();
  572. ~aiMaterial();
  573. // -------------------------------------------------------------------
  574. /** @brief Retrieve an array of Type values with a specific key
  575. * from the material
  576. *
  577. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  578. * @param type .. set by AI_MATKEY_XXX
  579. * @param idx .. set by AI_MATKEY_XXX
  580. * @param pOut Pointer to a buffer to receive the result.
  581. * @param pMax Specifies the size of the given buffer, in Type's.
  582. * Receives the number of values (not bytes!) read.
  583. * NULL is a valid value for this parameter.
  584. */
  585. template <typename Type>
  586. aiReturn Get(const char* pKey,unsigned int type,
  587. unsigned int idx, Type* pOut, unsigned int* pMax) const;
  588. aiReturn Get(const char* pKey,unsigned int type,
  589. unsigned int idx, int* pOut, unsigned int* pMax) const;
  590. aiReturn Get(const char* pKey,unsigned int type,
  591. unsigned int idx, float* pOut, unsigned int* pMax) const;
  592. // -------------------------------------------------------------------
  593. /** @brief Retrieve a Type value with a specific key
  594. * from the material
  595. *
  596. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  597. * @param type Specifies the type of the texture to be retrieved (
  598. * e.g. diffuse, specular, height map ...)
  599. * @param idx Index of the texture to be retrieved.
  600. * @param pOut Reference to receive the output value
  601. */
  602. template <typename Type>
  603. aiReturn Get(const char* pKey,unsigned int type,
  604. unsigned int idx,Type& pOut) const;
  605. aiReturn Get(const char* pKey,unsigned int type,
  606. unsigned int idx, int& pOut) const;
  607. aiReturn Get(const char* pKey,unsigned int type,
  608. unsigned int idx, float& pOut) const;
  609. aiReturn Get(const char* pKey,unsigned int type,
  610. unsigned int idx, aiString& pOut) const;
  611. aiReturn Get(const char* pKey,unsigned int type,
  612. unsigned int idx, aiColor3D& pOut) const;
  613. aiReturn Get(const char* pKey,unsigned int type,
  614. unsigned int idx, aiColor4D& pOut) const;
  615. aiReturn Get(const char* pKey,unsigned int type,
  616. unsigned int idx, aiUVTransform& pOut) const;
  617. // -------------------------------------------------------------------
  618. /** Get the number of textures for a particular texture type.
  619. * @param type Texture type to check for
  620. * @return Number of textures for this type.
  621. * @note A texture can be easily queried using #GetTexture() */
  622. unsigned int GetTextureCount(aiTextureType type) const;
  623. // -------------------------------------------------------------------
  624. /** Helper function to get all parameters pertaining to a
  625. * particular texture slot from a material.
  626. *
  627. * This function is provided just for convenience, you could also
  628. * read the single material properties manually.
  629. * @param type Specifies the type of the texture to be retrieved (
  630. * e.g. diffuse, specular, height map ...)
  631. * @param index Index of the texture to be retrieved. The function fails
  632. * if there is no texture of that type with this index.
  633. * #GetTextureCount() can be used to determine the number of textures
  634. * per texture type.
  635. * @param path Receives the path to the texture.
  636. * NULL is a valid value.
  637. * @param mapping The texture mapping.
  638. * NULL is allowed as value.
  639. * @param uvindex Receives the UV index of the texture.
  640. * NULL is a valid value.
  641. * @param blend Receives the blend factor for the texture
  642. * NULL is a valid value.
  643. * @param op Receives the texture operation to be performed between
  644. * this texture and the previous texture. NULL is allowed as value.
  645. * @param mapmode Receives the mapping modes to be used for the texture.
  646. * The parameter may be NULL but if it is a valid pointer it MUST
  647. * point to an array of 3 aiTextureMapMode's (one for each
  648. * axis: UVW order (=XYZ)).
  649. */
  650. // -------------------------------------------------------------------
  651. aiReturn GetTexture(aiTextureType type,
  652. unsigned int index,
  653. C_STRUCT aiString* path,
  654. aiTextureMapping* mapping = NULL,
  655. unsigned int* uvindex = NULL,
  656. float* blend = NULL,
  657. aiTextureOp* op = NULL,
  658. aiTextureMapMode* mapmode = NULL) const;
  659. // Setters
  660. // ------------------------------------------------------------------------------
  661. /** @brief Add a property with a given key and type info to the material
  662. * structure
  663. *
  664. * @param pInput Pointer to input data
  665. * @param pSizeInBytes Size of input data
  666. * @param pKey Key/Usage of the property (AI_MATKEY_XXX)
  667. * @param type Set by the AI_MATKEY_XXX macro
  668. * @param index Set by the AI_MATKEY_XXX macro
  669. * @param pType Type information hint */
  670. aiReturn AddBinaryProperty (const void* pInput,
  671. unsigned int pSizeInBytes,
  672. const char* pKey,
  673. unsigned int type ,
  674. unsigned int index ,
  675. aiPropertyTypeInfo pType);
  676. // ------------------------------------------------------------------------------
  677. /** @brief Add a string property with a given key and type info to the
  678. * material structure
  679. *
  680. * @param pInput Input string
  681. * @param pKey Key/Usage of the property (AI_MATKEY_XXX)
  682. * @param type Set by the AI_MATKEY_XXX macro
  683. * @param index Set by the AI_MATKEY_XXX macro */
  684. aiReturn AddProperty (const aiString* pInput,
  685. const char* pKey,
  686. unsigned int type = 0,
  687. unsigned int index = 0);
  688. // ------------------------------------------------------------------------------
  689. /** @brief Add a property with a given key to the material structure
  690. * @param pInput Pointer to the input data
  691. * @param pNumValues Number of values in the array
  692. * @param pKey Key/Usage of the property (AI_MATKEY_XXX)
  693. * @param type Set by the AI_MATKEY_XXX macro
  694. * @param index Set by the AI_MATKEY_XXX macro */
  695. template<class TYPE>
  696. aiReturn AddProperty (const TYPE* pInput,
  697. unsigned int pNumValues,
  698. const char* pKey,
  699. unsigned int type = 0,
  700. unsigned int index = 0);
  701. aiReturn AddProperty (const aiVector3D* pInput,
  702. unsigned int pNumValues,
  703. const char* pKey,
  704. unsigned int type = 0,
  705. unsigned int index = 0);
  706. aiReturn AddProperty (const aiColor3D* pInput,
  707. unsigned int pNumValues,
  708. const char* pKey,
  709. unsigned int type = 0,
  710. unsigned int index = 0);
  711. aiReturn AddProperty (const aiColor4D* pInput,
  712. unsigned int pNumValues,
  713. const char* pKey,
  714. unsigned int type = 0,
  715. unsigned int index = 0);
  716. aiReturn AddProperty (const int* pInput,
  717. unsigned int pNumValues,
  718. const char* pKey,
  719. unsigned int type = 0,
  720. unsigned int index = 0);
  721. aiReturn AddProperty (const float* pInput,
  722. unsigned int pNumValues,
  723. const char* pKey,
  724. unsigned int type = 0,
  725. unsigned int index = 0);
  726. aiReturn AddProperty (const aiUVTransform* pInput,
  727. unsigned int pNumValues,
  728. const char* pKey,
  729. unsigned int type = 0,
  730. unsigned int index = 0);
  731. // ------------------------------------------------------------------------------
  732. /** @brief Remove a given key from the list.
  733. *
  734. * The function fails if the key isn't found
  735. * @param pKey Key to be deleted */
  736. aiReturn RemoveProperty (const char* pKey,
  737. unsigned int type = 0,
  738. unsigned int index = 0);
  739. // ------------------------------------------------------------------------------
  740. /** @brief Removes all properties from the material.
  741. *
  742. * The data array remains allocated so adding new properties is quite fast. */
  743. void Clear();
  744. // ------------------------------------------------------------------------------
  745. /** Copy the property list of a material
  746. * @param pcDest Destination material
  747. * @param pcSrc Source material
  748. */
  749. static void CopyPropertyList(aiMaterial* pcDest,
  750. const aiMaterial* pcSrc);
  751. #endif
  752. /** List of all material properties loaded. */
  753. C_STRUCT aiMaterialProperty** mProperties;
  754. /** Number of properties in the data base */
  755. unsigned int mNumProperties;
  756. /** Storage allocated */
  757. unsigned int mNumAllocated;
  758. };
  759. // Go back to extern "C" again
  760. #ifdef __cplusplus
  761. extern "C" {
  762. #endif
  763. // ---------------------------------------------------------------------------
  764. #define AI_MATKEY_NAME "?mat.name",0,0
  765. #define AI_MATKEY_TWOSIDED "$mat.twosided",0,0
  766. #define AI_MATKEY_SHADING_MODEL "$mat.shadingm",0,0
  767. #define AI_MATKEY_ENABLE_WIREFRAME "$mat.wireframe",0,0
  768. #define AI_MATKEY_BLEND_FUNC "$mat.blend",0,0
  769. #define AI_MATKEY_OPACITY "$mat.opacity",0,0
  770. #define AI_MATKEY_BUMPSCALING "$mat.bumpscaling",0,0
  771. #define AI_MATKEY_SHININESS "$mat.shininess",0,0
  772. #define AI_MATKEY_REFLECTIVITY "$mat.reflectivity",0,0
  773. #define AI_MATKEY_SHININESS_STRENGTH "$mat.shinpercent",0,0
  774. #define AI_MATKEY_REFRACTI "$mat.refracti",0,0
  775. #define AI_MATKEY_COLOR_DIFFUSE "$clr.diffuse",0,0
  776. #define AI_MATKEY_COLOR_AMBIENT "$clr.ambient",0,0
  777. #define AI_MATKEY_COLOR_SPECULAR "$clr.specular",0,0
  778. #define AI_MATKEY_COLOR_EMISSIVE "$clr.emissive",0,0
  779. #define AI_MATKEY_COLOR_TRANSPARENT "$clr.transparent",0,0
  780. #define AI_MATKEY_COLOR_REFLECTIVE "$clr.reflective",0,0
  781. #define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "?bg.global",0,0
  782. // ---------------------------------------------------------------------------
  783. // Pure key names for all texture-related properties
  784. //! @cond MATS_DOC_FULL
  785. #define _AI_MATKEY_TEXTURE_BASE "$tex.file"
  786. #define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"
  787. #define _AI_MATKEY_TEXOP_BASE "$tex.op"
  788. #define _AI_MATKEY_MAPPING_BASE "$tex.mapping"
  789. #define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"
  790. #define _AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu"
  791. #define _AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev"
  792. #define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"
  793. #define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"
  794. #define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
  795. //! @endcond
  796. // ---------------------------------------------------------------------------
  797. #define AI_MATKEY_TEXTURE(type, N) _AI_MATKEY_TEXTURE_BASE,type,N
  798. // For backward compatibility and simplicity
  799. //! @cond MATS_DOC_FULL
  800. #define AI_MATKEY_TEXTURE_DIFFUSE(N) \
  801. AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE,N)
  802. #define AI_MATKEY_TEXTURE_SPECULAR(N) \
  803. AI_MATKEY_TEXTURE(aiTextureType_SPECULAR,N)
  804. #define AI_MATKEY_TEXTURE_AMBIENT(N) \
  805. AI_MATKEY_TEXTURE(aiTextureType_AMBIENT,N)
  806. #define AI_MATKEY_TEXTURE_EMISSIVE(N) \
  807. AI_MATKEY_TEXTURE(aiTextureType_EMISSIVE,N)
  808. #define AI_MATKEY_TEXTURE_NORMALS(N) \
  809. AI_MATKEY_TEXTURE(aiTextureType_NORMALS,N)
  810. #define AI_MATKEY_TEXTURE_HEIGHT(N) \
  811. AI_MATKEY_TEXTURE(aiTextureType_HEIGHT,N)
  812. #define AI_MATKEY_TEXTURE_SHININESS(N) \
  813. AI_MATKEY_TEXTURE(aiTextureType_SHININESS,N)
  814. #define AI_MATKEY_TEXTURE_OPACITY(N) \
  815. AI_MATKEY_TEXTURE(aiTextureType_OPACITY,N)
  816. #define AI_MATKEY_TEXTURE_DISPLACEMENT(N) \
  817. AI_MATKEY_TEXTURE(aiTextureType_DISPLACEMENT,N)
  818. #define AI_MATKEY_TEXTURE_LIGHTMAP(N) \
  819. AI_MATKEY_TEXTURE(aiTextureType_LIGHTMAP,N)
  820. #define AI_MATKEY_TEXTURE_REFLECTION(N) \
  821. AI_MATKEY_TEXTURE(aiTextureType_REFLECTION,N)
  822. //! @endcond
  823. // ---------------------------------------------------------------------------
  824. #define AI_MATKEY_UVWSRC(type, N) _AI_MATKEY_UVWSRC_BASE,type,N
  825. // For backward compatibility and simplicity
  826. //! @cond MATS_DOC_FULL
  827. #define AI_MATKEY_UVWSRC_DIFFUSE(N) \
  828. AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE,N)
  829. #define AI_MATKEY_UVWSRC_SPECULAR(N) \
  830. AI_MATKEY_UVWSRC(aiTextureType_SPECULAR,N)
  831. #define AI_MATKEY_UVWSRC_AMBIENT(N) \
  832. AI_MATKEY_UVWSRC(aiTextureType_AMBIENT,N)
  833. #define AI_MATKEY_UVWSRC_EMISSIVE(N) \
  834. AI_MATKEY_UVWSRC(aiTextureType_EMISSIVE,N)
  835. #define AI_MATKEY_UVWSRC_NORMALS(N) \
  836. AI_MATKEY_UVWSRC(aiTextureType_NORMALS,N)
  837. #define AI_MATKEY_UVWSRC_HEIGHT(N) \
  838. AI_MATKEY_UVWSRC(aiTextureType_HEIGHT,N)
  839. #define AI_MATKEY_UVWSRC_SHININESS(N) \
  840. AI_MATKEY_UVWSRC(aiTextureType_SHININESS,N)
  841. #define AI_MATKEY_UVWSRC_OPACITY(N) \
  842. AI_MATKEY_UVWSRC(aiTextureType_OPACITY,N)
  843. #define AI_MATKEY_UVWSRC_DISPLACEMENT(N) \
  844. AI_MATKEY_UVWSRC(aiTextureType_DISPLACEMENT,N)
  845. #define AI_MATKEY_UVWSRC_LIGHTMAP(N) \
  846. AI_MATKEY_UVWSRC(aiTextureType_LIGHTMAP,N)
  847. #define AI_MATKEY_UVWSRC_REFLECTION(N) \
  848. AI_MATKEY_UVWSRC(aiTextureType_REFLECTION,N)
  849. //! @endcond
  850. // ---------------------------------------------------------------------------
  851. #define AI_MATKEY_TEXOP(type, N) _AI_MATKEY_TEXOP_BASE,type,N
  852. // For backward compatibility and simplicity
  853. //! @cond MATS_DOC_FULL
  854. #define AI_MATKEY_TEXOP_DIFFUSE(N) \
  855. AI_MATKEY_TEXOP(aiTextureType_DIFFUSE,N)
  856. #define AI_MATKEY_TEXOP_SPECULAR(N) \
  857. AI_MATKEY_TEXOP(aiTextureType_SPECULAR,N)
  858. #define AI_MATKEY_TEXOP_AMBIENT(N) \
  859. AI_MATKEY_TEXOP(aiTextureType_AMBIENT,N)
  860. #define AI_MATKEY_TEXOP_EMISSIVE(N) \
  861. AI_MATKEY_TEXOP(aiTextureType_EMISSIVE,N)
  862. #define AI_MATKEY_TEXOP_NORMALS(N) \
  863. AI_MATKEY_TEXOP(aiTextureType_NORMALS,N)
  864. #define AI_MATKEY_TEXOP_HEIGHT(N) \
  865. AI_MATKEY_TEXOP(aiTextureType_HEIGHT,N)
  866. #define AI_MATKEY_TEXOP_SHININESS(N) \
  867. AI_MATKEY_TEXOP(aiTextureType_SHININESS,N)
  868. #define AI_MATKEY_TEXOP_OPACITY(N) \
  869. AI_MATKEY_TEXOP(aiTextureType_OPACITY,N)
  870. #define AI_MATKEY_TEXOP_DISPLACEMENT(N) \
  871. AI_MATKEY_TEXOP(aiTextureType_DISPLACEMENT,N)
  872. #define AI_MATKEY_TEXOP_LIGHTMAP(N) \
  873. AI_MATKEY_TEXOP(aiTextureType_LIGHTMAP,N)
  874. #define AI_MATKEY_TEXOP_REFLECTION(N) \
  875. AI_MATKEY_TEXOP(aiTextureType_REFLECTION,N)
  876. //! @endcond
  877. // ---------------------------------------------------------------------------
  878. #define AI_MATKEY_MAPPING(type, N) _AI_MATKEY_MAPPING_BASE,type,N
  879. // For backward compatibility and simplicity
  880. //! @cond MATS_DOC_FULL
  881. #define AI_MATKEY_MAPPING_DIFFUSE(N) \
  882. AI_MATKEY_MAPPING(aiTextureType_DIFFUSE,N)
  883. #define AI_MATKEY_MAPPING_SPECULAR(N) \
  884. AI_MATKEY_MAPPING(aiTextureType_SPECULAR,N)
  885. #define AI_MATKEY_MAPPING_AMBIENT(N) \
  886. AI_MATKEY_MAPPING(aiTextureType_AMBIENT,N)
  887. #define AI_MATKEY_MAPPING_EMISSIVE(N) \
  888. AI_MATKEY_MAPPING(aiTextureType_EMISSIVE,N)
  889. #define AI_MATKEY_MAPPING_NORMALS(N) \
  890. AI_MATKEY_MAPPING(aiTextureType_NORMALS,N)
  891. #define AI_MATKEY_MAPPING_HEIGHT(N) \
  892. AI_MATKEY_MAPPING(aiTextureType_HEIGHT,N)
  893. #define AI_MATKEY_MAPPING_SHININESS(N) \
  894. AI_MATKEY_MAPPING(aiTextureType_SHININESS,N)
  895. #define AI_MATKEY_MAPPING_OPACITY(N) \
  896. AI_MATKEY_MAPPING(aiTextureType_OPACITY,N)
  897. #define AI_MATKEY_MAPPING_DISPLACEMENT(N) \
  898. AI_MATKEY_MAPPING(aiTextureType_DISPLACEMENT,N)
  899. #define AI_MATKEY_MAPPING_LIGHTMAP(N) \
  900. AI_MATKEY_MAPPING(aiTextureType_LIGHTMAP,N)
  901. #define AI_MATKEY_MAPPING_REFLECTION(N) \
  902. AI_MATKEY_MAPPING(aiTextureType_REFLECTION,N)
  903. //! @endcond
  904. // ---------------------------------------------------------------------------
  905. #define AI_MATKEY_TEXBLEND(type, N) _AI_MATKEY_TEXBLEND_BASE,type,N
  906. // For backward compatibility and simplicity
  907. //! @cond MATS_DOC_FULL
  908. #define AI_MATKEY_TEXBLEND_DIFFUSE(N) \
  909. AI_MATKEY_TEXBLEND(aiTextureType_DIFFUSE,N)
  910. #define AI_MATKEY_TEXBLEND_SPECULAR(N) \
  911. AI_MATKEY_TEXBLEND(aiTextureType_SPECULAR,N)
  912. #define AI_MATKEY_TEXBLEND_AMBIENT(N) \
  913. AI_MATKEY_TEXBLEND(aiTextureType_AMBIENT,N)
  914. #define AI_MATKEY_TEXBLEND_EMISSIVE(N) \
  915. AI_MATKEY_TEXBLEND(aiTextureType_EMISSIVE,N)
  916. #define AI_MATKEY_TEXBLEND_NORMALS(N) \
  917. AI_MATKEY_TEXBLEND(aiTextureType_NORMALS,N)
  918. #define AI_MATKEY_TEXBLEND_HEIGHT(N) \
  919. AI_MATKEY_TEXBLEND(aiTextureType_HEIGHT,N)
  920. #define AI_MATKEY_TEXBLEND_SHININESS(N) \
  921. AI_MATKEY_TEXBLEND(aiTextureType_SHININESS,N)
  922. #define AI_MATKEY_TEXBLEND_OPACITY(N) \
  923. AI_MATKEY_TEXBLEND(aiTextureType_OPACITY,N)
  924. #define AI_MATKEY_TEXBLEND_DISPLACEMENT(N) \
  925. AI_MATKEY_TEXBLEND(aiTextureType_DISPLACEMENT,N)
  926. #define AI_MATKEY_TEXBLEND_LIGHTMAP(N) \
  927. AI_MATKEY_TEXBLEND(aiTextureType_LIGHTMAP,N)
  928. #define AI_MATKEY_TEXBLEND_REFLECTION(N) \
  929. AI_MATKEY_TEXBLEND(aiTextureType_REFLECTION,N)
  930. //! @endcond
  931. // ---------------------------------------------------------------------------
  932. #define AI_MATKEY_MAPPINGMODE_U(type, N) _AI_MATKEY_MAPPINGMODE_U_BASE,type,N
  933. // For backward compatibility and simplicity
  934. //! @cond MATS_DOC_FULL
  935. #define AI_MATKEY_MAPPINGMODE_U_DIFFUSE(N) \
  936. AI_MATKEY_MAPPINGMODE_U(aiTextureType_DIFFUSE,N)
  937. #define AI_MATKEY_MAPPINGMODE_U_SPECULAR(N) \
  938. AI_MATKEY_MAPPINGMODE_U(aiTextureType_SPECULAR,N)
  939. #define AI_MATKEY_MAPPINGMODE_U_AMBIENT(N) \
  940. AI_MATKEY_MAPPINGMODE_U(aiTextureType_AMBIENT,N)
  941. #define AI_MATKEY_MAPPINGMODE_U_EMISSIVE(N) \
  942. AI_MATKEY_MAPPINGMODE_U(aiTextureType_EMISSIVE,N)
  943. #define AI_MATKEY_MAPPINGMODE_U_NORMALS(N) \
  944. AI_MATKEY_MAPPINGMODE_U(aiTextureType_NORMALS,N)
  945. #define AI_MATKEY_MAPPINGMODE_U_HEIGHT(N) \
  946. AI_MATKEY_MAPPINGMODE_U(aiTextureType_HEIGHT,N)
  947. #define AI_MATKEY_MAPPINGMODE_U_SHININESS(N) \
  948. AI_MATKEY_MAPPINGMODE_U(aiTextureType_SHININESS,N)
  949. #define AI_MATKEY_MAPPINGMODE_U_OPACITY(N) \
  950. AI_MATKEY_MAPPINGMODE_U(aiTextureType_OPACITY,N)
  951. #define AI_MATKEY_MAPPINGMODE_U_DISPLACEMENT(N) \
  952. AI_MATKEY_MAPPINGMODE_U(aiTextureType_DISPLACEMENT,N)
  953. #define AI_MATKEY_MAPPINGMODE_U_LIGHTMAP(N) \
  954. AI_MATKEY_MAPPINGMODE_U(aiTextureType_LIGHTMAP,N)
  955. #define AI_MATKEY_MAPPINGMODE_U_REFLECTION(N) \
  956. AI_MATKEY_MAPPINGMODE_U(aiTextureType_REFLECTION,N)
  957. //! @endcond
  958. // ---------------------------------------------------------------------------
  959. #define AI_MATKEY_MAPPINGMODE_V(type, N) _AI_MATKEY_MAPPINGMODE_V_BASE,type,N
  960. // For backward compatibility and simplicity
  961. //! @cond MATS_DOC_FULL
  962. #define AI_MATKEY_MAPPINGMODE_V_DIFFUSE(N) \
  963. AI_MATKEY_MAPPINGMODE_V(aiTextureType_DIFFUSE,N)
  964. #define AI_MATKEY_MAPPINGMODE_V_SPECULAR(N) \
  965. AI_MATKEY_MAPPINGMODE_V(aiTextureType_SPECULAR,N)
  966. #define AI_MATKEY_MAPPINGMODE_V_AMBIENT(N) \
  967. AI_MATKEY_MAPPINGMODE_V(aiTextureType_AMBIENT,N)
  968. #define AI_MATKEY_MAPPINGMODE_V_EMISSIVE(N) \
  969. AI_MATKEY_MAPPINGMODE_V(aiTextureType_EMISSIVE,N)
  970. #define AI_MATKEY_MAPPINGMODE_V_NORMALS(N) \
  971. AI_MATKEY_MAPPINGMODE_V(aiTextureType_NORMALS,N)
  972. #define AI_MATKEY_MAPPINGMODE_V_HEIGHT(N) \
  973. AI_MATKEY_MAPPINGMODE_V(aiTextureType_HEIGHT,N)
  974. #define AI_MATKEY_MAPPINGMODE_V_SHININESS(N) \
  975. AI_MATKEY_MAPPINGMODE_V(aiTextureType_SHININESS,N)
  976. #define AI_MATKEY_MAPPINGMODE_V_OPACITY(N) \
  977. AI_MATKEY_MAPPINGMODE_V(aiTextureType_OPACITY,N)
  978. #define AI_MATKEY_MAPPINGMODE_V_DISPLACEMENT(N) \
  979. AI_MATKEY_MAPPINGMODE_V(aiTextureType_DISPLACEMENT,N)
  980. #define AI_MATKEY_MAPPINGMODE_V_LIGHTMAP(N) \
  981. AI_MATKEY_MAPPINGMODE_V(aiTextureType_LIGHTMAP,N)
  982. #define AI_MATKEY_MAPPINGMODE_V_REFLECTION(N) \
  983. AI_MATKEY_MAPPINGMODE_V(aiTextureType_REFLECTION,N)
  984. //! @endcond
  985. // ---------------------------------------------------------------------------
  986. #define AI_MATKEY_TEXMAP_AXIS(type, N) _AI_MATKEY_TEXMAP_AXIS_BASE,type,N
  987. // For backward compatibility and simplicity
  988. //! @cond MATS_DOC_FULL
  989. #define AI_MATKEY_TEXMAP_AXIS_DIFFUSE(N) \
  990. AI_MATKEY_TEXMAP_AXIS(aiTextureType_DIFFUSE,N)
  991. #define AI_MATKEY_TEXMAP_AXIS_SPECULAR(N) \
  992. AI_MATKEY_TEXMAP_AXIS(aiTextureType_SPECULAR,N)
  993. #define AI_MATKEY_TEXMAP_AXIS_AMBIENT(N) \
  994. AI_MATKEY_TEXMAP_AXIS(aiTextureType_AMBIENT,N)
  995. #define AI_MATKEY_TEXMAP_AXIS_EMISSIVE(N) \
  996. AI_MATKEY_TEXMAP_AXIS(aiTextureType_EMISSIVE,N)
  997. #define AI_MATKEY_TEXMAP_AXIS_NORMALS(N) \
  998. AI_MATKEY_TEXMAP_AXIS(aiTextureType_NORMALS,N)
  999. #define AI_MATKEY_TEXMAP_AXIS_HEIGHT(N) \
  1000. AI_MATKEY_TEXMAP_AXIS(aiTextureType_HEIGHT,N)
  1001. #define AI_MATKEY_TEXMAP_AXIS_SHININESS(N) \
  1002. AI_MATKEY_TEXMAP_AXIS(aiTextureType_SHININESS,N)
  1003. #define AI_MATKEY_TEXMAP_AXIS_OPACITY(N) \
  1004. AI_MATKEY_TEXMAP_AXIS(aiTextureType_OPACITY,N)
  1005. #define AI_MATKEY_TEXMAP_AXIS_DISPLACEMENT(N) \
  1006. AI_MATKEY_TEXMAP_AXIS(aiTextureType_DISPLACEMENT,N)
  1007. #define AI_MATKEY_TEXMAP_AXIS_LIGHTMAP(N) \
  1008. AI_MATKEY_TEXMAP_AXIS(aiTextureType_LIGHTMAP,N)
  1009. #define AI_MATKEY_TEXMAP_AXIS_REFLECTION(N) \
  1010. AI_MATKEY_TEXMAP_AXIS(aiTextureType_REFLECTION,N)
  1011. //! @endcond
  1012. // ---------------------------------------------------------------------------
  1013. #define AI_MATKEY_UVTRANSFORM(type, N) _AI_MATKEY_UVTRANSFORM_BASE,type,N
  1014. // For backward compatibility and simplicity
  1015. //! @cond MATS_DOC_FULL
  1016. #define AI_MATKEY_UVTRANSFORM_DIFFUSE(N) \
  1017. AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE,N)
  1018. #define AI_MATKEY_UVTRANSFORM_SPECULAR(N) \
  1019. AI_MATKEY_UVTRANSFORM(aiTextureType_SPECULAR,N)
  1020. #define AI_MATKEY_UVTRANSFORM_AMBIENT(N) \
  1021. AI_MATKEY_UVTRANSFORM(aiTextureType_AMBIENT,N)
  1022. #define AI_MATKEY_UVTRANSFORM_EMISSIVE(N) \
  1023. AI_MATKEY_UVTRANSFORM(aiTextureType_EMISSIVE,N)
  1024. #define AI_MATKEY_UVTRANSFORM_NORMALS(N) \
  1025. AI_MATKEY_UVTRANSFORM(aiTextureType_NORMALS,N)
  1026. #define AI_MATKEY_UVTRANSFORM_HEIGHT(N) \
  1027. AI_MATKEY_UVTRANSFORM(aiTextureType_HEIGHT,N)
  1028. #define AI_MATKEY_UVTRANSFORM_SHININESS(N) \
  1029. AI_MATKEY_UVTRANSFORM(aiTextureType_SHININESS,N)
  1030. #define AI_MATKEY_UVTRANSFORM_OPACITY(N) \
  1031. AI_MATKEY_UVTRANSFORM(aiTextureType_OPACITY,N)
  1032. #define AI_MATKEY_UVTRANSFORM_DISPLACEMENT(N) \
  1033. AI_MATKEY_UVTRANSFORM(aiTextureType_DISPLACEMENT,N)
  1034. #define AI_MATKEY_UVTRANSFORM_LIGHTMAP(N) \
  1035. AI_MATKEY_UVTRANSFORM(aiTextureType_LIGHTMAP,N)
  1036. #define AI_MATKEY_UVTRANSFORM_REFLECTION(N) \
  1037. AI_MATKEY_UVTRANSFORM(aiTextureType_REFLECTION,N)
  1038. #define AI_MATKEY_UVTRANSFORM_UNKNOWN(N) \
  1039. AI_MATKEY_UVTRANSFORM(aiTextureType_UNKNOWN,N)
  1040. //! @endcond
  1041. // ---------------------------------------------------------------------------
  1042. #define AI_MATKEY_TEXFLAGS(type, N) _AI_MATKEY_TEXFLAGS_BASE,type,N
  1043. // For backward compatibility and simplicity
  1044. //! @cond MATS_DOC_FULL
  1045. #define AI_MATKEY_TEXFLAGS_DIFFUSE(N) \
  1046. AI_MATKEY_TEXFLAGS(aiTextureType_DIFFUSE,N)
  1047. #define AI_MATKEY_TEXFLAGS_SPECULAR(N) \
  1048. AI_MATKEY_TEXFLAGS(aiTextureType_SPECULAR,N)
  1049. #define AI_MATKEY_TEXFLAGS_AMBIENT(N) \
  1050. AI_MATKEY_TEXFLAGS(aiTextureType_AMBIENT,N)
  1051. #define AI_MATKEY_TEXFLAGS_EMISSIVE(N) \
  1052. AI_MATKEY_TEXFLAGS(aiTextureType_EMISSIVE,N)
  1053. #define AI_MATKEY_TEXFLAGS_NORMALS(N) \
  1054. AI_MATKEY_TEXFLAGS(aiTextureType_NORMALS,N)
  1055. #define AI_MATKEY_TEXFLAGS_HEIGHT(N) \
  1056. AI_MATKEY_TEXFLAGS(aiTextureType_HEIGHT,N)
  1057. #define AI_MATKEY_TEXFLAGS_SHININESS(N) \
  1058. AI_MATKEY_TEXFLAGS(aiTextureType_SHININESS,N)
  1059. #define AI_MATKEY_TEXFLAGS_OPACITY(N) \
  1060. AI_MATKEY_TEXFLAGS(aiTextureType_OPACITY,N)
  1061. #define AI_MATKEY_TEXFLAGS_DISPLACEMENT(N) \
  1062. AI_MATKEY_TEXFLAGS(aiTextureType_DISPLACEMENT,N)
  1063. #define AI_MATKEY_TEXFLAGS_LIGHTMAP(N) \
  1064. AI_MATKEY_TEXFLAGS(aiTextureType_LIGHTMAP,N)
  1065. #define AI_MATKEY_TEXFLAGS_REFLECTION(N) \
  1066. AI_MATKEY_TEXFLAGS(aiTextureType_REFLECTION,N)
  1067. #define AI_MATKEY_TEXFLAGS_UNKNOWN(N) \
  1068. AI_MATKEY_TEXFLAGS(aiTextureType_UNKNOWN,N)
  1069. // ---------------------------------------------------------------------------
  1070. /** @brief Retrieve a material property with a specific key from the material
  1071. *
  1072. * @param pMat Pointer to the input material. May not be NULL
  1073. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  1074. * @param type Specifies the type of the texture to be retrieved (
  1075. * e.g. diffuse, specular, height map ...)
  1076. * @param index Index of the texture to be retrieved.
  1077. * @param pPropOut Pointer to receive a pointer to a valid aiMaterialProperty
  1078. * structure or NULL if the key has not been found. */
  1079. // ---------------------------------------------------------------------------
  1080. ASSIMP_API C_ENUM aiReturn aiGetMaterialProperty(
  1081. const C_STRUCT aiMaterial* pMat,
  1082. const char* pKey,
  1083. unsigned int type,
  1084. unsigned int index,
  1085. const C_STRUCT aiMaterialProperty** pPropOut);
  1086. // ---------------------------------------------------------------------------
  1087. /** @brief Retrieve an array of float values with a specific key
  1088. * from the material
  1089. *
  1090. * Pass one of the AI_MATKEY_XXX constants for the last three parameters (the
  1091. * example reads the #AI_MATKEY_UVTRANSFORM property of the first diffuse texture)
  1092. * @code
  1093. * aiUVTransform trafo;
  1094. * unsigned int max = sizeof(aiUVTransform);
  1095. * if (AI_SUCCESS != aiGetMaterialFloatArray(mat, AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE,0),
  1096. * (float*)&trafo, &max) || sizeof(aiUVTransform) != max)
  1097. * {
  1098. * // error handling
  1099. * }
  1100. * @endcode
  1101. *
  1102. * @param pMat Pointer to the input material. May not be NULL
  1103. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  1104. * @param pOut Pointer to a buffer to receive the result.
  1105. * @param pMax Specifies the size of the given buffer, in float's.
  1106. * Receives the number of values (not bytes!) read.
  1107. * @param type (see the code sample above)
  1108. * @param index (see the code sample above)
  1109. * @return Specifies whether the key has been found. If not, the output
  1110. * arrays remains unmodified and pMax is set to 0.*/
  1111. // ---------------------------------------------------------------------------
  1112. ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
  1113. const C_STRUCT aiMaterial* pMat,
  1114. const char* pKey,
  1115. unsigned int type,
  1116. unsigned int index,
  1117. float* pOut,
  1118. unsigned int* pMax);
  1119. #ifdef __cplusplus
  1120. // ---------------------------------------------------------------------------
  1121. /** @brief Retrieve a single float property with a specific key from the material.
  1122. *
  1123. * Pass one of the AI_MATKEY_XXX constants for the last three parameters (the
  1124. * example reads the #AI_MATKEY_SHININESS_STRENGTH property of the first diffuse texture)
  1125. * @code
  1126. * float specStrength = 1.f; // default value, remains unmodified if we fail.
  1127. * aiGetMaterialFloat(mat, AI_MATKEY_SHININESS_STRENGTH,
  1128. * (float*)&specStrength);
  1129. * @endcode
  1130. *
  1131. * @param pMat Pointer to the input material. May not be NULL
  1132. * @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
  1133. * @param pOut Receives the output float.
  1134. * @param type (see the code sample above)
  1135. * @param index (see the code sample above)
  1136. * @return Specifies whether the key has been found. If not, the output
  1137. * float remains unmodified.*/
  1138. // ---------------------------------------------------------------------------
  1139. inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat,
  1140. const char* pKey,
  1141. unsigned int type,
  1142. unsigned int index,
  1143. float* pOut)
  1144. {
  1145. return aiGetMaterialFloatArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0);
  1146. }
  1147. #else
  1148. // Use our friend, the C preprocessor
  1149. #define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \
  1150. aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL)
  1151. #endif //!__cplusplus
  1152. // ---------------------------------------------------------------------------
  1153. /** @brief Retrieve an array of integer values with a specific key
  1154. * from a material
  1155. *
  1156. * See the sample for aiGetMaterialFloatArray for more information.*/
  1157. ASSIMP_API C_ENUM aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial* pMat,
  1158. const char* pKey,
  1159. unsigned int type,
  1160. unsigned int index,
  1161. int* pOut,
  1162. unsigned int* pMax);
  1163. #ifdef __cplusplus
  1164. // ---------------------------------------------------------------------------
  1165. /** @brief Retrieve an integer property with a specific key from a material
  1166. *
  1167. * See the sample for aiGetMaterialFloat for more information.*/
  1168. // ---------------------------------------------------------------------------
  1169. inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial* pMat,
  1170. const char* pKey,
  1171. unsigned int type,
  1172. unsigned int index,
  1173. int* pOut)
  1174. {
  1175. return aiGetMaterialIntegerArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0);
  1176. }
  1177. #else
  1178. // use our friend, the C preprocessor
  1179. #define aiGetMaterialInteger (pMat, type, index, pKey, pOut) \
  1180. aiGetMaterialIntegerArray(pMat, type, index, pKey, pOut, NULL)
  1181. #endif //!__cplusplus
  1182. // ---------------------------------------------------------------------------
  1183. /** @brief Retrieve a color value from the material property table
  1184. *
  1185. * See the sample for aiGetMaterialFloat for more information*/
  1186. // ---------------------------------------------------------------------------
  1187. ASSIMP_API C_ENUM aiReturn aiGetMaterialColor(const C_STRUCT aiMaterial* pMat,
  1188. const char* pKey,
  1189. unsigned int type,
  1190. unsigned int index,
  1191. C_STRUCT aiColor4D* pOut);
  1192. // ---------------------------------------------------------------------------
  1193. /** @brief Retrieve a aiUVTransform value from the material property table
  1194. *
  1195. * See the sample for aiGetMaterialFloat for more information*/
  1196. // ---------------------------------------------------------------------------
  1197. ASSIMP_API C_ENUM aiReturn aiGetMaterialUVTransform(const C_STRUCT aiMaterial* pMat,
  1198. const char* pKey,
  1199. unsigned int type,
  1200. unsigned int index,
  1201. C_STRUCT aiUVTransform* pOut);
  1202. // ---------------------------------------------------------------------------
  1203. /** @brief Retrieve a string from the material property table
  1204. *
  1205. * See the sample for aiGetMaterialFloat for more information.*/
  1206. // ---------------------------------------------------------------------------
  1207. ASSIMP_API C_ENUM aiReturn aiGetMaterialString(const C_STRUCT aiMaterial* pMat,
  1208. const char* pKey,
  1209. unsigned int type,
  1210. unsigned int index,
  1211. C_STRUCT aiString* pOut);
  1212. // ---------------------------------------------------------------------------
  1213. /** Get the number of textures for a particular texture type.
  1214. * @param[in] pMat Pointer to the input material. May not be NULL
  1215. * @param type Texture type to check for
  1216. * @return Number of textures for this type.
  1217. * @note A texture can be easily queried using #aiGetMaterialTexture() */
  1218. // ---------------------------------------------------------------------------
  1219. ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat,
  1220. C_ENUM aiTextureType type);
  1221. // ---------------------------------------------------------------------------
  1222. /** @brief Helper function to get all values pertaining to a particular
  1223. * texture slot from a material structure.
  1224. *
  1225. * This function is provided just for convenience. You could also read the
  1226. * texture by parsing all of its properties manually. This function bundles
  1227. * all of them in a huge function monster.
  1228. *
  1229. * @param[in] mat Pointer to the input material. May not be NULL
  1230. * @param[in] type Specifies the texture stack to read from (e.g. diffuse,
  1231. * specular, height map ...).
  1232. * @param[in] index Index of the texture. The function fails if the
  1233. * requested index is not available for this texture type.
  1234. * #aiGetMaterialTextureCount() can be used to determine the number of
  1235. * textures in a particular texture stack.
  1236. * @param[out] path Receives the output path
  1237. * This parameter must be non-null.
  1238. * @param mapping The texture mapping mode to be used.
  1239. * Pass NULL if you're not interested in this information.
  1240. * @param[out] uvindex For UV-mapped textures: receives the index of the UV
  1241. * source channel. Unmodified otherwise.
  1242. * Pass NULL if you're not interested in this information.
  1243. * @param[out] blend Receives the blend factor for the texture
  1244. * Pass NULL if you're not interested in this information.
  1245. * @param[out] op Receives the texture blend operation to be perform between
  1246. * this texture and the previous texture.
  1247. * Pass NULL if you're not interested in this information.
  1248. * @param[out] mapmode Receives the mapping modes to be used for the texture.
  1249. * Pass NULL if you're not interested in this information. Otherwise,
  1250. * pass a pointer to an array of two aiTextureMapMode's (one for each
  1251. * axis, UV order).
  1252. * @return AI_SUCCESS on success, otherwise something else. Have fun.*/
  1253. // ---------------------------------------------------------------------------
  1254. #ifdef __cplusplus
  1255. ASSIMP_API aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
  1256. aiTextureType type,
  1257. unsigned int index,
  1258. aiString* path,
  1259. aiTextureMapping* mapping = NULL,
  1260. unsigned int* uvindex = NULL,
  1261. float* blend = NULL,
  1262. aiTextureOp* op = NULL,
  1263. aiTextureMapMode* mapmode = NULL,
  1264. unsigned int* flags = NULL);
  1265. #else
  1266. C_ENUM aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
  1267. C_ENUM aiTextureType type,
  1268. unsigned int index,
  1269. C_STRUCT aiString* path,
  1270. C_ENUM aiTextureMapping* mapping /*= NULL*/,
  1271. unsigned int* uvindex /*= NULL*/,
  1272. float* blend /*= NULL*/,
  1273. C_ENUM aiTextureOp* op /*= NULL*/,
  1274. C_ENUM aiTextureMapMode* mapmode /*= NULL*/,
  1275. unsigned int* flags /*= NULL*/);
  1276. #endif // !#ifdef __cplusplus
  1277. #ifdef __cplusplus
  1278. }
  1279. #include "material.inl"
  1280. #endif //!__cplusplus
  1281. #endif //!!AI_MATERIAL_H_INC