[6616] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Gion-Andri Cantieni |
---|
| 24 | * Co-authors: |
---|
[8232] | 25 | * Damian 'Mozork' Frick |
---|
[6616] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[8232] | 29 | /** |
---|
| 30 | @file SkyboxGenerator.h |
---|
| 31 | @brief Definition of the SkyboxGenerator class. |
---|
| 32 | @ingroup Designtools |
---|
| 33 | */ |
---|
[6616] | 34 | |
---|
[8232] | 35 | #ifndef __SkyboxGenerator_h__ |
---|
| 36 | #define __SkyboxGenerator_h__ |
---|
| 37 | |
---|
[9667] | 38 | #include "core/config/Configurable.h" |
---|
[6616] | 39 | #include "util/Singleton.h" |
---|
[6673] | 40 | #include "tools/interfaces/Tickable.h" |
---|
[8232] | 41 | |
---|
[6804] | 42 | #include <OgreMath.h> |
---|
[7127] | 43 | |
---|
[6616] | 44 | namespace orxonox |
---|
| 45 | { |
---|
[8232] | 46 | |
---|
| 47 | /** |
---|
| 48 | @brief |
---|
| 49 | The SkyboxGenerator class is a singleton that allows for the creation of a skybox from a level by taking pictures to all 6 sides. |
---|
| 50 | The 6 images created by the createSkybox() method are placed in the log folder in your build directory. |
---|
| 51 | |
---|
| 52 | The image filename prefix and the file extension can both be adjusted as config values, so can the desired size of the skybox faces. |
---|
| 53 | |
---|
| 54 | @author |
---|
| 55 | Gion-Andri Cantieni |
---|
| 56 | @author |
---|
| 57 | Damian 'Mozork' Frick |
---|
| 58 | @ingroup Designtools |
---|
| 59 | */ |
---|
[9667] | 60 | class SkyboxGenerator : public virtual Configurable, public Singleton<SkyboxGenerator>, public Tickable |
---|
[6616] | 61 | { |
---|
| 62 | friend class Singleton<SkyboxGenerator>; |
---|
[7127] | 63 | |
---|
[6616] | 64 | public: |
---|
| 65 | SkyboxGenerator(); |
---|
| 66 | virtual ~SkyboxGenerator(); |
---|
[10845] | 67 | virtual void tick(float dt) override; // This is where the skybox generation happens. |
---|
[8232] | 68 | static void createSkybox(void); // Generate the 6 faces of a skybox. |
---|
| 69 | void setConfigValues(void); // Sets some config values. |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | @brief Set the size of the skybox faces to be generated. |
---|
| 73 | @param size The size in pixels. |
---|
| 74 | */ |
---|
| 75 | inline void setSize(unsigned int size) |
---|
| 76 | { this->size_ = size; } |
---|
| 77 | |
---|
| 78 | protected: |
---|
| 79 | /** |
---|
| 80 | @brief Starts the generation of the skybox. |
---|
| 81 | */ |
---|
| 82 | inline void startSkyboxGeneration(void) |
---|
| 83 | { this->bGenerateSkybox_ = true; } |
---|
[6616] | 84 | |
---|
| 85 | private: |
---|
[8232] | 86 | void setupCamera(Ogre::Camera* camera); // Set up the input camera to be ready to generate a skybox face. |
---|
| 87 | void setupRenderWindow(Ogre::RenderWindow* renderWindow); // Setup the input render window to be ready to generate the skybox. |
---|
| 88 | void restoreRenderWindow(Ogre::RenderWindow* renderWindow); // Restore the render window. |
---|
| 89 | |
---|
| 90 | void saveImage(Ogre::Image* image, const std::string& name) const; |
---|
| 91 | |
---|
| 92 | static SkyboxGenerator* singletonPtr_s; //!< Singleton pointer. |
---|
| 93 | |
---|
| 94 | unsigned int size_; //!< The desired size of the skybox faces. |
---|
| 95 | std::string skyboxPrefix_; //!< Prefix for the generated image files. |
---|
| 96 | std::string imageExtension_; //!< Extension of the generated image files. |
---|
| 97 | |
---|
| 98 | // FLow control variables |
---|
| 99 | bool bGenerateSkybox_; //!< Whether a skybox is currently being generated. |
---|
| 100 | bool bCaptionsRemoved_; //!< Whether the overlays have been removed. |
---|
| 101 | bool bSetup_; //!< Whether the render window is being setup. |
---|
| 102 | bool bWait_; //!< Whether we have to wait for the setup to take effect. |
---|
| 103 | bool bCreateFace_; //!< Whether the faces are being created, |
---|
| 104 | unsigned int faceCounter_; //!< Counter to keep track of which skybox face is being created. |
---|
| 105 | bool bCleanup_; //!< Whether the generator is being cleaned up. |
---|
| 106 | |
---|
| 107 | std::vector<std::string> names_; //!< The names of the image files for the skybox faces to be generated. |
---|
[10769] | 108 | std::vector< std::pair<int, int>> rotations_; //!< The rotation in yaw an pitch direction that is applied to the camera after a specific face has been generated. |
---|
[8232] | 109 | |
---|
| 110 | // Storage variables |
---|
| 111 | float aspectRatio_; //!< The backed up aspect ratio of the camera. |
---|
| 112 | Ogre::Radian fovy_; //!< The backed up field of view of the camera. |
---|
| 113 | unsigned int windowWidth_; //!< The backed up window width. |
---|
| 114 | unsigned int windowHeight_; //!< The backed up window height. |
---|
| 115 | bool windowFullScreen_; //!< Whether the window was in fullscreen mode. |
---|
| 116 | unsigned int gridSize_; //!< The backed up grid size of the ScreenshotManager. |
---|
| 117 | |
---|
[6616] | 118 | }; |
---|
| 119 | } |
---|
[8232] | 120 | |
---|
[9667] | 121 | #endif // __SkyboxGenerator_h__ |
---|