material.h 54 KB

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