Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/modules/designtools/SkyboxGenerator.cc @ 12145

Last change on this file since 12145 was 8077, checked in by dafrick, 14 years ago

Improving documentation of ScreenshotManager.

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