Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/doc/src/modules/designtools/SkyboxGenerator.cc @ 7371

Last change on this file since 7371 was 7284, checked in by landauf, 14 years ago

merged consolecommands3 branch back to trunk.

note: the console command interface has changed completely, but the documentation is not yet up to date. just copy an existing command and change it to your needs, it's pretty self-explanatory. also the include files related to console commands are now located in core/command/. in the game it should work exactly like before, except for some changes in the auto-completion.

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