1 // Copyright (c) 2013-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Graphic3d_TextureParams_HeaderFile
15 #define _Graphic3d_TextureParams_HeaderFile
17 #include <Graphic3d_LevelOfTextureAnisotropy.hxx>
18 #include <Graphic3d_Vec2.hxx>
19 #include <Graphic3d_Vec4.hxx>
20 #include <Graphic3d_TextureUnit.hxx>
21 #include <Graphic3d_TypeOfTextureFilter.hxx>
22 #include <Graphic3d_TypeOfTextureMode.hxx>
23 #include <Standard.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_ShortReal.hxx>
26 #include <Standard_Type.hxx>
27 #include <Standard_Transient.hxx>
29 //! This class describes texture parameters.
30 class Graphic3d_TextureParams : public Standard_Transient
32 DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureParams, Standard_Transient)
35 //! Default constructor.
36 Standard_EXPORT Graphic3d_TextureParams();
39 Standard_EXPORT virtual ~Graphic3d_TextureParams();
41 //! Default texture unit to be used, default is Graphic3d_TextureUnit_BaseColor.
42 Graphic3d_TextureUnit TextureUnit() const { return myTextureUnit; }
44 //! Setup default texture unit.
45 void SetTextureUnit (Graphic3d_TextureUnit theUnit) { myTextureUnit = theUnit; }
47 //! @return TRUE if the texture is modulate.
48 //! Default value is FALSE.
49 Standard_Boolean IsModulate() const { return myToModulate; }
51 //! @param theToModulate turn modulation on/off.
52 Standard_EXPORT void SetModulate (const Standard_Boolean theToModulate);
54 //! @return TRUE if the texture repeat is enabled.
55 //! Default value is FALSE.
56 Standard_Boolean IsRepeat() const { return myToRepeat; }
58 //! @param theToRepeat turn texture repeat mode ON or OFF (clamping).
59 Standard_EXPORT void SetRepeat (const Standard_Boolean theToRepeat);
61 //! @return texture interpolation filter.
62 //! Default value is Graphic3d_TOTF_NEAREST.
63 Graphic3d_TypeOfTextureFilter Filter() const { return myFilter; }
65 //! @param theFilter texture interpolation filter.
66 Standard_EXPORT void SetFilter (const Graphic3d_TypeOfTextureFilter theFilter);
68 //! @return level of anisontropy texture filter.
69 //! Default value is Graphic3d_LOTA_OFF.
70 Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const { return myAnisoLevel; }
72 //! @param theLevel level of anisontropy texture filter.
73 Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
75 //! @return rotation angle in degrees
76 //! Default value is 0.
77 Standard_ShortReal Rotation() const { return myRotAngle; }
79 //! @param theAngleDegrees rotation angle.
80 Standard_EXPORT void SetRotation (const Standard_ShortReal theAngleDegrees);
82 //! @return scale factor
83 //! Default value is no scaling (1.0; 1.0).
84 const Graphic3d_Vec2& Scale() const { return myScale; }
86 //! @param theScale scale factor.
87 Standard_EXPORT void SetScale (const Graphic3d_Vec2 theScale);
89 //! @return translation vector
90 //! Default value is no translation (0.0; 0.0).
91 const Graphic3d_Vec2& Translation() const { return myTranslation; }
93 //! @param theVec translation vector.
94 Standard_EXPORT void SetTranslation (const Graphic3d_Vec2 theVec);
96 //! @return texture coordinates generation mode.
97 //! Default value is Graphic3d_TOTM_MANUAL.
98 Graphic3d_TypeOfTextureMode GenMode() const { return myGenMode; }
100 //! @return texture coordinates generation plane S.
101 const Graphic3d_Vec4& GenPlaneS() const { return myGenPlaneS; }
103 //! @return texture coordinates generation plane T.
104 const Graphic3d_Vec4& GenPlaneT() const { return myGenPlaneT; }
106 //! Setup texture coordinates generation mode.
107 Standard_EXPORT void SetGenMode (const Graphic3d_TypeOfTextureMode theMode, const Graphic3d_Vec4 thePlaneS, const Graphic3d_Vec4 thePlaneT);
109 //! @return base texture mipmap level; 0 by default.
110 Standard_Integer BaseLevel() const { return myBaseLevel; }
112 //! @return maximum texture mipmap array level; 1000 by default.
113 Standard_Integer MaxLevel() const { return myMaxLevel; }
115 //! Setups texture mipmap array levels range.
116 //! The lowest value will be the base level.
117 //! The remaining one will be the maximum level.
118 void SetLevelsRange (Standard_Integer theFirstLevel, Standard_Integer theSecondLevel = 0)
120 myMaxLevel = theFirstLevel > theSecondLevel ? theFirstLevel : theSecondLevel;
121 myBaseLevel = theFirstLevel > theSecondLevel ? theSecondLevel : theFirstLevel;
124 //! Return modification counter of parameters related to sampler state.
125 unsigned int SamplerRevision() const { return mySamplerRevision; }
129 //! Increment revision.
130 void updateSamplerRevision() { ++mySamplerRevision; }
134 Graphic3d_Vec4 myGenPlaneS; //!< texture coordinates generation plane S
135 Graphic3d_Vec4 myGenPlaneT; //!< texture coordinates generation plane T
136 Graphic3d_Vec2 myScale; //!< texture coordinates scale factor vector; (1,1) by default
137 Graphic3d_Vec2 myTranslation; //!< texture coordinates translation vector; (0,0) by default
138 unsigned int mySamplerRevision; //!< modification counter of parameters related to sampler state
139 Graphic3d_TextureUnit myTextureUnit; //!< default texture unit to bind texture; Graphic3d_TextureUnit_BaseColor by default
140 Graphic3d_TypeOfTextureFilter myFilter; //!< texture filter, Graphic3d_TOTF_NEAREST by default
141 Graphic3d_LevelOfTextureAnisotropy myAnisoLevel; //!< level of anisotropy filter, Graphic3d_LOTA_OFF by default
142 Graphic3d_TypeOfTextureMode myGenMode; //!< texture coordinates generation mode, Graphic3d_TOTM_MANUAL by default
143 Standard_Integer myBaseLevel; //!< base texture mipmap level (0 by default)
144 Standard_Integer myMaxLevel; //!< maximum texture mipmap array level (1000 by default)
145 Standard_ShortReal myRotAngle; //!< texture coordinates rotation angle in degrees, 0 by default
146 Standard_Boolean myToModulate; //!< flag to modulate texture with material color, FALSE by default
147 Standard_Boolean myToRepeat; //!< flag to repeat (true) or wrap (false) texture coordinates out of [0,1] range
151 DEFINE_STANDARD_HANDLE(Graphic3d_TextureParams, Standard_Transient)
153 #endif // _Graphic3d_TextureParams_HeaderFile