1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxtexture.h
13#ifndef _FBXSDK_SCENE_SHADING_TEXTURE_H_
14#define _FBXSDK_SCENE_SHADING_TEXTURE_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/core/fbxobject.h>
19
20#include <fbxsdk/fbxsdk_nsbegin.h>
21
22/** This class is the base class for textures, ie classes FbxFileTexture, FbxLayeredTexture and FbxProceduralTexture.
23 * It describes image mapping on top of a geometry.
24 * \nosubgrouping
25 */
26class FBXSDK_DLL FbxTexture : public FbxObject
27{
28 FBXSDK_OBJECT_DECLARE(FbxTexture, FbxObject);
29
30public:
31 /**
32 * \name Texture Properties
33 */
34 //@{
35 /** \enum EUnifiedMappingType Internal enum for texture mapping types.
36 * Includes mapping types and planar mapping normal orientations.
37 * Use SetMappingType(), GetMappingType(), SetPlanarMappingNormal()
38 * and GetPlanarMappingNormal() to access these values.
39 */
40 enum EUnifiedMappingType
41 {
42 eUMT_UV, //! Maps to EMappingType::eUV.
43 eUMT_XY, //! Maps to EMappingType::ePlanar and EPlanarMappingNormal::ePlanarNormalZ.
44 eUMT_YZ, //! Maps to EMappingType::ePlanar and EPlanarMappingNormal::ePlanarNormalX.
45 eUMT_XZ, //! Maps to EMappingType::ePlanar and EPlanarMappingNormal::ePlanarNormalY.
46 eUMT_SPHERICAL, //! Maps to EMappingType::eSpherical.
47 eUMT_CYLINDRICAL, //! Maps to EMappingType::eCylindrical.
48 eUMT_ENVIRONMENT, //! Maps to EMappingType::eEnvironment.
49 eUMT_PROJECTION, //! Unused.
50 eUMT_BOX, //! DEPRECATED! Maps to EMappingType::eBox.
51 eUMT_FACE, //! DEPRECATED! Maps to EMappingType::eFace.
52 eUMT_NO_MAPPING, //! Maps to EMappingType::eNull.
53 };
54
55 /** \enum ETextureUse6 Internal enum for texture usage.
56 * For example, the texture might be used as a standard texture, as a shadow map, as a bump map, etc.
57 * Use SetTextureUse() and GetTextureUse() to access these values.
58 */
59 enum ETextureUse6
60 {
61 eTEXTURE_USE_6_STANDARD, //! Maps to ETextureUse::eStandard.
62 eTEXTURE_USE_6_SPHERICAL_REFLEXION_MAP, //! Maps to ETextureUse::eSphericalReflectionMap.
63 eTEXTURE_USE_6_SPHERE_REFLEXION_MAP, //! Maps to ETextureUse::eSphereReflectionMap.
64 eTEXTURE_USE_6_SHADOW_MAP, //! Maps to ETextureUse::eShadowMap.
65 eTEXTURE_USE_6_LIGHT_MAP, //! Maps to ETextureUse::eLightMap.
66 eTEXTURE_USE_6_BUMP_NORMAL_MAP //! Maps to ETextureUse::eBumpNormalMap.
67 };
68
69 /** \enum EWrapMode Wrap modes.
70 * Use SetWrapMode(), GetWrapModeU() and GetWrapModeV() to access these values.
71 */
72 enum EWrapMode
73 {
74 eRepeat, //! Apply the texture over and over on the model's surface until the model is covered. This is the default setting.
75 eClamp //! Apply the texture to a model only once, using the color at the ends of the texture as the "filter".
76 };
77
78 /** \enum EBlendMode Blend modes.
79 */
80 enum EBlendMode
81 {
82 eTranslucent, //! The texture is transparent, depending on the Alpha settings.
83 eAdditive, //! The color of the texture is added to the previous texture.
84 eModulate, //! The color value of the texture is multiplied by the color values of all previous layers of texture.
85 eModulate2, //! The color value of the texture is multiplied by two and then multiplied by the color values of all previous layers of texture.
86 eOver //! The texture is opaque.
87 };
88
89 /** \enum EAlignMode Align indices for cropping.
90 */
91 enum EAlignMode
92 {
93 eLeft, //! Left cropping.
94 eRight, //! Right cropping.
95 eTop, //! Top cropping.
96 eBottom //! Bottom cropping.
97 };
98
99 /** \enum ECoordinates Texture coordinates.
100 */
101 enum ECoordinates
102 {
103 eU, //! U axis.
104 eV, //! V axis.
105 eW //! W axis.
106 };
107
108 // Type description
109
110 /** This property handles the use of textures.
111 * Default value is eTEXTURE_USE_6_STANDARD.
112 */
113 FbxPropertyT<ETextureUse6> TextureTypeUse;
114
115 /** This property handles the default alpha value for textures.
116 * Default value is 1.0
117 */
118 FbxPropertyT<FbxDouble> Alpha;
119
120
121 // Mapping information
122
123 /** This property handles the texture mapping types.
124 * Default value is eUMT_UV.
125 */
126 FbxPropertyT<EUnifiedMappingType> CurrentMappingType;
127
128 /** This property handles the texture wrap modes in U.
129 * Default value is eRepeat.
130 */
131 FbxPropertyT<EWrapMode> WrapModeU;
132
133 /** This property handles the texture wrap modes in V.
134 * Default value is eRepeat.
135 */
136 FbxPropertyT<EWrapMode> WrapModeV;
137
138 /** This property handles the swap UV flag.
139 * If swap UV flag is enabled, the texture's width and height are swapped.
140 * Default value is false.
141 */
142 FbxPropertyT<FbxBool> UVSwap;
143
144 /** This property handles the PremultiplyAlpha flag.
145 * If PremultiplyAlpha flag is true, the R, G, and B components you store have already been multiplied in with the alpha.
146 * Default value is true.
147 */
148 FbxPropertyT<FbxBool> PremultiplyAlpha;
149
150 // Texture positioning
151
152 /** This property handles the default translation vector.
153 * Default value is FbxDouble3(0.0,0.0,0.0).
154 */
155 FbxPropertyT<FbxDouble3> Translation;
156
157 /** This property handles the default rotation vector.
158 * Default value is FbxDouble3(0.0,0.0,0.0).
159 */
160 FbxPropertyT<FbxDouble3> Rotation;
161
162 /** This property handles the default scale vector.
163 * Default value is FbxDouble3(1.0,1.0,1.0).
164 */
165 FbxPropertyT<FbxDouble3> Scaling;
166
167 /** This property handles the rotation pivot vector.
168 * Default value is FbxDouble3(0.0,0.0,0.0).
169 */
170 FbxPropertyT<FbxDouble3> RotationPivot;
171
172 /** This property handles the scaling pivot vector.
173 * Default value is FbxDouble3(0.0,0.0,0.0).
174 */
175 FbxPropertyT<FbxDouble3> ScalingPivot;
176
177 // Blend mode
178 /** This property handles the texture blend mode.
179 * Default value is eAdditive.
180 */
181 FbxPropertyT<EBlendMode> CurrentTextureBlendMode;
182
183 // UV set to use.
184 /** This property handles the use of UV sets.
185 * Default value is "default".
186 */
187 FbxPropertyT<FbxString> UVSet;
188
189 /** This property only used by Vector Displacement Texture so it is not added to FbxTexture.
190 * It is a dynamic enum property which has values : "World", "Object" and "Tangent"
191 * Default value is "Object".
192 */
193 static const char* sVectorSpace ;
194 static const char* sVectorSpaceWorld ;
195 static const char* sVectorSpaceObject ;
196 static const char* sVectorSpaceTangent ;
197
198 /** This property only used by Vector Displacement Texture so it is not added to FbxTexture.
199 * It is a dynamic enum property which has values : "Floating-point Absolute" and "Signed Encoding"
200 * Default value is "Floating-point Absolute".
201 */
202 static const char* sVectorEncoding ;
203 static const char* sVectorEncodingFP ;
204 static const char* sVectorEncodingSE ;
205
206
207 /** Resets the default texture values.
208 */
209 virtual void Reset();
210
211 /** Sets the swap UV flag.
212 * \param pSwapUV Set to \c true if the swap UV flag is enabled.
213 * \remarks If the swap UV flag is enabled, the texture's width and height are swapped.
214 */
215 void SetSwapUV(bool pSwapUV);
216
217 /** Returns the swap UV flag.
218 * \return \c True if the swap UV flag is enabled.
219 * \remarks If the swap UV flag is enabled, the texture's width and height are swapped.
220 */
221 bool GetSwapUV() const;
222
223 /** Sets the PremultiplyAlpha flag.
224 * \param pPremultiplyAlpha Set to \c true if the method of storing alpha is PremultiplyAlpha.
225 * \remarks If PremultiplyAlpha flag is true, the R, G, and B components you store have already been multiplied in with the alpha.
226 */
227 void SetPremultiplyAlpha(bool pPremultiplyAlpha);
228
229 /** Returns the PremultiplyAlpha flag.
230 * \return \c True if the method of storing alpha is PremultiplyAlpha.
231 * \remarks If PremultiplyAlpha flag is true, the R, G, and B components you store have already been multiplied in with the alpha.
232 */
233 bool GetPremultiplyAlpha() const;
234
235 /** \enum EAlphaSource Controls if the Alpha computation of the current texture comes from the Alpha channel, RGB Intensity channel, or if there is No Alpha.
236 */
237 enum EAlphaSource
238 {
239 eNone, //! No Alpha.
240 eRGBIntensity, //! RGB Intensity (computed).
241 eBlack //! Alpha channel. Black is 100% transparency, white is opaque.
242 };
243
244 /** Sets the alpha source.
245 * \param pAlphaSource The alpha source identifier.
246 */
247 void SetAlphaSource(EAlphaSource pAlphaSource);
248
249 /** Returns the alpha source.
250 * \return The alpha source identifier for this texture.
251 */
252 EAlphaSource GetAlphaSource() const;
253
254 /** Sets cropping.
255 * \param pLeft Left cropping value.
256 * \param pTop Top cropping value.
257 * \param pRight Right cropping value.
258 * \param pBottom Bottom cropping value.
259 * \remarks The defined rectangle is not checked for invalid values.
260 * The caller must verify that the rectangle
261 * is meaningful for this texture.
262 */
263 void SetCropping(int pLeft, int pTop, int pRight, int pBottom);
264
265 /** Returns left cropping.
266 * \return The left side of the cropping rectangle.
267 */
268 int GetCroppingLeft() const;
269
270 /** Returns top cropping.
271 * \return The top side of the cropping rectangle.
272 */
273 int GetCroppingTop() const;
274
275 /** Returns right cropping.
276 * \return The right side of the cropping rectangle.
277 */
278 int GetCroppingRight() const;
279
280 /** Returns bottom cropping.
281 * \return The bottom side of the cropping rectangle.
282 */
283 int GetCroppingBottom() const;
284
285 /** \enum EMappingType Texture mapping types.
286 */
287 enum EMappingType
288 {
289 eNull, //! No texture mapping defined.
290 ePlanar, //! Apply texture to the model viewed as a plane.
291 eSpherical, //! Wrap texture around the model as if it was a sphere.
292 eCylindrical, //! Wrap texture around the model as if it was a cylinder.
293 eBox, //! Wrap texture around the model as if it was a box.
294 eFace, //! Apply texture to the model viewed as a face.
295 eUV, //! Apply texture to the model according to UVs.
296 eEnvironment //! Texture is an environment map.
297 };
298
299 /** Sets the mapping type.
300 * \param pMappingType The mapping type identifier.
301 */
302 void SetMappingType(EMappingType pMappingType);
303
304 /** Returns the mapping type.
305 * \return The mapping type identifier.
306 */
307 EMappingType GetMappingType() const;
308
309 /** \enum EPlanarMappingNormal Planar mapping normal orientations.
310 */
311 enum EPlanarMappingNormal
312 {
313 ePlanarNormalX, //! Normals are in the direction of the X axis, mapping plan is in the YZ axis.
314 ePlanarNormalY, //! Normals are in the direction of the Y axis, mapping plan is in the XZ axis.
315 ePlanarNormalZ //! Normals are in the direction of the Z axis, mapping plan is in the XY axis.
316 };
317
318 /** Sets the normal orientations for planar mapping.
319 * \param pPlanarMappingNormal The identifier for planar mapping normal orientation.
320 */
321 void SetPlanarMappingNormal(EPlanarMappingNormal pPlanarMappingNormal);
322
323 /** Returns the normal orientations for planar mapping.
324 * \return The identifier for planar mapping normal orientation.
325 */
326 EPlanarMappingNormal GetPlanarMappingNormal() const;
327
328 /** \enum ETextureUse Texture uses.
329 */
330 enum ETextureUse
331 {
332 eStandard, //! Standard texture use (ex. image)
333 eShadowMap, //! Shadow map
334 eLightMap, //! Light map
335 eSphericalReflectionMap, //! Spherical reflection map: Object reflects the contents of the scene
336 eSphereReflectionMap, //! Sphere reflection map: Object reflects the contents of the scene from only one point of view
337 eBumpNormalMap //! Bump map: Texture contains two direction vectors, that are used to convey relief in a texture.
338 };
339
340 /** Sets the texture use.
341 * \param pTextureUse The texture use identifier.
342 */
343 void SetTextureUse(ETextureUse pTextureUse);
344
345 /** Returns the texture use.
346 * \return The texture use identifier.
347 */
348 ETextureUse GetTextureUse() const;
349
350
351 /** Sets the U and V wrap mode.
352 * \param pWrapU Wrap mode identifier.
353 * \param pWrapV Wrap mode identifier.
354 */
355 void SetWrapMode(EWrapMode pWrapU, EWrapMode pWrapV);
356
357 /** Returns the U wrap mode.
358 * \return U wrap mode identifier.
359 */
360 EWrapMode GetWrapModeU() const;
361
362 /** Returns the V wrap mode.
363 * \return V wrap mode identifier.
364 */
365 EWrapMode GetWrapModeV() const;
366
367
368 /** Sets the blend mode.
369 * \param pBlendMode Blend mode identifier.
370 */
371 void SetBlendMode(EBlendMode pBlendMode);
372
373 /** Returns the blend mode.
374 * \return Blend mode identifier.
375 */
376 EBlendMode GetBlendMode() const;
377
378 //@}
379
380 /**
381 * \name Default Values Management By Vectors
382 * This set of functions provides direct access to the default values in vector base.
383 */
384 //@{
385
386 /** Sets the default translation vector.
387 * \param pT The first element is the U translation applied to
388 * the texture. A displacement of one unit is equal to the texture
389 * width after the U scaling is applied. The second element is the
390 * V translation applied to the texture. A displacement of one unit is
391 * equal to the texture height after the V scaling is applied.
392 * The third and fourth elements have no effect on texture
393 * translation.
394 */
395 inline void SetDefaultT(const FbxVector4& pT) { Translation.Set( pT ); }
396
397 /** Returns the default translation vector.
398 * \param pT The first element is the U translation applied to
399 * the texture. A displacement of one unit is equal to the texture
400 * width after the U scaling is applied. The second element is the
401 * V translation applied to the texture. A displacement of one unit is
402 * equal to the texture height after the V scaling is applied.
403 * The third and fourth elements have no effect on texture
404 * translation.
405 * \return The input parameter completed with appropriate data.
406 */
407 FbxVector4& GetDefaultT(FbxVector4& pT) const;
408
409 /** Sets the default rotation vector.
410 * \param pR The first element is the texture rotation around the
411 * U axis in degrees. The second element is the texture rotation
412 * around the V axis in degrees. The third element is the texture
413 * rotation around the W axis in degrees.
414 * \remarks The W axis is oriented toward the result of the
415 * vector product of the U and V axes that is W = U x V.
416 */
417 inline void SetDefaultR(const FbxVector4& pR) { Rotation.Set( FbxDouble3(pR[0],pR[1],pR[2]) ); }
418
419 /** Returns the default rotation vector.
420 * \param pR First element is the texture rotation around the
421 * U axis in degrees. Second element is the texture rotation
422 * around the V axis in degrees. Third element is the texture
423 * rotation around the W axis in degrees.
424 * \return Input parameter filled with appropriate data.
425 * \remarks The W axis is oriented towards the result of the
426 * vector product of the U axis and V axis i.e. W = U x V.
427 */
428 FbxVector4& GetDefaultR(FbxVector4& pR) const;
429
430 /** Sets the default scale vector.
431 * \param pS The first element is scale applied to the texture width.
432 * The second element is scale applied to the texture height. The third
433 * and fourth elements have no effect on the texture.
434 * \remarks A scale value less than 1 stretches the texture.
435 * A scale value greater than 1 compresses the texture.
436 */
437 inline void SetDefaultS(const FbxVector4& pS) { Scaling.Set( FbxDouble3(pS[0],pS[1],pS[2]) ); }
438
439 /** Returns the default scale vector.
440 * \param pS The first element is scale applied to the texture width.
441 * The second element is scale applied to the texture height. The third
442 * and fourth elements have no effect on the texture.
443 * \remarks A scale value less than 1 stretches the texture.
444 * A scale value greater than 1 compresses the texture.
445 */
446 FbxVector4& GetDefaultS(FbxVector4& pS) const;
447
448 //@}
449
450 /**
451 * \name Default Alpha Value
452 */
453 //@{
454
455 /** Sets the default alpha.
456 * \param pAlpha A value on a scale from 0 to 1, with 0 being transparent.
457 */
458 void SetDefaultAlpha(double pAlpha);
459
460 /** Returns the default alpha.
461 * \return A value on a scale from 0 to 1, with 0 being transparent.
462 */
463 double GetDefaultAlpha() const;
464
465 //@}
466
467 /**
468 * \name Default Values Management By Numbers
469 * This set of functions provides direct access to the default values in number base.
470 * U, V and W coordinates are mapped to the X, Y and Z coordinates of the default vectors
471 * found in the "Default Values By Vector" section.
472 */
473 //@{
474
475 /** Sets translation.
476 * \param pU Horizontal translation applied to a texture. A displacement
477 * of one unit is equal to the texture's width after applying U scaling.
478 * \param pV Vertical translation applied to a texture. A displacement
479 * of one unit is equal to the texture's height after applying V scaling.
480 */
481 void SetTranslation(double pU,double pV);
482
483 /** Returns translation applied to the texture width.
484 * \remarks A displacement of one unit is equal to the texture's width
485 * after applying U scaling.
486 */
487 double GetTranslationU() const;
488
489 /** Returns translation applied to the texture height.
490 * \remarks A displacement of one unit is equal to the texture's height
491 * after applying V scaling.
492 */
493 double GetTranslationV() const;
494
495 /** Sets rotation.
496 * \param pU Texture rotation around the U axis in degrees.
497 * \param pV Texture rotation around the V axis in degrees.
498 * \param pW Texture rotation around the W axis in degrees.
499 * \remarks The W axis is oriented toward the result of the vector product of
500 * the U and V axes that is W = U x V.
501 */
502 void SetRotation(double pU, double pV, double pW = 0.0);
503
504 //! Returns the texture rotation around the U axis in degrees.
505 double GetRotationU() const;
506
507 //! Returns the texture rotation around the V axis in degrees.
508 double GetRotationV() const;
509
510 //! Returns the texture rotation around the W axis in degrees.
511 double GetRotationW() const;
512
513 /** Sets scale.
514 * \param pU Scale applied to the texture width.
515 * \param pV Scale applied to the texture height.
516 * \remarks A scale value less than 1 stretches the texture.
517 * A scale value greater than 1 compresses the texture.
518 */
519 void SetScale(double pU,double pV);
520
521 /** Returns scale applied to the texture width.
522 * \remarks A scale value less than 1 stretches the texture.
523 * A scale value greater than 1 compresses the texture.
524 */
525 double GetScaleU() const;
526
527 /** Returns scale applied to the texture height.
528 * \remarks A scale value less than 1 stretches the texture.
529 * A scale value greater than 1 compresses the texture.
530 */
531 double GetScaleV() const;
532 //@}
533
534/*****************************************************************************************************************************
535** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
536*****************************************************************************************************************************/
537#ifndef DOXYGEN_SHOULD_SKIP_THIS
538 virtual FbxObject& Copy(const FbxObject& pObject);
539
540 bool operator==(FbxTexture const& pTexture) const;
541
542 void SetUVTranslation(FbxVector2& pT);
543 FbxVector2& GetUVTranslation();
544 void SetUVScaling(FbxVector2& pS);
545 FbxVector2& GetUVScaling();
546
547 FbxString GetTextureType();
548
549protected:
550 virtual void Construct(const FbxObject* pFrom);
551 virtual void ConstructProperties(bool pForceSet);
552
553 virtual bool PropertyNotify(EPropertyNotifyType pType, FbxProperty& pProperty);
554
555 void Init();
556
557 int mCropping[4]; // not a prop
558
559 EAlphaSource mAlphaSource; // now unused in MB (always set to None); not a prop
560 EMappingType mMappingType; // CurrentMappingType
561 EPlanarMappingNormal mPlanarMappingNormal; // CurrentMappingType
562
563 // Unsupported parameters in the FBX SDK, these are declared but not accessible.
564 // They are used to keep imported and exported data identical.
565 FbxVector2 mUVScaling; // not a prop
566 FbxVector2 mUVTranslation; // not a prop
567#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
568};
569
570inline EFbxType FbxTypeOf(const FbxTexture::EUnifiedMappingType&){ return eFbxEnum; }
571inline EFbxType FbxTypeOf(const FbxTexture::ETextureUse6&){ return eFbxEnum; }
572inline EFbxType FbxTypeOf(const FbxTexture::EWrapMode&){ return eFbxEnum; }
573inline EFbxType FbxTypeOf(const FbxTexture::EBlendMode&){ return eFbxEnum; }
574
575#include <fbxsdk/fbxsdk_nsend.h>
576
577#endif /* _FBXSDK_SCENE_SHADING_TEXTURE_H_ */
578