Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox2/src/modules/designtools/SkyboxGenerator.cc @ 6787

Last change on this file since 6787 was 6771, checked in by gionc, 16 years ago

update SkyboxGenerator

  • Property svn:eol-style set to native
File size: 4.6 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 *      ...
26 *
27 */
28
29#include "SkyboxGenerator.h"
30
31#include <string>
32#include <cassert>
33#include <OgreRenderWindow.h>
34#include <OgreCamera.h>
35
36#include "core/ConsoleCommand.h"
37#include "core/CoreIncludes.h"
38#include "core/ConfigValueIncludes.h"
39#include "core/ScopedSingletonManager.h"
40#include "controllers/HumanController.h"
41#include "worldentities/CameraPosition.h"
42#include "worldentities/ControllableEntity.h"
43#include "core/GraphicsManager.h"
44#include "core/CommandExecutor.h"
45#include "graphics/Camera.h"
46
47
48 
49namespace orxonox
50{
51
52    SetConsoleCommand(SkyboxGenerator, createSkybox, true);
53
54    ManageScopedSingleton(SkyboxGenerator, ScopeID::Graphics, false);
55
56    SkyboxGenerator::SkyboxGenerator() : iterateOverDirections_(0)
57    {
58        RegisterRootObject(SkyboxGenerator);
59
60        this->setConfigValues();
61        takeScreenshot_ = false;
62    }
63
64    SkyboxGenerator::~SkyboxGenerator()
65    {
66
67    }
68
69    void SkyboxGenerator::setConfigValues( ) 
70    {
71        SetConfigValue(skyboxPrefix_, "SkyboxFile_");
72    }
73
74    void SkyboxGenerator::tick(float dt)
75    {
76        if( takeScreenshot_ == true )
77        {
78            ControllableEntity* ce = HumanController::getLocalControllerSingleton()->getControllableEntity();
79            Camera* camera = ce->getCamera();
80            assert(ce);
81       
82            Ogre::RenderWindow* w = GraphicsManager::getInstance().getRenderWindow();
83
84            switch (iterateOverDirections_) 
85            {
86            case 0 :
87                camera->getOgreCamera()->setFOVy(Degree(90));
88                camera->getOgreCamera()->setAspectRatio(1);
89                iterateOverDirections_++;
90                break;
91            case 1 :
92                w->writeContentsToFile(skyboxPrefix_+"fr.png");
93                //w->writeContentsToFile(skyboxPrefix_+"0.png");
94                ce->yaw(Degree(90));
95                iterateOverDirections_++;
96                break;
97               
98            case 2 :
99                w->writeContentsToFile(skyboxPrefix_+"lf.png");
100                //w->writeContentsToFile(skyboxPrefix_+"1.png");
101                ce->yaw(Degree(90)); 
102                iterateOverDirections_++;
103                break;
104
105            case 3 :
106                w->writeContentsToFile(skyboxPrefix_+"bk.png");
107                //w->writeContentsToFile(skyboxPrefix_+"2.png");
108                ce->yaw(Degree(90)); 
109                iterateOverDirections_++;
110                break;
111
112            case 4 :
113                w->writeContentsToFile(skyboxPrefix_+"rt.png");
114                //w->writeContentsToFile(skyboxPrefix_+"3.png");
115                ce->yaw(Degree(90)); 
116                ce->pitch(Degree(90)); 
117                iterateOverDirections_++;
118                break;
119
120            case 5 :
121                w->writeContentsToFile(skyboxPrefix_+"up.png");
122                //w->writeContentsToFile(skyboxPrefix_+"4.png");
123                ce->pitch(Degree(180)); 
124                iterateOverDirections_++;
125                break;
126
127            case 6 :
128                w->writeContentsToFile(skyboxPrefix_+"dn.png");
129                //w->writeContentsToFile(skyboxPrefix_+"5.png");
130                ce->pitch(Degree(90));
131                iterateOverDirections_++;
132                break;
133               
134            case 7 :
135                camera->getOgreCamera()->setAspectRatio(1.3333);
136                camera->getOgreCamera()->setFOVy(Degree(45));
137                iterateOverDirections_ =0;
138                takeScreenshot_ = false;
139                CommandExecutor::execute("pause");
140            }
141        }
142    }
143       
144        void SkyboxGenerator::createSkybox( ) 
145        {
146        SkyboxGenerator::getInstance().takeScreenshot_ = true;
147        CommandExecutor::execute("pause");
148        }
149}
Note: See TracBrowser for help on using the repository browser.