fbxtexture.h 23 KB

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