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