Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:47

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 
0028   //! Constructor defining loading cubemap from file.
0029   Standard_EXPORT Graphic3d_CubeMap (const TCollection_AsciiString& theFileName,
0030                                      Standard_Boolean               theToGenerateMipmaps = Standard_False);
0031 
0032   //! Constructor defining direct cubemap initialization from PixMap.
0033   Standard_EXPORT Graphic3d_CubeMap (const Handle(Image_PixMap)& thePixmap = Handle(Image_PixMap)(),
0034                                      Standard_Boolean            theToGenerateMipmaps = Standard_False);
0035 
0036   //! Returns whether the iterator has reached the end (true if it hasn't). 
0037   Standard_Boolean 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 (Standard_Boolean theZIsInverted)
0058   {
0059     myZIsInverted = theZIsInverted;
0060   }
0061 
0062   //! Returns whether Z axis is inverted.
0063   Standard_Boolean ZIsInverted() const
0064   {
0065     return myZIsInverted;
0066   }
0067 
0068   //! Returns whether mipmaps of cubemap will be generated or not.
0069   Standard_Boolean HasMipmaps() const { return myHasMipmaps; }
0070 
0071   //! Sets whether to generate mipmaps of cubemap or not.
0072   void SetMipmapsGeneration (Standard_Boolean theToGenerateMipmaps) { myHasMipmaps = theToGenerateMipmaps; }
0073 
0074   //! Returns current cubemap side as compressed PixMap.
0075   //! Returns null handle if current side is invalid or if image is not in supported compressed format.
0076   virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) = 0;
0077 
0078   //! Returns PixMap containing current side of cubemap.
0079   //! Returns null handle if current side is invalid.
0080   virtual Handle(Image_PixMap) Value (const Handle(Image_SupportedFormats)& theSupported) = 0;
0081 
0082   //! Sets iterator state to +X cubemap side.
0083   Graphic3d_CubeMap& Reset()
0084   { 
0085     myCurrentSide = Graphic3d_CMS_POS_X;
0086     myEndIsReached = false;
0087     return *this;
0088   }
0089 
0090   //! Empty destructor.
0091   Standard_EXPORT virtual ~Graphic3d_CubeMap();
0092 
0093 protected:
0094 
0095   Graphic3d_CubeMapSide myCurrentSide;  //!< Iterator state
0096   Standard_Boolean      myEndIsReached; //!< Indicates whether end of iteration has been reached or hasn't
0097   Standard_Boolean      myZIsInverted;  //!< Indicates whether Z axis is inverted that allows to synchronize vertical flip of cubemap
0098 
0099 };
0100 
0101 DEFINE_STANDARD_HANDLE(Graphic3d_CubeMap, Graphic3d_TextureMap)
0102 
0103 #endif // _Graphic3d_CubeMap_HeaderFile