Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:17:42

0001 // Author: Ilya Khramov
0002 // Copyright (c) 2019 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _Graphic3d_CubeMap_HeaderFile
0016 #define _Graphic3d_CubeMap_HeaderFile
0017 
0018 #include <Graphic3d_CubeMapOrder.hxx>
0019 #include <Graphic3d_TextureMap.hxx>
0020 
0021 //! Base class for cubemaps.
0022 //! It is iterator over cubemap sides.
0023 class Graphic3d_CubeMap : public Graphic3d_TextureMap
0024 {
0025   DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMap, Graphic3d_TextureMap)
0026 public:
0027   //! Constructor defining loading cubemap from file.
0028   Standard_EXPORT Graphic3d_CubeMap(const TCollection_AsciiString& theFileName,
0029                                     bool                           theToGenerateMipmaps = false);
0030 
0031   //! Constructor defining direct cubemap initialization from PixMap.
0032   Standard_EXPORT Graphic3d_CubeMap(
0033     const occ::handle<Image_PixMap>& thePixmap            = occ::handle<Image_PixMap>(),
0034     bool                             theToGenerateMipmaps = false);
0035 
0036   //! Returns whether the iterator has reached the end (true if it hasn't).
0037   bool More() const { return !myEndIsReached; }
0038 
0039   //! Returns current cubemap side (iterator state).
0040   Graphic3d_CubeMapSide CurrentSide() const { return myCurrentSide; }
0041 
0042   //! Moves iterator to the next cubemap side.
0043   //! Uses OpenGL cubemap sides order +X -> -X -> +Y -> -Y -> +Z -> -Z.
0044   void Next()
0045   {
0046     if (!myEndIsReached && myCurrentSide == Graphic3d_CMS_NEG_Z)
0047     {
0048       myEndIsReached = true;
0049     }
0050     else
0051     {
0052       myCurrentSide = Graphic3d_CubeMapSide(myCurrentSide + 1);
0053     }
0054   }
0055 
0056   //! Sets Z axis inversion (vertical flipping).
0057   void SetZInversion(bool theZIsInverted) { myZIsInverted = theZIsInverted; }
0058 
0059   //! Returns whether Z axis is inverted.
0060   bool ZIsInverted() const { return myZIsInverted; }
0061 
0062   //! Returns whether mipmaps of cubemap will be generated or not.
0063   bool HasMipmaps() const { return myHasMipmaps; }
0064 
0065   //! Sets whether to generate mipmaps of cubemap or not.
0066   void SetMipmapsGeneration(bool theToGenerateMipmaps) { myHasMipmaps = theToGenerateMipmaps; }
0067 
0068   //! Returns current cubemap side as compressed PixMap.
0069   //! Returns null handle if current side is invalid or if image is not in supported compressed
0070   //! format.
0071   virtual occ::handle<Image_CompressedPixMap> CompressedValue(
0072     const occ::handle<Image_SupportedFormats>& theSupported) = 0;
0073 
0074   //! Returns PixMap containing current side of cubemap.
0075   //! Returns null handle if current side is invalid.
0076   virtual occ::handle<Image_PixMap> Value(
0077     const occ::handle<Image_SupportedFormats>& theSupported) = 0;
0078 
0079   //! Sets iterator state to +X cubemap side.
0080   Graphic3d_CubeMap& Reset()
0081   {
0082     myCurrentSide  = Graphic3d_CMS_POS_X;
0083     myEndIsReached = false;
0084     return *this;
0085   }
0086 
0087   //! Empty destructor.
0088   Standard_EXPORT ~Graphic3d_CubeMap() override;
0089 
0090 protected:
0091   Graphic3d_CubeMapSide myCurrentSide; //!< Iterator state
0092   // clang-format off
0093   bool      myEndIsReached; //!< Indicates whether end of iteration has been reached or hasn't
0094   bool      myZIsInverted;  //!< Indicates whether Z axis is inverted that allows to synchronize vertical flip of cubemap
0095   // clang-format on
0096 };
0097 
0098 #endif // _Graphic3d_CubeMap_HeaderFile