| 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 | |
|---|
| 49 | namespace 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 | } |
|---|