Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Graphic3d_TextureParams.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 
0034   //! Default constructor.
0035   Standard_EXPORT Graphic3d_TextureParams();
0036 
0037   //! Destructor.
0038   Standard_EXPORT virtual ~Graphic3d_TextureParams();
0039 
0040   //! Default texture unit to be used, default is Graphic3d_TextureUnit_BaseColor.
0041   Graphic3d_TextureUnit TextureUnit() const { return myTextureUnit; }
0042 
0043   //! Setup default texture unit.
0044   void SetTextureUnit (Graphic3d_TextureUnit theUnit) { myTextureUnit = theUnit; }
0045 
0046   //! @return TRUE if the texture is modulate.
0047   //! Default value is FALSE.
0048   Standard_Boolean IsModulate() const { return myToModulate; }
0049   
0050   //! @param theToModulate turn modulation on/off.
0051   Standard_EXPORT void SetModulate (const Standard_Boolean theToModulate);
0052   
0053   //! @return TRUE if the texture repeat is enabled.
0054   //! Default value is FALSE.
0055   Standard_Boolean IsRepeat() const { return myToRepeat; }
0056   
0057   //! @param theToRepeat turn texture repeat mode ON or OFF (clamping).
0058   Standard_EXPORT void SetRepeat (const Standard_Boolean theToRepeat);
0059   
0060   //! @return texture interpolation filter.
0061   //! Default value is Graphic3d_TOTF_NEAREST.
0062   Graphic3d_TypeOfTextureFilter Filter() const { return myFilter; }
0063   
0064   //! @param theFilter texture interpolation filter.
0065   Standard_EXPORT void SetFilter (const Graphic3d_TypeOfTextureFilter theFilter);
0066   
0067   //! @return level of anisontropy texture filter.
0068   //! Default value is Graphic3d_LOTA_OFF.
0069   Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const { return myAnisoLevel; }
0070   
0071   //! @param theLevel level of anisontropy texture filter.
0072   Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
0073   
0074   //! Return rotation angle in degrees; 0 by default.
0075   //! Complete transformation matrix: Rotation -> Translation -> Scale.
0076   Standard_ShortReal Rotation() const { return myRotAngle; }
0077   
0078   //! @param theAngleDegrees rotation angle.
0079   Standard_EXPORT void SetRotation (const Standard_ShortReal theAngleDegrees);
0080   
0081   //! Return scale factor; (1.0; 1.0) by default, which means no scaling.
0082   //! Complete transformation matrix: Rotation -> Translation -> Scale.
0083   const Graphic3d_Vec2& Scale() const { return myScale; }
0084   
0085   //! @param theScale scale factor.
0086   Standard_EXPORT void SetScale (const Graphic3d_Vec2 theScale);
0087 
0088   //! Return translation vector; (0.0; 0.0), which means no translation.
0089   //! Complete transformation matrix: Rotation -> Translation -> Scale.
0090   const Graphic3d_Vec2& Translation() const { return myTranslation; }
0091   
0092   //! @param theVec translation vector.
0093   Standard_EXPORT void SetTranslation (const Graphic3d_Vec2 theVec);
0094   
0095   //! @return texture coordinates generation mode.
0096   //! Default value is Graphic3d_TOTM_MANUAL.
0097   Graphic3d_TypeOfTextureMode GenMode() const { return myGenMode; }
0098   
0099   //! @return texture coordinates generation plane S.
0100   const Graphic3d_Vec4& GenPlaneS() const { return myGenPlaneS; }
0101   
0102   //! @return texture coordinates generation plane T.
0103   const Graphic3d_Vec4& GenPlaneT() const { return myGenPlaneT; }
0104   
0105   //! Setup texture coordinates generation mode.
0106   Standard_EXPORT void SetGenMode (const Graphic3d_TypeOfTextureMode theMode, const Graphic3d_Vec4 thePlaneS, const Graphic3d_Vec4 thePlaneT);
0107 
0108   //! @return base texture mipmap level; 0 by default.
0109   Standard_Integer BaseLevel() const { return myBaseLevel; }
0110 
0111   //! Return maximum texture mipmap array level; 1000 by default.
0112   //! Real rendering limit will take into account mipmap generation flags and presence of mipmaps in loaded image.
0113   Standard_Integer MaxLevel() const { return myMaxLevel; }
0114 
0115   //! Setups texture mipmap array levels range.
0116   //! The lowest value will be the base level.
0117   //! The remaining one will be the maximum level.
0118   void SetLevelsRange (Standard_Integer theFirstLevel, Standard_Integer theSecondLevel = 0)
0119   {
0120     myMaxLevel  = theFirstLevel > theSecondLevel ? theFirstLevel : theSecondLevel;
0121     myBaseLevel = theFirstLevel > theSecondLevel ? theSecondLevel : theFirstLevel;
0122   }
0123 
0124   //! Return modification counter of parameters related to sampler state.
0125   unsigned int SamplerRevision() const { return mySamplerRevision; }
0126 
0127 private:
0128 
0129   //! Increment revision.
0130   void updateSamplerRevision() { ++mySamplerRevision; }
0131 
0132 private:
0133 
0134   Graphic3d_Vec4                     myGenPlaneS;       //!< texture coordinates generation plane S
0135   Graphic3d_Vec4                     myGenPlaneT;       //!< texture coordinates generation plane T
0136   Graphic3d_Vec2                     myScale;           //!< texture coordinates scale factor vector; (1,1) by default
0137   Graphic3d_Vec2                     myTranslation;     //!< texture coordinates translation vector;  (0,0) by default
0138   unsigned int                       mySamplerRevision; //!< modification counter of parameters related to sampler state
0139   Graphic3d_TextureUnit              myTextureUnit;     //!< default texture unit to bind texture; Graphic3d_TextureUnit_BaseColor by default
0140   Graphic3d_TypeOfTextureFilter      myFilter;          //!< texture filter, Graphic3d_TOTF_NEAREST by default
0141   Graphic3d_LevelOfTextureAnisotropy myAnisoLevel;      //!< level of anisotropy filter, Graphic3d_LOTA_OFF by default
0142   Graphic3d_TypeOfTextureMode        myGenMode;         //!< texture coordinates generation mode, Graphic3d_TOTM_MANUAL by default
0143   Standard_Integer                   myBaseLevel;       //!< base texture mipmap level (0 by default)
0144   Standard_Integer                   myMaxLevel;        //!< maximum texture mipmap array level (1000 by default)
0145   Standard_ShortReal                 myRotAngle;        //!< texture coordinates rotation angle in degrees, 0 by default
0146   Standard_Boolean                   myToModulate;      //!< flag to modulate texture with material color, FALSE by default
0147   Standard_Boolean                   myToRepeat;        //!< flag to repeat (true) or wrap (false) texture coordinates out of [0,1] range
0148 
0149 };
0150 
0151 DEFINE_STANDARD_HANDLE(Graphic3d_TextureParams, Standard_Transient)
0152 
0153 #endif // _Graphic3d_TextureParams_HeaderFile