[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> |
---|
| 34 | |
---|
[6616] | 35 | #include "core/ConsoleCommand.h" |
---|
| 36 | #include "core/CoreIncludes.h" |
---|
| 37 | #include "core/ConfigValueIncludes.h" |
---|
| 38 | #include "core/ScopedSingletonManager.h" |
---|
[6673] | 39 | #include "controllers/HumanController.h" |
---|
| 40 | #include "worldentities/CameraPosition.h" |
---|
| 41 | #include "worldentities/ControllableEntity.h" |
---|
| 42 | #include "core/GraphicsManager.h" |
---|
| 43 | #include "core/CommandExecutor.h" |
---|
| 44 | |
---|
| 45 | |
---|
[6616] | 46 | |
---|
| 47 | namespace orxonox |
---|
| 48 | { |
---|
| 49 | |
---|
| 50 | SetConsoleCommand(SkyboxGenerator, createSkybox, true); |
---|
| 51 | |
---|
| 52 | ManageScopedSingleton(SkyboxGenerator, ScopeID::Graphics, false); |
---|
| 53 | |
---|
[6673] | 54 | SkyboxGenerator::SkyboxGenerator() : iterateOverDirections_(0) |
---|
[6616] | 55 | { |
---|
| 56 | RegisterRootObject(SkyboxGenerator); |
---|
| 57 | |
---|
| 58 | this->setConfigValues(); |
---|
[6673] | 59 | takeScreenshot_ = false; |
---|
[6616] | 60 | } |
---|
| 61 | |
---|
| 62 | SkyboxGenerator::~SkyboxGenerator() |
---|
| 63 | { |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | void SkyboxGenerator::setConfigValues( ) |
---|
| 68 | { |
---|
| 69 | SetConfigValue(skyboxPrefix_, "SkyboxFile_"); |
---|
| 70 | } |
---|
[6673] | 71 | |
---|
| 72 | void SkyboxGenerator::tick(float dt) |
---|
| 73 | { |
---|
| 74 | if( takeScreenshot_ == true ) |
---|
| 75 | { |
---|
| 76 | ControllableEntity* ce = HumanController::getLocalControllerSingleton()->getControllableEntity(); |
---|
| 77 | assert(ce); |
---|
| 78 | |
---|
| 79 | Ogre::RenderWindow* w = GraphicsManager::getInstance().getRenderWindow(); |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | switch (iterateOverDirections_) |
---|
| 84 | { |
---|
| 85 | case 0 : |
---|
| 86 | CommandExecutor::execute("pause"); |
---|
| 87 | //w->writeContentsToFile(skyboxPrefix_+"FR.png"); |
---|
| 88 | w->writeContentsToFile(skyboxPrefix_+"0.png"); |
---|
| 89 | ce->yaw(Degree(90)); |
---|
| 90 | iterateOverDirections_++; |
---|
| 91 | break; |
---|
| 92 | |
---|
| 93 | case 1 : |
---|
| 94 | //w->writeContentsToFile(skyboxPrefix_+"LF.png"); |
---|
| 95 | w->writeContentsToFile(skyboxPrefix_+"1.png"); |
---|
| 96 | ce->yaw(Degree(90)); |
---|
| 97 | iterateOverDirections_++; |
---|
| 98 | break; |
---|
| 99 | |
---|
| 100 | case 2 : |
---|
| 101 | //w->writeContentsToFile(skyboxPrefix_+"BK.png"); |
---|
| 102 | w->writeContentsToFile(skyboxPrefix_+"2.png"); |
---|
| 103 | ce->yaw(Degree(90)); |
---|
| 104 | iterateOverDirections_++; |
---|
| 105 | break; |
---|
| 106 | |
---|
| 107 | case 3 : |
---|
| 108 | //w->writeContentsToFile(skyboxPrefix_+"RT.png"); |
---|
| 109 | w->writeContentsToFile(skyboxPrefix_+"3.png"); |
---|
| 110 | ce->yaw(Degree(90)); |
---|
| 111 | ce->pitch(Degree(90)); |
---|
| 112 | iterateOverDirections_++; |
---|
| 113 | break; |
---|
| 114 | |
---|
| 115 | case 4 : |
---|
| 116 | //w->writeContentsToFile(skyboxPrefix_+"UP.png"); |
---|
| 117 | w->writeContentsToFile(skyboxPrefix_+"4.png"); |
---|
| 118 | ce->pitch(Degree(180)); |
---|
| 119 | iterateOverDirections_++; |
---|
| 120 | break; |
---|
| 121 | |
---|
| 122 | case 5 : |
---|
| 123 | //w->writeContentsToFile(skyboxPrefix_+"DN.png"); |
---|
| 124 | w->writeContentsToFile(skyboxPrefix_+"5.png"); |
---|
| 125 | ce->pitch(Degree(90)); |
---|
| 126 | iterateOverDirections_ =0; |
---|
| 127 | takeScreenshot_ = false; |
---|
| 128 | CommandExecutor::execute("pause"); |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | } |
---|
[6616] | 133 | |
---|
| 134 | void SkyboxGenerator::createSkybox( ) |
---|
| 135 | { |
---|
| 136 | |
---|
[6673] | 137 | SkyboxGenerator::getInstance().takeScreenshot_ = true; |
---|
| 138 | |
---|
[6616] | 139 | |
---|
[6673] | 140 | |
---|
[6616] | 141 | } |
---|
| 142 | } |
---|