material.h 52 KB

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