Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/kicklib2/src/modules/designtools/SkyboxGenerator.h @ 8359

Last change on this file since 8359 was 8232, checked in by dafrick, 14 years ago

Extending and reorganizing ScreenshotManager and SkyboxGenerator.
The SkyboxGenerator now takes HD screenshots, thus the size of the faces generated by the SkyboxGenerator can now be specified freely (through a config value).

  • Property svn:eol-style set to native
File size: 5.0 KB
Line 
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:
25 *      Damian 'Mozork' Frick
26 *
27 */
28
29/**
30    @file SkyboxGenerator.h
31    @brief Definition of the SkyboxGenerator class.
32    @ingroup Designtools
33*/
34
35#ifndef __SkyboxGenerator_h__
36#define __SkyboxGenerator_h__
37
38#include "core/OrxonoxClass.h"
39#include "util/Singleton.h"
40#include "tools/interfaces/Tickable.h"
41
42#include <OgreMath.h>
43
44namespace orxonox
45{
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    */
60    class SkyboxGenerator : public virtual OrxonoxClass, public Singleton<SkyboxGenerator>, public Tickable
61    {
62        friend class Singleton<SkyboxGenerator>;
63
64        public:
65            SkyboxGenerator();
66            virtual ~SkyboxGenerator();
67            void tick(float dt); // This is where the skybox generation happens.
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; }
84
85        private:
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.
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.
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
118    };
119}
120
121#endif  // __SkyboxGenerator_h__
Note: See TracBrowser for help on using the repository browser.