material.h 51 KB

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