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