Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6819 was 6806, checked in by gionc, 16 years ago

updated skybox generator

  • Property svn:eol-style set to native
File size: 4.3 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                fovy_ = camera->getOgreCamera()->getFOVy();
88                camera->getOgreCamera()->setFOVy(Degree(90));
89                aspectRatio_ = camera->getOgreCamera()->getAspectRatio();
90                camera->getOgreCamera()->setAspectRatio(1);
91                iterateOverDirections_++;
92                break;
93            case 1 :
94                w->writeContentsToFile(skyboxPrefix_+"fr.png");
95                ce->yaw(Degree(90));
96                iterateOverDirections_++;
97                break;
98               
99            case 2 :
100                w->writeContentsToFile(skyboxPrefix_+"lf.png");
101                ce->yaw(Degree(90)); 
102                iterateOverDirections_++;
103                break;
104
105            case 3 :
106                w->writeContentsToFile(skyboxPrefix_+"bk.png");
107                ce->yaw(Degree(90)); 
108                iterateOverDirections_++;
109                break;
110
111            case 4 :
112                w->writeContentsToFile(skyboxPrefix_+"rt.png");
113                ce->yaw(Degree(90)); 
114                ce->pitch(Degree(90)); 
115                iterateOverDirections_++;
116                break;
117
118            case 5 :
119                w->writeContentsToFile(skyboxPrefix_+"up.png");
120                ce->pitch(Degree(180)); 
121                iterateOverDirections_++;
122                break;
123
124            case 6 :
125                w->writeContentsToFile(skyboxPrefix_+"dn.png");
126                ce->pitch(Degree(90));
127                iterateOverDirections_++;
128                break;
129               
130            case 7 :
131                camera->getOgreCamera()->setAspectRatio(aspectRatio_);
132                camera->getOgreCamera()->setFOVy(fovy_);
133                iterateOverDirections_ =0;
134                takeScreenshot_ = false;
135                CommandExecutor::execute("pause");
136            }
137        }
138    }
139       
140        void SkyboxGenerator::createSkybox( ) 
141        {
142        SkyboxGenerator::getInstance().takeScreenshot_ = true;
143        CommandExecutor::execute("pause");
144        }
145}
Note: See TracBrowser for help on using the repository browser.