Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

642 rindas
19 KiB

  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2009, ASSIMP Development 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 Development 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. /**
  35. * Contains the material system which stores the imported material information.
  36. */
  37. module assimp.material;
  38. import assimp.math;
  39. import assimp.types;
  40. extern ( C ) {
  41. /**
  42. * Default material names for meshes without UV coordinates.
  43. */
  44. const char* AI_DEFAULT_MATERIAL_NAME = "aiDefaultMat";
  45. /**
  46. * Default material names for meshes with UV coordinates.
  47. */
  48. const char* AI_DEFAULT_TEXTURED_MATERIAL_NAME = "TexturedDefaultMaterial";
  49. /**
  50. * Defines how the Nth texture of a specific type is combined with the
  51. * result of all previous layers.
  52. *
  53. * Example (left: key, right: value):
  54. * <pre> DiffColor0 - gray
  55. * DiffTextureOp0 - aiTextureOpMultiply
  56. * DiffTexture0 - tex1.png
  57. * DiffTextureOp0 - aiTextureOpAdd
  58. * DiffTexture1 - tex2.png</pre>
  59. * Written as equation, the final diffuse term for a specific pixel would be:
  60. * <pre>diffFinal = DiffColor0 * sampleTex( DiffTexture0, UV0 ) +
  61. * sampleTex( DiffTexture1, UV0 ) * diffContrib;</pre>
  62. * where <code>diffContrib</code> is the intensity of the incoming light for
  63. * that pixel.
  64. */
  65. enum aiTextureOp : uint {
  66. /**
  67. * <code>T = T1 * T2</code>
  68. */
  69. Multiply = 0x0,
  70. /**
  71. * <code>T = T1 + T2</code>
  72. */
  73. Add = 0x1,
  74. /**
  75. * <code>T = T1 - T2</code>
  76. */
  77. Subtract = 0x2,
  78. /**
  79. * <code>T = T1 / T2</code>
  80. */
  81. Divide = 0x3,
  82. /**
  83. * <code>T = ( T1 + T2 ) - ( T1 * T2 )</code>
  84. */
  85. SmoothAdd = 0x4,
  86. /**
  87. * <code>T = T1 + ( T2 - 0.5 )</code>
  88. */
  89. SignedAdd = 0x5
  90. }
  91. /**
  92. * Defines how UV coordinates outside the <code>[0..1]</code> range are
  93. * handled.
  94. *
  95. * Commonly refered to as 'wrapping mode'.
  96. */
  97. enum aiTextureMapMode : uint {
  98. /**
  99. * A texture coordinate <code>u | v</code> is translated to
  100. * <code>(u%1) | (v%1)</code>.
  101. */
  102. Wrap = 0x0,
  103. /**
  104. * Texture coordinates are clamped to the nearest valid value.
  105. */
  106. Clamp = 0x1,
  107. /**
  108. * If the texture coordinates for a pixel are outside
  109. * <code>[0..1]</code>, the texture is not applied to that pixel.
  110. */
  111. Decal = 0x3,
  112. /**
  113. * A texture coordinate <code>u | v</code> becomes
  114. * <code>(u%1) | (v%1)</code> if <code>(u-(u%1))%2</code> is
  115. * zero and <code>(1-(u%1)) | (1-(v%1))</code> otherwise.
  116. */
  117. Mirror = 0x2
  118. }
  119. /**
  120. * Defines how the mapping coords for a texture are generated.
  121. *
  122. * Real-time applications typically require full UV coordinates, so the use of
  123. * the <code>aiProcess.GenUVCoords</code> step is highly recommended. It
  124. * generates proper UV channels for non-UV mapped objects, as long as an
  125. * accurate description how the mapping should look like (e.g spherical) is
  126. * given. See the <code>AI_MATKEY_MAPPING</code> property for more details.
  127. */
  128. enum aiTextureMapping : uint {
  129. /**
  130. * The mapping coordinates are taken from an UV channel.
  131. *
  132. * The <code>AI_MATKEY_UVSRC</code> key specifies from which (remember,
  133. * meshes can have more than one UV channel).
  134. */
  135. UV = 0x0,
  136. /**
  137. * Spherical mapping.
  138. */
  139. SPHERE = 0x1,
  140. /**
  141. * Cylindrical mapping.
  142. */
  143. CYLINDER = 0x2,
  144. /**
  145. * Cubic mapping.
  146. */
  147. BOX = 0x3,
  148. /**
  149. * Planar mapping.
  150. */
  151. PLANE = 0x4,
  152. /**
  153. * Undefined mapping.
  154. */
  155. OTHER = 0x5
  156. }
  157. /**
  158. * Defines the purpose of a texture
  159. *
  160. * This is a very difficult topic. Different 3D packages support different
  161. * kinds of textures. For very common texture types, such as bumpmaps, the
  162. * rendering results depend on implementation details in the rendering
  163. * pipelines of these applications. Assimp loads all texture references from
  164. * the model file and tries to determine which of the predefined texture
  165. * types below is the best choice to match the original use of the texture
  166. * as closely as possible.
  167. *
  168. * In content pipelines you'll usually define how textures have to be
  169. * handled, and the artists working on models have to conform to this
  170. * specification, regardless which 3D tool they're using.
  171. */
  172. enum aiTextureType : uint {
  173. /**
  174. * No texture, but the value to be used for
  175. * <code>aiMaterialProperty.mSemantic</code> for all material properties
  176. * <em>not</em> related to textures.
  177. */
  178. NONE = 0x0,
  179. /**
  180. * The texture is combined with the result of the diffuse lighting
  181. * equation.
  182. */
  183. DIFFUSE = 0x1,
  184. /**
  185. * The texture is combined with the result of the specular lighting
  186. * equation.
  187. */
  188. SPECULAR = 0x2,
  189. /**
  190. * The texture is combined with the result of the ambient lighting
  191. * equation.
  192. */
  193. AMBIENT = 0x3,
  194. /**
  195. * The texture is added to the result of the lighting calculation. It
  196. * isn't influenced by incoming light.
  197. */
  198. EMISSIVE = 0x4,
  199. /**
  200. * The texture is a height map.
  201. *
  202. * By convention, higher grey-scale values stand for higher elevations
  203. * from the base height.
  204. */
  205. HEIGHT = 0x5,
  206. /**
  207. * The texture is a (tangent space) normal-map.
  208. *
  209. * Again, there are several conventions for tangent-space normal maps.
  210. * Assimp does (intentionally) not differenciate here.
  211. */
  212. NORMALS = 0x6,
  213. /**
  214. * The texture defines the glossiness of the material.
  215. *
  216. * The glossiness is in fact the exponent of the specular (phong)
  217. * lighting equation. Usually there is a conversion function defined to
  218. * map the linear color values in the texture to a suitable exponent.
  219. */
  220. SHININESS = 0x7,
  221. /**
  222. * The texture defines per-pixel opacity.
  223. *
  224. * Usually white means opaque and black means transparent.
  225. */
  226. OPACITY = 0x8,
  227. /**
  228. * Displacement texture.
  229. *
  230. * The exact purpose and format is application-dependent. Higher color
  231. * values stand for higher vertex displacements.
  232. */
  233. DISPLACEMENT = 0x9,
  234. /**
  235. * Lightmap or ambient occlusion texture.
  236. *
  237. * Both lightmaps and dedicated ambient occlusion maps are covered by
  238. * this material property. The texture contains a scaling value for the
  239. * final color value of a pixel. Its intensity is not affected by
  240. * incoming light.
  241. */
  242. LIGHTMAP = 0xA,
  243. /**
  244. * Reflection texture.
  245. *
  246. * Contains the color of a perfect mirror reflection. Rarely used, almost
  247. * never for real-time applications.
  248. */
  249. REFLECTION = 0xB,
  250. /**
  251. * Unknown texture.
  252. *
  253. * A texture reference that does not match any of the definitions above is
  254. * considered to be 'unknown'. It is still imported, but is excluded from
  255. * any further postprocessing.
  256. */
  257. UNKNOWN = 0xC
  258. }
  259. /**
  260. * Defines all shading models supported by the library
  261. *
  262. * The list of shading modes has been taken from Blender. See Blender
  263. * documentation for more information. The API does not distinguish between
  264. * "specular" and "diffuse" shaders (thus the specular term for diffuse
  265. * shading models like Oren-Nayar remains undefined).
  266. *
  267. * Again, this value is just a hint. Assimp tries to select the shader whose
  268. * most common implementation matches the original rendering results of the
  269. * 3D modeller which wrote a particular model as closely as possible.
  270. */
  271. enum aiShadingMode : uint {
  272. /**
  273. * Flat shading.
  274. *
  275. * Shading is done on per-face base diffuse only. Also known as
  276. * »faceted shading«.
  277. */
  278. Flat = 0x1,
  279. /**
  280. * Simple Gouraud shading.
  281. */
  282. Gouraud = 0x2,
  283. /**
  284. * Phong-Shading.
  285. */
  286. Phong = 0x3,
  287. /**
  288. * Phong-Blinn-Shading.
  289. */
  290. Blinn = 0x4,
  291. /**
  292. * Per-pixel toon shading.
  293. *
  294. * Often referred to as »comic shading«.
  295. */
  296. Toon = 0x5,
  297. /**
  298. * Per-pixel Oren-Nayar shading.
  299. *
  300. * Extension to standard Lambertian shading, taking the roughness of the
  301. * material into account.
  302. */
  303. OrenNayar = 0x6,
  304. /**
  305. * Per-pixel Minnaert shading.
  306. *
  307. * Extension to standard Lambertian shading, taking the "darkness" of the
  308. * material into account.
  309. */
  310. Minnaert = 0x7,
  311. /**
  312. * Per-pixel Cook-Torrance shading.
  313. *
  314. * Special shader for metallic surfaces.
  315. */
  316. CookTorrance = 0x8,
  317. /**
  318. * No shading at all.
  319. *
  320. * Constant light influence of 1.
  321. */
  322. NoShading = 0x9,
  323. /**
  324. * Fresnel shading.
  325. */
  326. Fresnel = 0xa
  327. }
  328. /**
  329. * Defines some mixed flags for a particular texture.
  330. *
  331. * Usually you'll instruct your cg artists how textures have to look like
  332. * and how they will be processed in your application. However, if you use
  333. * Assimp for completely generic loading purposes you might also need to
  334. * process these flags in order to display as many 'unknown' 3D models as
  335. * possible correctly.
  336. *
  337. * This corresponds to the <code>AI_MATKEY_TEXFLAGS</code> property.
  338. */
  339. enum aiTextureFlags : uint {
  340. /**
  341. * The texture's color values have to be inverted (i.e. <code>1-n</code>
  342. * component-wise).
  343. */
  344. Invert = 0x1,
  345. /**
  346. * Explicit request to the application to process the alpha channel of the
  347. * texture.
  348. *
  349. * Mutually exclusive with <code>IgnoreAlpha</code>. These flags are
  350. * set if the library can say for sure that the alpha channel is used/is
  351. * not used. If the model format does not define this, it is left to the
  352. * application to decide whether the texture alpha channel – if any – is
  353. * evaluated or not.
  354. */
  355. UseAlpha = 0x2,
  356. /**
  357. * Explicit request to the application to ignore the alpha channel of the
  358. * texture.
  359. *
  360. * Mutually exclusive with <code>UseAlpha</code>.
  361. */
  362. IgnoreAlpha = 0x4
  363. }
  364. /**
  365. * Defines alpha-blend flags.
  366. *
  367. * If you're familiar with OpenGL or D3D, these flags aren't new to you.
  368. * They define how the final color value of a pixel is computed, based on
  369. * the previous color at that pixel and the new color value from the
  370. * material.
  371. *
  372. * The basic blending formula is
  373. * <code>SourceColor * SourceBlend + DestColor * DestBlend</code>,
  374. * where <code>DestColor</code> is the previous color in the framebuffer at
  375. * this position and <code>SourceColor</code> is the material color before
  376. * the transparency calculation.
  377. *
  378. * This corresponds to the <code>AI_MATKEY_BLEND_FUNC</code> property.
  379. */
  380. enum aiBlendMode :uint {
  381. /**
  382. * Formula:
  383. * <code>SourceColor * SourceAlpha + DestColor * (1 - SourceAlpha)</code>
  384. */
  385. Default = 0x0,
  386. /**
  387. * Additive blending.
  388. *
  389. * Formula: <code>SourceColor*1 + DestColor*1</code>
  390. */
  391. Additive = 0x1
  392. }
  393. /**
  394. * Defines how an UV channel is transformed.
  395. *
  396. * This is just a helper structure for the <code>AI_MATKEY_UVTRANSFORM</code>
  397. * key. See its documentation for more details.
  398. */
  399. struct aiUVTransform {
  400. align ( 1 ) :
  401. /**
  402. * Translation on the u and v axes.
  403. *
  404. * The default value is (0|0).
  405. */
  406. aiVector2D mTranslation;
  407. /**
  408. * Scaling on the u and v axes.
  409. *
  410. * The default value is (1|1).
  411. */
  412. aiVector2D mScaling;
  413. /**
  414. * Rotation - in counter-clockwise direction.
  415. *
  416. * The rotation angle is specified in radians. The rotation center is
  417. * 0.5|0.5. The default value is 0.
  418. */
  419. float mRotation;
  420. }
  421. /**
  422. * A very primitive RTTI system to store the data type of a material
  423. * property.
  424. */
  425. enum aiPropertyTypeInfo : uint {
  426. /**
  427. * Array of single-precision (32 bit) floats.
  428. *
  429. * It is possible to use <code>aiGetMaterialInteger[Array]()</code> to
  430. * query properties stored in floating-point format. The material system
  431. * performs the type conversion automatically.
  432. */
  433. Float = 0x1,
  434. /**
  435. * aiString property.
  436. *
  437. * Arrays of strings aren't possible, <code>aiGetMaterialString()</code>
  438. * must be used to query a string property.
  439. */
  440. String = 0x3,
  441. /**
  442. * Array of (32 bit) integers.
  443. *
  444. * It is possible to use <code>aiGetMaterialFloat[Array]()</code> to
  445. * query properties stored in integer format. The material system
  446. * performs the type conversion automatically.
  447. */
  448. Integer = 0x4,
  449. /**
  450. * Simple binary buffer, content undefined. Not convertible to anything.
  451. */
  452. Buffer = 0x5
  453. }
  454. /**
  455. * Data structure for a single material property.
  456. *
  457. * As an user, you'll probably never need to deal with this data structure.
  458. * Just use the provided <code>aiGetMaterialXXX()</code> functions to query
  459. * material properties easily. Processing them manually is faster, but it is
  460. * not the recommended way. It isn't worth the effort.
  461. *
  462. * Material property names follow a simple scheme:
  463. *
  464. * <code>$[name]</code>: A public property, there must be a corresponding
  465. * AI_MATKEY_XXX constant.
  466. *
  467. * <code>?[name]</code>: Also public, but ignored by the
  468. * <code>aiProcess.RemoveRedundantMaterials</code> post-processing step.
  469. *
  470. * <code>~[name]</code>: A temporary property for internal use.
  471. */
  472. struct aiMaterialProperty {
  473. /**
  474. * Specifies the name of the property (key).
  475. *
  476. * Keys are generally case insensitive.
  477. */
  478. aiString mKey;
  479. /**
  480. * For texture properties, this specifies the exact usage semantic.
  481. *
  482. * For non-texture properties, this member is always 0 (or rather
  483. * <code>aiTextureType.NONE</code>).
  484. */
  485. uint mSemantic;
  486. /**
  487. * For texture properties, this specifies the index of the texture.
  488. *
  489. * For non-texture properties, this member is always 0.
  490. */
  491. uint mIndex;
  492. /**
  493. * Size of the buffer <code>mData</code> is pointing to (in bytes).
  494. *
  495. * This value may not be 0.
  496. */
  497. uint mDataLength;
  498. /**
  499. * Type information for the property.
  500. *
  501. * Defines the data layout inside the data buffer. This is used by the
  502. * library internally to perform debug checks and to utilize proper type
  503. * conversions.
  504. */
  505. aiPropertyTypeInfo mType;
  506. /**
  507. * Binary buffer to hold the property's value.
  508. *
  509. * The size of the buffer is always <code>mDataLength</code>.
  510. */
  511. char* mData;
  512. }
  513. /**
  514. * Data structure for a material
  515. *
  516. * Material data is stored using a key-value structure. A single key-value
  517. * pair is called a <em>material property</em>. The properties can be
  518. * queried using the <code>aiMaterialGetXXX</code> family of functions. The
  519. * library defines a set of standard keys (AI_MATKEY_XXX).
  520. */
  521. struct aiMaterial {
  522. /**
  523. * List of all material properties loaded.
  524. */
  525. aiMaterialProperty** mProperties;
  526. /**
  527. * Number of properties loaded.
  528. */
  529. uint mNumProperties;
  530. uint mNumAllocated; /// ditto
  531. }
  532. /**
  533. * Standard material property keys. Always pass 0 for texture type and index
  534. * when querying these keys.
  535. */
  536. const char* AI_MATKEY_NAME = "?mat.name";
  537. const char* AI_MATKEY_TWOSIDED = "$mat.twosided"; /// ditto
  538. const char* AI_MATKEY_SHADING_MODEL = "$mat.shadingm"; /// ditto
  539. const char* AI_MATKEY_ENABLE_WIREFRAME = "$mat.wireframe"; /// ditto
  540. const char* AI_MATKEY_BLEND_FUNC = "$mat.blend"; /// ditto
  541. const char* AI_MATKEY_OPACITY = "$mat.opacity"; /// ditto
  542. const char* AI_MATKEY_BUMPSCALING = "$mat.bumpscaling"; /// ditto
  543. const char* AI_MATKEY_SHININESS = "$mat.shininess"; /// ditto
  544. const char* AI_MATKEY_REFLECTIVITY = "$mat.reflectivity"; /// ditto
  545. const char* AI_MATKEY_SHININESS_STRENGTH = "$mat.shinpercent"; /// ditto
  546. const char* AI_MATKEY_REFRACTI = "$mat.refracti"; /// ditto
  547. const char* AI_MATKEY_COLOR_DIFFUSE = "$clr.diffuse"; /// ditto
  548. const char* AI_MATKEY_COLOR_AMBIENT = "$clr.ambient"; /// ditto
  549. const char* AI_MATKEY_COLOR_SPECULAR = "$clr.specular"; /// ditto
  550. const char* AI_MATKEY_COLOR_EMISSIVE = "$clr.emissive"; /// ditto
  551. const char* AI_MATKEY_COLOR_TRANSPARENT = "$clr.transparent"; /// ditto
  552. const char* AI_MATKEY_COLOR_REFLECTIVE = "$clr.reflective"; /// ditto
  553. const char* AI_MATKEY_GLOBAL_BACKGROUND_IMAGE = "?bg.global"; /// ditto
  554. /**
  555. * Texture material property keys. Do not forget to specify texture type and
  556. * index for these keys.
  557. */
  558. const char* AI_MATKEY_TEXTURE = "$tex.file";
  559. const char* AI_MATKEY_UVWSRC = "$tex.uvwsrc"; /// ditto
  560. const char* AI_MATKEY_TEXOP = "$tex.op"; /// ditto
  561. const char* AI_MATKEY_MAPPING = "$tex.mapping"; /// ditto
  562. const char* AI_MATKEY_TEXBLEND = "$tex.blend"; /// ditto
  563. const char* AI_MATKEY_MAPPINGMODE_U = "$tex.mapmodeu"; /// ditto
  564. const char* AI_MATKEY_MAPPINGMODE_V = "$tex.mapmodev"; /// ditto
  565. const char* AI_MATKEY_TEXMAP_AXIS = "$tex.mapaxis"; /// ditto
  566. const char* AI_MATKEY_UVTRANSFORM = "$tex.uvtrafo"; /// ditto
  567. const char* AI_MATKEY_TEXFLAGS = "$tex.flags"; /// ditto
  568. }