material.h 54 KB

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