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