Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-03 08:33:04

0001 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Graphic3d_TextureParams_HeaderFile
0015 #define _Graphic3d_TextureParams_HeaderFile
0016 
0017 #include <Graphic3d_LevelOfTextureAnisotropy.hxx>
0018 #include <Graphic3d_Vec2.hxx>
0019 #include <Graphic3d_Vec4.hxx>
0020 #include <Graphic3d_TextureUnit.hxx>
0021 #include <Graphic3d_TypeOfTextureFilter.hxx>
0022 #include <Graphic3d_TypeOfTextureMode.hxx>
0023 #include <Standard.hxx>
0024 #include <Standard_ShortReal.hxx>
0025 #include <Standard_Type.hxx>
0026 #include <Standard_Transient.hxx>
0027 
0028 //! This class describes texture parameters.
0029 class Graphic3d_TextureParams : public Standard_Transient
0030 {
0031   DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureParams, Standard_Transient)
0032 public:
0033   //! Default constructor.
0034   Standard_EXPORT Graphic3d_TextureParams();
0035 
0036   //! Destructor.
0037   Standard_EXPORT virtual ~Graphic3d_TextureParams();
0038 
0039   //! Default texture unit to be used, default is Graphic3d_TextureUnit_BaseColor.
0040   Graphic3d_TextureUnit TextureUnit() const { return myTextureUnit; }
0041 
0042   //! Setup default texture unit.
0043   void SetTextureUnit(Graphic3d_TextureUnit theUnit) { myTextureUnit = theUnit; }
0044 
0045   //! @return TRUE if the texture is modulate.
0046   //! Default value is FALSE.
0047   Standard_Boolean IsModulate() const { return myToModulate; }
0048 
0049   //! @param theToModulate turn modulation on/off.
0050   Standard_EXPORT void SetModulate(const Standard_Boolean theToModulate);
0051 
0052   //! @return TRUE if the texture repeat is enabled.
0053   //! Default value is FALSE.
0054   Standard_Boolean IsRepeat() const { return myToRepeat; }
0055 
0056   //! @param theToRepeat turn texture repeat mode ON or OFF (clamping).
0057   Standard_EXPORT void SetRepeat(const Standard_Boolean theToRepeat);
0058 
0059   //! @return texture interpolation filter.
0060   //! Default value is Graphic3d_TOTF_NEAREST.
0061   Graphic3d_TypeOfTextureFilter Filter() const { return myFilter; }
0062 
0063   //! @param theFilter texture interpolation filter.
0064   Standard_EXPORT void SetFilter(const Graphic3d_TypeOfTextureFilter theFilter);
0065 
0066   //! @return level of anisontropy texture filter.
0067   //! Default value is Graphic3d_LOTA_OFF.
0068   Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const { return myAnisoLevel; }
0069 
0070   //! @param theLevel level of anisontropy texture filter.
0071   Standard_EXPORT void SetAnisoFilter(const Graphic3d_LevelOfTextureAnisotropy theLevel);
0072 
0073   //! Return rotation angle in degrees; 0 by default.
0074   //! Complete transformation matrix: Rotation -> Translation -> Scale.
0075   Standard_ShortReal Rotation() const { return myRotAngle; }
0076 
0077   //! @param theAngleDegrees rotation angle.
0078   Standard_EXPORT void SetRotation(const Standard_ShortReal theAngleDegrees);
0079 
0080   //! Return scale factor; (1.0; 1.0) by default, which means no scaling.
0081   //! Complete transformation matrix: Rotation -> Translation -> Scale.
0082   const Graphic3d_Vec2& Scale() const { return myScale; }
0083 
0084   //! @param theScale scale factor.
0085   Standard_EXPORT void SetScale(const Graphic3d_Vec2 theScale);
0086 
0087   //! Return translation vector; (0.0; 0.0), which means no translation.
0088   //! Complete transformation matrix: Rotation -> Translation -> Scale.
0089   const Graphic3d_Vec2& Translation() const { return myTranslation; }
0090 
0091   //! @param theVec translation vector.
0092   Standard_EXPORT void SetTranslation(const Graphic3d_Vec2 theVec);
0093 
0094   //! @return texture coordinates generation mode.
0095   //! Default value is Graphic3d_TOTM_MANUAL.
0096   Graphic3d_TypeOfTextureMode GenMode() const { return myGenMode; }
0097 
0098   //! @return texture coordinates generation plane S.
0099   const Graphic3d_Vec4& GenPlaneS() const { return myGenPlaneS; }
0100 
0101   //! @return texture coordinates generation plane T.
0102   const Graphic3d_Vec4& GenPlaneT() const { return myGenPlaneT; }
0103 
0104   //! Setup texture coordinates generation mode.
0105   Standard_EXPORT void SetGenMode(const Graphic3d_TypeOfTextureMode theMode,
0106                                   const Graphic3d_Vec4              thePlaneS,
0107                                   const Graphic3d_Vec4              thePlaneT);
0108 
0109   //! @return base texture mipmap level; 0 by default.
0110   Standard_Integer BaseLevel() const { return myBaseLevel; }
0111 
0112   //! Return maximum texture mipmap array level; 1000 by default.
0113   //! Real rendering limit will take into account mipmap generation flags and presence of mipmaps in
0114   //! loaded image.
0115   Standard_Integer MaxLevel() const { return myMaxLevel; }
0116 
0117   //! Setups texture mipmap array levels range.
0118   //! The lowest value will be the base level.
0119   //! The remaining one will be the maximum level.
0120   void SetLevelsRange(Standard_Integer theFirstLevel, Standard_Integer theSecondLevel = 0)
0121   {
0122     myMaxLevel  = theFirstLevel > theSecondLevel ? theFirstLevel : theSecondLevel;
0123     myBaseLevel = theFirstLevel > theSecondLevel ? theSecondLevel : theFirstLevel;
0124   }
0125 
0126   //! Return modification counter of parameters related to sampler state.
0127   unsigned int SamplerRevision() const { return mySamplerRevision; }
0128 
0129 private:
0130   //! Increment revision.
0131   void updateSamplerRevision() { ++mySamplerRevision; }
0132 
0133 private:
0134   // clang-format off
0135   Graphic3d_Vec4                     myGenPlaneS;       //!< texture coordinates generation plane S
0136   Graphic3d_Vec4                     myGenPlaneT;       //!< texture coordinates generation plane T
0137   Graphic3d_Vec2                     myScale;           //!< texture coordinates scale factor vector; (1,1) by default
0138   Graphic3d_Vec2                     myTranslation;     //!< texture coordinates translation vector;  (0,0) by default
0139   unsigned int                       mySamplerRevision; //!< modification counter of parameters related to sampler state
0140   Graphic3d_TextureUnit              myTextureUnit;     //!< default texture unit to bind texture; Graphic3d_TextureUnit_BaseColor by default
0141   Graphic3d_TypeOfTextureFilter      myFilter;          //!< texture filter, Graphic3d_TOTF_NEAREST by default
0142   Graphic3d_LevelOfTextureAnisotropy myAnisoLevel;      //!< level of anisotropy filter, Graphic3d_LOTA_OFF by default
0143   Graphic3d_TypeOfTextureMode        myGenMode;         //!< texture coordinates generation mode, Graphic3d_TOTM_MANUAL by default
0144   Standard_Integer                   myBaseLevel;       //!< base texture mipmap level (0 by default)
0145   Standard_Integer                   myMaxLevel;        //!< maximum texture mipmap array level (1000 by default)
0146   Standard_ShortReal                 myRotAngle;        //!< texture coordinates rotation angle in degrees, 0 by default
0147   Standard_Boolean                   myToModulate;      //!< flag to modulate texture with material color, FALSE by default
0148   Standard_Boolean                   myToRepeat;        //!< flag to repeat (true) or wrap (false) texture coordinates out of [0,1] range
0149   // clang-format on
0150 };
0151 
0152 DEFINE_STANDARD_HANDLE(Graphic3d_TextureParams, Standard_Transient)
0153 
0154 #endif // _Graphic3d_TextureParams_HeaderFile