[Orxonox-commit 1011] r5732 - in code/branches/libraries2/src: modules/gamestates orxonox orxonox/interfaces orxonox/objects/controllers orxonox/overlays
landauf at orxonox.net
landauf at orxonox.net
Mon Aug 31 22:51:36 CEST 2009
Author: landauf
Date: 2009-08-31 22:51:36 +0200 (Mon, 31 Aug 2009)
New Revision: 5732
Added:
code/branches/libraries2/src/orxonox/overlays/InGameConsole.cc
code/branches/libraries2/src/orxonox/overlays/InGameConsole.h
code/branches/libraries2/src/orxonox/overlays/Map.cc
code/branches/libraries2/src/orxonox/overlays/Map.h
Removed:
code/branches/libraries2/src/orxonox/InGameConsole.cc
code/branches/libraries2/src/orxonox/InGameConsole.h
code/branches/libraries2/src/orxonox/Map.cc
code/branches/libraries2/src/orxonox/Map.h
Modified:
code/branches/libraries2/src/modules/gamestates/GSGraphics.cc
code/branches/libraries2/src/orxonox/CMakeLists.txt
code/branches/libraries2/src/orxonox/interfaces/RadarViewable.cc
code/branches/libraries2/src/orxonox/objects/controllers/HumanController.cc
code/branches/libraries2/src/orxonox/overlays/CMakeLists.txt
Log:
moved InGameConsole and Map into the overlays folder
Modified: code/branches/libraries2/src/modules/gamestates/GSGraphics.cc
===================================================================
--- code/branches/libraries2/src/modules/gamestates/GSGraphics.cc 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/modules/gamestates/GSGraphics.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -46,11 +46,11 @@
#include "core/input/InputState.h"
#include "core/Loader.h"
#include "core/XMLFile.h"
-#include "InGameConsole.h"
+#include "overlays/InGameConsole.h"
#include "sound/SoundManager.h"
// HACK:
-#include "Map.h"
+#include "overlays/Map.h"
namespace orxonox
{
Modified: code/branches/libraries2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/libraries2/src/orxonox/CMakeLists.txt 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/CMakeLists.txt 2009-08-31 20:51:36 UTC (rev 5732)
@@ -24,9 +24,6 @@
LevelManager.cc
PawnManager.cc
PlayerManager.cc
-
- InGameConsole.cc
- Map.cc
)
ADD_SUBDIRECTORY(interfaces)
ADD_SUBDIRECTORY(overlays)
Deleted: code/branches/libraries2/src/orxonox/InGameConsole.cc
===================================================================
--- code/branches/libraries2/src/orxonox/InGameConsole.cc 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/InGameConsole.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -1,606 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Felix Schulthess
- * Co-authors:
- * Fabian 'x3n' Landau
- *
- */
-
-
-#include "InGameConsole.h"
-
-#include <algorithm>
-#include <string>
-#include <OgreOverlay.h>
-#include <OgreOverlayElement.h>
-#include <OgreOverlayManager.h>
-#include <OgreOverlayContainer.h>
-#include <OgreBorderPanelOverlayElement.h>
-#include <OgreTextAreaOverlayElement.h>
-#include <OgreFontManager.h>
-#include <OgreFont.h>
-
-#include "util/Math.h"
-#include "util/Convert.h"
-#include "util/UTFStringConversions.h"
-#include "core/Clock.h"
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/ConsoleCommand.h"
-#include "core/input/InputManager.h"
-#include "core/input/InputState.h"
-#include "core/input/InputBuffer.h"
-
-namespace orxonox
-{
- const int LINES = 30;
- const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
-
- SetConsoleCommand(InGameConsole, openConsole, true);
- SetConsoleCommand(InGameConsole, closeConsole, true);
-
- InGameConsole* InGameConsole::singletonPtr_s = 0;
-
- /**
- @brief Constructor: Creates and initializes the InGameConsole.
- */
- InGameConsole::InGameConsole()
- : consoleOverlay_(0)
- , consoleOverlayContainer_(0)
- , consoleOverlayNoise_(0)
- , consoleOverlayCursor_(0)
- , consoleOverlayBorder_(0)
- , consoleOverlayTextAreas_(0)
- , inputState_(0)
- {
- RegisterObject(InGameConsole);
-
- this->bActive_ = false;
- this->cursor_ = 0.0f;
- this->cursorSymbol_ = '|';
- this->inputWindowStart_ = 0;
- this->numLinesShifted_ = LINES - 1;
- // for the beginning, don't scroll
- this->scroll_ = 0;
-
- this->setConfigValues();
- }
-
- /**
- @brief Destructor: Destroys the TextAreas.
- */
- InGameConsole::~InGameConsole()
- {
- this->deactivate();
-
- // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
- InputManager::getInstance().destroyState("console");
-
- Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
- if (ovMan)
- {
- if (this->consoleOverlayNoise_)
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
- if (this->consoleOverlayCursor_)
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
- Ogre::FontManager::getSingleton().remove("MonofurConsole");
- if (this->consoleOverlayBorder_)
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
- if (this->consoleOverlayTextAreas_)
- {
- for (int i = 0; i < LINES; i++)
- {
- if (this->consoleOverlayTextAreas_[i])
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
- this->consoleOverlayTextAreas_[i] = 0;
- }
-
- }
- if (this->consoleOverlayContainer_)
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
- }
- if (this->consoleOverlayTextAreas_)
- {
- delete[] this->consoleOverlayTextAreas_;
- this->consoleOverlayTextAreas_ = 0;
- }
-
- if (this->consoleOverlay_)
- Ogre::OverlayManager::getSingleton().destroy(consoleOverlay_);
- }
-
- /**
- @brief Sets the config values, describing the size of the console.
- */
- void InGameConsole::setConfigValues()
- {
- SetConfigValue(relativeWidth, 0.8);
- SetConfigValue(relativeHeight, 0.4);
- SetConfigValue(blinkTime, 0.5);
- SetConfigValue(scrollSpeed_, 3.0f);
- SetConfigValue(noiseSize_, 1.0f);
- SetConfigValue(cursorSymbol_, '|');
- SetConfigValue(bHidesAllInput_, false).callback(this, &InGameConsole::bHidesAllInputChanged);
- }
-
- /**
- @brief Called whenever bHidesAllInput_ changes.
- */
- void InGameConsole::bHidesAllInputChanged()
- {
- if (inputState_)
- {
- if (bHidesAllInput_)
- {
- inputState_->setMouseHandler(&InputHandler::EMPTY);
- inputState_->setJoyStickHandler(&InputHandler::EMPTY);
- }
- else
- {
- inputState_->setMouseHandler(0);
- inputState_->setJoyStickHandler(0);
- }
- }
- }
-
- /**
- @brief Initializes the InGameConsole.
- */
- void InGameConsole::initialise()
- {
- // create the corresponding input state
- inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
- inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
- bHidesAllInputChanged();
-
- // create overlay and elements
- Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
-
- // create actual overlay
- this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
-
- // create a container
- this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
- this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
- this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
- this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
- this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
-
- // create BorderPanel
- this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
- this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
- this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
- this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
- this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
- this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
- this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
- this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
- this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
- this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
- this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
-
- // create a new font to match the requested size exactly
- Ogre::FontPtr font = static_cast<Ogre::FontPtr>
- (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
- font->setType(Ogre::FT_TRUETYPE);
- font->setSource("Monofur.ttf");
- font->setTrueTypeSize(18);
- // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
- font->setTrueTypeResolution(192);
- font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
- font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
-
- // create the text lines
- this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
- for (int i = 0; i < LINES; i++)
- {
- this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
- this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
- this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
- this->consoleOverlayTextAreas_[i]->setCharHeight(18);
- this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
- this->consoleOverlayTextAreas_[i]->setLeft(8);
- this->consoleOverlayTextAreas_[i]->setCaption("");
- this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
- }
-
- // create cursor (also a text area overlay element)
- this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
- this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
- this->consoleOverlayCursor_->setFontName("MonofurConsole");
- this->consoleOverlayCursor_->setCharHeight(18);
- this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
- this->consoleOverlayCursor_->setLeft(7);
- this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
- this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
-
- // create noise
- this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
- this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
- this->consoleOverlayNoise_->setPosition(5,0);
- this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
- // comment following line to disable noise
- this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
-
- this->windowResized(this->getWindowWidth(), this->getWindowWidth());
-
- // move overlay "above" the top edge of the screen
- // we take -1.2 because the border makes the panel bigger
- this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
-
- Shell::getInstance().addOutputLevel(true);
-
- COUT(4) << "Info: InGameConsole initialized" << std::endl;
- }
-
- // ###############################
- // ### ShellListener methods ###
- // ###############################
-
- /**
- @brief Called if all output-lines have to be redrawn.
- */
- void InGameConsole::linesChanged()
- {
- std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
- int max = 0;
- for (int i = 1; i < LINES; ++i)
- {
- if (it != Shell::getInstance().getEndIterator())
- {
- ++it;
- max = i;
- }
- else
- break;
- }
-
- for (int i = LINES - 1; i > max; --i)
- this->print("", i, true);
-
- for (int i = max; i >= 1; --i)
- {
- --it;
- this->print(*it, i, true);
- }
- }
-
- /**
- @brief Called if only the last output-line has changed.
- */
- void InGameConsole::onlyLastLineChanged()
- {
- if (LINES > 1)
- this->print(*Shell::getInstance().getNewestLineIterator(), 1);
- }
-
- /**
- @brief Called if a new output-line was added.
- */
- void InGameConsole::lineAdded()
- {
- this->numLinesShifted_ = 0;
- this->shiftLines();
- this->onlyLastLineChanged();
- }
-
- /**
- @brief Called if the text in the input-line has changed.
- */
- void InGameConsole::inputChanged()
- {
- if (LINES > 0)
- this->print(Shell::getInstance().getInput(), 0);
-
- if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
- this->inputWindowStart_ = 0;
- }
-
- /**
- @brief Called if the position of the cursor in the input-line has changed.
- */
- void InGameConsole::cursorChanged()
- {
- unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
- if (pos > maxCharsPerLine_)
- pos = maxCharsPerLine_;
-
- this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
- this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24);
- }
-
- /**
- @brief Called if the console gets closed.
- */
- void InGameConsole::exit()
- {
- this->deactivate();
- }
-
- // ###############################
- // ### other external calls ###
- // ###############################
-
- /**
- @brief Used to control the actual scrolling and the cursor.
- */
- void InGameConsole::update(const Clock& time)
- {
- if (this->scroll_ != 0)
- {
- float oldTop = this->consoleOverlayContainer_->getTop();
-
- if (this->scroll_ > 0)
- {
- // scrolling down
- // enlarge oldTop a little bit so that this exponential function
- // reaches 0 before infinite time has passed...
- float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_;
- if (oldTop - deltaScroll >= 0)
- {
- // window has completely scrolled down
- this->consoleOverlayContainer_->setTop(0);
- this->scroll_ = 0;
- }
- else
- this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
- }
-
- else
- {
- // scrolling up
- // note: +0.01 for the same reason as when scrolling down
- float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
- if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
- {
- // window has completely scrolled up
- this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
- this->scroll_ = 0;
- this->consoleOverlay_->hide();
- }
- else
- this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
- }
- }
-
- if (this->bActive_)
- {
- this->cursor_ += time.getDeltaTime();
- if (this->cursor_ >= this->blinkTime)
- {
- this->cursor_ = 0;
- bShowCursor_ = !bShowCursor_;
- if (bShowCursor_)
- this->consoleOverlayCursor_->show();
- else
- this->consoleOverlayCursor_->hide();
- }
-
- // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
- float uRand = (rand() & 1023) / 1023.0f * 0.2f;
- float vRand = (rand() & 1023) / 1023.0f * 0.2f;
- this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
- }
- }
-
- /**
- @brief Resizes the console elements. Call if window size changes.
- */
- void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
- {
- this->windowW_ = newWidth;
- this->windowH_ = newHeight;
- this->consoleOverlayBorder_->setWidth(static_cast<int>(this->windowW_* this->relativeWidth));
- this->consoleOverlayBorder_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight));
- this->consoleOverlayNoise_->setWidth(static_cast<int>(this->windowW_ * this->relativeWidth) - 10);
- this->consoleOverlayNoise_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight) - 5);
- this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
-
- // now adjust the text lines...
- this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
-
- if (LINES > 0)
- this->maxCharsPerLine_ = std::max(10U, static_cast<unsigned int>(static_cast<float>(this->desiredTextWidth_) / CHAR_WIDTH));
- else
- this->maxCharsPerLine_ = 10;
-
- for (int i = 0; i < LINES; i++)
- {
- this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
- this->consoleOverlayTextAreas_[i]->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24 - 14*i);
- }
-
- this->linesChanged();
- this->cursorChanged();
- }
-
- // ###############################
- // ### internal methods ###
- // ###############################
-
- /**
- @brief Prints string to bottom line.
- @param s String to be printed
- */
- void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
- {
- char level = 0;
- if (text.size() > 0)
- level = text[0];
-
- std::string output = text;
-
- if (level >= -1 && level <= 5)
- output.erase(0, 1);
-
- if (LINES > index)
- {
- this->colourLine(level, index);
-
- if (index > 0)
- {
- unsigned int linesUsed = 1;
- while (output.size() > this->maxCharsPerLine_)
- {
- ++linesUsed;
- this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
- output.erase(0, this->maxCharsPerLine_);
- output.insert(0, 1, ' ');
- if (linesUsed > numLinesShifted_ || alwaysShift)
- this->shiftLines();
- this->colourLine(level, index);
- }
- this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
- this->displayedText_ = output;
- this->numLinesShifted_ = linesUsed;
- }
- else
- {
- if (output.size() > this->maxCharsPerLine_)
- {
- if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
- this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
- else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
- this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
-
- output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
- }
- else
- this->inputWindowStart_ = 0;
- this->displayedText_ = output;
- this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
- }
- }
- }
-
- /**
- @brief Shows the InGameConsole.
- */
- void InGameConsole::activate()
- {
- if (!this->bActive_)
- {
- this->bActive_ = true;
- InputManager::getInstance().enterState("console");
- Shell::getInstance().registerListener(this);
-
- this->windowResized(this->windowW_, this->windowH_);
- this->linesChanged();
- this->cursorChanged();
- this->consoleOverlay_->show();
-
- // scroll down
- this->scroll_ = 1;
- // the rest is done by tick
- }
- }
-
- /**
- @brief Hides the InGameConsole.
- */
- void InGameConsole::deactivate()
- {
- if (this->bActive_)
- {
- this->bActive_ = false;
- InputManager::getInstance().leaveState("console");
- Shell::getInstance().unregisterListener(this);
-
- // scroll up
- this->scroll_ = -1;
- // the rest is done by tick
- }
- }
-
- /**
- @brief Shifts all output lines one line up
- */
- void InGameConsole::shiftLines()
- {
- for (unsigned int i = LINES - 1; i > 1; --i)
- {
- this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
- this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
- this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
- }
- }
-
- void InGameConsole::colourLine(int colourcode, int index)
- {
- if (colourcode == -1)
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.90, 0.90, 0.90, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
- }
- else if (colourcode == 1)
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.25, 0.25, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
- }
- else if (colourcode == 2)
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.50, 0.20, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
- }
- else if (colourcode == 3)
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.50, 0.50, 0.95, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
- }
- else if (colourcode == 4)
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.65, 0.48, 0.44, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
- }
- else if (colourcode == 5)
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.40, 0.20, 0.40, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
- }
- else
- {
- this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.21, 0.69, 0.21, 1.00));
- this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
- }
- }
-
- // ###############################
- // ### satic methods ###
- // ###############################
-
- /**
- @brief Activates the console.
- */
- /*static*/ void InGameConsole::openConsole()
- {
- InGameConsole::getInstance().activate();
- }
-
- /**
- @brief Deactivates the console.
- */
- /*static*/ void InGameConsole::closeConsole()
- {
- InGameConsole::getInstance().deactivate();
- }
-}
Deleted: code/branches/libraries2/src/orxonox/InGameConsole.h
===================================================================
--- code/branches/libraries2/src/orxonox/InGameConsole.h 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/InGameConsole.h 2009-08-31 20:51:36 UTC (rev 5732)
@@ -1,118 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Felix Schulthess
- * Co-authors:
- * Fabian 'x3n' Landau
- *
- */
-
-#ifndef _InGameConsole_H__
-#define _InGameConsole_H__
-
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-
-#include "util/OgreForwardRefs.h"
-#include "util/Singleton.h"
-#include "core/Shell.h"
-#include "core/WindowEventListener.h"
-
-namespace orxonox
-{
- class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
- {
- friend class Singleton<InGameConsole>;
- public: // functions
- InGameConsole();
- ~InGameConsole();
-
- void initialise();
- void destroy();
- void setConfigValues();
-
- void update(const Clock& time);
-
- static void openConsole();
- static void closeConsole();
-
- private: // functions
- InGameConsole(const InGameConsole& other);
-
- void activate();
- void deactivate();
-
- void linesChanged();
- void onlyLastLineChanged();
- void lineAdded();
- void inputChanged();
- void cursorChanged();
- void exit();
-
- void shiftLines();
- void colourLine(int colourcode, int index);
- void setCursorPosition(unsigned int pos);
- void print(const std::string& text, int index, bool alwaysShift = false);
-
- void windowResized(unsigned int newWidth, unsigned int newHeight);
-
- // config value related
- void bHidesAllInputChanged();
-
- private: // variables
- bool bActive_;
- int windowW_;
- int windowH_;
- int desiredTextWidth_;
- unsigned int maxCharsPerLine_;
- unsigned int numLinesShifted_;
- int scroll_;
- float cursor_;
- unsigned int inputWindowStart_;
- bool bShowCursor_;
- std::string displayedText_;
- Ogre::Overlay* consoleOverlay_;
- Ogre::OverlayContainer* consoleOverlayContainer_;
- Ogre::PanelOverlayElement* consoleOverlayNoise_;
- Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
- Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
- Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
-
- // input related
- InputState* inputState_;
-
- // config values
- float relativeWidth;
- float relativeHeight;
- float blinkTime;
- float scrollSpeed_;
- float noiseSize_;
- char cursorSymbol_;
- bool bHidesAllInput_;
-
- static InGameConsole* singletonPtr_s;
- };
-}
-
-#endif /* _InGameConsole_H__ */
Deleted: code/branches/libraries2/src/orxonox/Map.cc
===================================================================
--- code/branches/libraries2/src/orxonox/Map.cc 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/Map.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -1,456 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Si Sun
- *
- */
-
-#include "Map.h"
-
-#include <string>
-
-#include <OgreBorderPanelOverlayElement.h>
-#include <OgreCamera.h>
-#include <OgreEntity.h>
-#include <OgreHardwarePixelBuffer.h>
-#include <OgreMaterialManager.h>
-#include <OgreMovablePlane.h>
-#include <OgreOverlay.h>
-#include <OgreOverlayContainer.h>
-#include <OgreOverlayManager.h>
-#include <OgrePass.h>
-#include <OgreRenderTexture.h>
-#include <OgreResourceGroupManager.h>
-#include <OgreRoot.h>
-#include <OgreSceneManager.h>
-#include <OgreSceneNode.h>
-#include <OgreTechnique.h>
-#include <OgreTexture.h>
-#include <OgreTextureManager.h>
-#include <OgreViewport.h>
-
-#include "core/ConsoleCommand.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "interfaces/RadarViewable.h"
-#include "objects/Scene.h"
-#include "objects/controllers/HumanController.h"
-#include "objects/worldentities/CameraPosition.h"
-#include "objects/worldentities/ControllableEntity.h"
-
- namespace orxonox
- {
- CreateFactory(Map);
- SetConsoleCommand(Map, openMap, true);
- //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
- //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
- SetConsoleCommand(Map, Zoom, true).setAsInputCommand();
-
-
- Map* Map::singletonMap_s = 0;
- Ogre::SceneManager* Map::mapSceneM_s = 0;
- Ogre::Camera* Map::Cam_ = 0;
- Ogre::SceneNode* Map::CamNode_ = 0;
- Ogre::MaterialPtr Map::OverlayMaterial_;// = init();
- Ogre::Overlay* Map::overlay_ = 0;
-/*
-Ogre::MaterialPtr Map::init()
-{
- Ogre::MaterialPtr tmp;
- tmp.setNull();
- return tmp;
-}
-*/
-
- //int Map::mouseLookSpeed_ = 200;
- //Ogre::SceneNode* Map::playerShipNode_ = 0;
-
- const int PITCH=-30;
- const int DISTANCE=200;
-
- Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
- {
- RegisterObject(Map);
- Map::singletonMap_s=this;
-
- //Getting Scene Manager (Hack)
- if( !sManager_ )
- {
- ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
- this->sManager_ = it->getSceneManager();
- }
- if( !Map::getMapSceneManager() )
- {
- Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
- }
-
- this->playerShipNode_ = 0;
- //this->sNode_ = new Ogre::SceneNode(sManager_);
- //oManager_ = Ogre::OverlayManager::getSingletonPtr();
- //overlay_ = oManager_->create("Map");
- //overlay_ is member of OrxonoxOverlay
-
- //Not Showing the map as default
- //this->isVisible_=false;
- //overlay_->hide();
- this->mouseLookSpeed_ = 200;
-
- //TestEntity
- //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
-
- //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
- /*sNode_->setPosition(0,0,-50);
- overlay_->add3D(sNode_);
- */
-
-
-
-
-
- // Alter the camera aspect ratio to match the viewport
- //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
- if(!Map::Cam_)
- Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
- //Cam_->setPosition(200,170, -160);
- //Cam_->lookAt(0,0,0);
- Cam_->setAspectRatio(1);
- //Cam_->setRenderingDistance(0);
- if(!Map::CamNode_)
- CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
-
-
- //Create overlay material
- if(Map::OverlayMaterial_.isNull())
- Map::OverlayMaterial_ = this->createRenderCamera(Cam_, "RttMat");
-/*
- Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
-
- Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
-
- renderTexture->addViewport(Cam_);
- renderTexture->getViewport(0)->setClearEveryFrame(true);
- renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
- renderTexture->getViewport(0)->setOverlaysEnabled(false);
-
- Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- Ogre::Technique *technique = material->createTechnique();
- technique->createPass();
- material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
- material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
-*/
-
-
- // create overlay
-/*
- Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1");
-
- // Create a panel with RenderToTexture texture
- Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
- m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
- m_pOverlayPanel->setPosition(10, 10);
- m_pOverlayPanel->setDimensions(500, 300);
- // Give overlay a texture
- m_pOverlayPanel->setMaterialName(camMat_id);
- pOverlay->add2D(m_pOverlayPanel);
- pOverlay->show();
-*/
- if(!this->overlay_)
- {
- this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
- Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
- //m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
- //m_pOverlayPanel->setPosition(10, 10);
- //m_pOverlayPanel->setDimensions(600, 400);
- m_pOverlayPanel->setPosition(0.01, 0.003);
- m_pOverlayPanel->setDimensions(0.5, 0.4);
- // Give overlay a texture
- m_pOverlayPanel->setMaterialName("RttMat");
- overlay_->add2D(m_pOverlayPanel);
-
- //Add Borders
- Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
- oBorder->setBorderSize( 0.003, 0.003 );
- oBorder->setDimensions(0.5, 0.4);
- oBorder->setBorderMaterialName("StatsBorder");
- oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
- oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
- oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
- oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
- oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
- oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
- oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
- oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
- //overlay_->add2D(oBorder);
- m_pOverlayPanel->addChild(oBorder);
- }
-
-
- //Not Showing the map as default
- this->isVisible_=false;
- overlay_->hide();
-
- //Create plane to show gridTypeError: blimport() takes no keyword arguments
-/* Ogre::Entity* plane_ent;
- if(Map::getMapSceneManager()->hasEntity("MapPlane"))
- plane_ent = Map::getMapSceneManager()->getEntity("MapPlane");
- else
- plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
-*/
- this->movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
- this->movablePlane_->normalise();
-
- if(!Map::getMapSceneManager()->hasEntity("MapPlane"))
- {
- Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
- planeNode_ = Map::getMapSceneManager()->createSceneNode();
- //Create plane for calculations
-
-
- //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
- //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
- //plane_ent->setMaterialName("mapgrid");
- plane_ent->setMaterialName("Map/Grid");
- planeNode_->attachObject(plane_ent);
-
- planeNode_->scale(160,1,160);
-// planeNode_->attachObject(movablePlane_);
- //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
-
-
- //ToDo create material script
- Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
- myManualObjectMaterial->setReceiveShadows(false);
- myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
- myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
- myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
- myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
- }
- }
-
- Map::~Map()
- {
- this->singletonMap_s = 0;
- //delete this->overlay_;
- /*if (this->isInitialized())
- {
- //delete sManager_;
- //delete Map::getMapSceneManager()->getRootSceneNode();
- //delete oManager_;
- //delete CamNode_;
- //delete Cam_;
- //delete mapSceneM_s;
- //Map::getMapSceneManager()->destroyAllEntities();
- //Map::getMapSceneManager()->destroyAllCameras();
- delete Map::getMapSceneManager();
- }*/
- }
-
- Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, const std::string& matName)
- {
- Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(matName+"_tex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
-
- Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
-
- renderTexture->addViewport(cam);
- renderTexture->getViewport(0)->setClearEveryFrame(true);
- renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
- renderTexture->getViewport(0)->setOverlaysEnabled(false);
-
- Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- Ogre::Technique *technique = material->createTechnique();
- technique->createPass();
- material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
- material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex");
- return material;
- }
-
- void Map::updatePositions()
- {
-
-//Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh");
- for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
- it!=ObjectList<orxonox::RadarViewable>::end();
- it++)
- {
- //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
- //Ogre::SceneNode node = it->getMapNode();
- //Ogre::Entity ent = it->getMapEntity();
- if( !(it->MapNode_) )
- {
- it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() );
- //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
- /*if(it->getRadarObjectShape() == RadarViewable::Dot)
- {
- //if( !(it->MapEntity_) )//check wether the entity is already attached
- //{
- //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh");
- //it->addEntity();
- //it->MapNode_->attachObject( it->MapEntity_ );
- //it->MapNode_->attachObject( it->line_ );
- // }
- }*/
- it->addMapEntity();
- }
- if(it->isHumanShip_)
- {
- this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
- if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_)
- {
- this->playerShipNode_ = it->MapNode_;
- if(planeNode_ && this->planeNode_->getParent())
- this->planeNode_->getParent()->removeChild(this->planeNode_);
- this->playerShipNode_->addChild(this->planeNode_);
- //Movable Plane needs to be attached direcly for calculations
- //this->movablePlane_->detatchFromParent();
- //this->movablePlane_->getParentSceneNode()->detachObject(this->movablePlane_);
- //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
- //it->MapNode_->attachObject(this->movablePlane_);
- if(planeNode_ && this->CamNode_->getParent())
- this->CamNode_->getParent()->removeChild(this->CamNode_);
- this->playerShipNode_->addChild(this->CamNode_);
- this->CamNode_->attachObject(this->Cam_);
- //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode();
- //this->CamNodeHelper_->attachObject(this->Cam_);
- this->Cam_->setPosition(0, 0, DISTANCE);
- this->Cam_->pitch( static_cast<Degree>(PITCH) );
- this->Cam_->lookAt(this->playerShipNode_->getPosition());
- //this->Cam_->setAutoTracking(true, this->playerShipNode_);
- }
- }
- it->updateMapPosition();
-
-
-
-
-
-
- }
- }
-
-
-
- void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
- {
- SUPER(Map, XMLPort, xmlElement, mode);
- }
-
- void Map::changedOwner()
- {
- SUPER(Map, changedOwner);
- //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
-
- ControllableEntity* entity = orxonox_cast<ControllableEntity*>(this->getOwner());
- if(entity && entity->getReverseCamera())
- {
- //COUT(0) << "foo";
- entity->getReverseCamera()->attachCamera(this->Cam_);
- }
- }
-
-
- void Map::toggleVisibility()
- {
- if (!(this->isVisible_))
- {
- this->overlay_->show();
- this->isVisible_=1;
- //set mouselook when showing map
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
- HumanController::localController_s->controllableEntity_->mouseLook();
- }
- else
- {
- this->overlay_->hide();
- this->isVisible_=0;
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
- HumanController::localController_s->controllableEntity_->mouseLook();
- }
- }
-
- //Static function to toggle visibility of the map
- void Map::openMap()
- {
- for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
- it!=ObjectList<orxonox::Map>::end();
- it++)
- {
- //Map * m = it->getMap();
- //COUT(0) << it->isVisible_ << std::endl;
- it->toggleVisibility();
- //it->updatePositions();
- }
- }
-
- // HACK!
- void Map::hackDestroyMap()
- {
- Map::OverlayMaterial_.setNull();
- }
-
- void Map::tick(float dt)
- {
- //Debug
- //COUT(0) << "MovablePlane Position: " << this->movablePlane_->getParentSceneNode()->getName() << this->movablePlane_->getParentSceneNode()->getPosition() << std::endl;
- //COUT(0) << "planeNode_ Position: " << this->planeNode_ ->getName() << this->planeNode_->getPosition() << std::endl;
- //COUT(0) << "planeNode_ Parrent Position" << this->planeNode_->getParent()->getName() << this->planeNode_->getParent()->getPosition() << std::endl;
- if( this->isVisible_ )
- updatePositions();
- //Cam_->roll(Degree(1));
-
- }
-
- void Map::rotateYaw(const Vector2& value)
- {
- if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
- return;
-
-/*
- singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
-
- Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
- Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
-*/
- singletonMap_s->CamNode_->yaw( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
- }
-
- void Map::rotatePitch(const Vector2& value)
- {
- if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
- return;
- //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
-/* singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
-
- Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
- Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
-*/
- singletonMap_s->CamNode_->pitch( static_cast<Degree>(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
-
- }
-
- void Map::Zoom(const Vector2& value)
- {
- if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
- return;
- //COUT(0) << value.y << std::endl;
- Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ );
- }
- }
Deleted: code/branches/libraries2/src/orxonox/Map.h
===================================================================
--- code/branches/libraries2/src/orxonox/Map.h 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/Map.h 2009-08-31 20:51:36 UTC (rev 5732)
@@ -1,118 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Si Sun
- *
- */
-
-#ifndef _Map_H__
-#define _Map_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <OgreMaterial.h>
-
-#include "util/UtilPrereqs.h"
-#include "tools/interfaces/Tickable.h"
-#include "overlays/OrxonoxOverlay.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Map : public OrxonoxOverlay, public Tickable
- {
-
- public: // functions
- Map(BaseObject* creator);
- virtual ~Map();
-
- virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
- virtual void tick(float dt);
- virtual void changedOwner();
-
- static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, const std::string& matName);
-
- static void openMap();
- // HACK!
- static void hackDestroyMap();
-
-//Not yet implemented
- static const int maxRange_s=1000;
-
- static void rotateYaw(const Vector2& value);
- static void rotatePitch(const Vector2& value);
- static void Zoom(const Vector2& value);
- // variables
-
-
- bool inline getVisibility()
- { return this->isVisible_; };
-
- static inline Ogre::SceneManager* getMapSceneManagerPtr()
- {
- return Map::singletonMap_s->mapSceneM_s;
- }
- static inline Map* getSingletonPtr()
- {
- return Map::singletonMap_s;
- }
-
- static inline Ogre::SceneManager* getMapSceneManager()
- {
- return Map::mapSceneM_s;
- }
-
-
-
- private: // functions
-
- void toggleVisibility();
- void updatePositions();
-// void changedPlayerNode();
- static inline void setMapSceneManager( Ogre::SceneManager * sm)
- {
- Map::mapSceneM_s = sm;
- }
- //static Ogre::MaterialPtr init();
-
- private: // variables
- static Map* singletonMap_s;
-
- Ogre::SceneManager* sManager_;
- Ogre::OverlayManager * oManager_;
-
- static Ogre::SceneManager* mapSceneM_s;
- static Ogre::SceneNode* CamNode_;
- static Ogre::Camera* Cam_;
- static Ogre::MaterialPtr OverlayMaterial_;
- static Ogre::Overlay* overlay_;
- //Ogre::SceneNode* CamNodeHelper_;
- Ogre::SceneNode* playerShipNode_;
- Ogre::SceneNode* planeNode_;
- Ogre::MovablePlane* movablePlane_;
- int mouseLookSpeed_;
- bool isVisible_;
-
- friend class RadarViewable;
- };
-}
-
-#endif /* _Map_H__ */
Modified: code/branches/libraries2/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/branches/libraries2/src/orxonox/interfaces/RadarViewable.cc 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/interfaces/RadarViewable.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -37,7 +37,7 @@
#include "tools/DynamicLines.h"
#include "objects/worldentities/WorldEntity.h"
#include "objects/Radar.h"
-#include "Map.h"
+#include "overlays/Map.h"
namespace orxonox
{
Modified: code/branches/libraries2/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- code/branches/libraries2/src/orxonox/objects/controllers/HumanController.cc 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/objects/controllers/HumanController.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -34,7 +34,7 @@
#include "objects/worldentities/pawns/Pawn.h"
#include "objects/gametypes/Gametype.h"
#include "objects/infos/PlayerInfo.h"
-#include "Map.h"
+#include "overlays/Map.h"
namespace orxonox
{
Modified: code/branches/libraries2/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/branches/libraries2/src/orxonox/overlays/CMakeLists.txt 2009-08-31 20:45:15 UTC (rev 5731)
+++ code/branches/libraries2/src/orxonox/overlays/CMakeLists.txt 2009-08-31 20:51:36 UTC (rev 5732)
@@ -1,4 +1,7 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
OrxonoxOverlay.cc
OverlayGroup.cc
+
+ InGameConsole.cc
+ Map.cc
)
Copied: code/branches/libraries2/src/orxonox/overlays/InGameConsole.cc (from rev 5727, code/branches/libraries2/src/orxonox/InGameConsole.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/overlays/InGameConsole.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/overlays/InGameConsole.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -0,0 +1,606 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Felix Schulthess
+ * Co-authors:
+ * Fabian 'x3n' Landau
+ *
+ */
+
+
+#include "InGameConsole.h"
+
+#include <algorithm>
+#include <string>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgreFontManager.h>
+#include <OgreFont.h>
+
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "util/UTFStringConversions.h"
+#include "core/Clock.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "core/input/InputState.h"
+#include "core/input/InputBuffer.h"
+
+namespace orxonox
+{
+ const int LINES = 30;
+ const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
+
+ SetConsoleCommand(InGameConsole, openConsole, true);
+ SetConsoleCommand(InGameConsole, closeConsole, true);
+
+ InGameConsole* InGameConsole::singletonPtr_s = 0;
+
+ /**
+ @brief Constructor: Creates and initializes the InGameConsole.
+ */
+ InGameConsole::InGameConsole()
+ : consoleOverlay_(0)
+ , consoleOverlayContainer_(0)
+ , consoleOverlayNoise_(0)
+ , consoleOverlayCursor_(0)
+ , consoleOverlayBorder_(0)
+ , consoleOverlayTextAreas_(0)
+ , inputState_(0)
+ {
+ RegisterObject(InGameConsole);
+
+ this->bActive_ = false;
+ this->cursor_ = 0.0f;
+ this->cursorSymbol_ = '|';
+ this->inputWindowStart_ = 0;
+ this->numLinesShifted_ = LINES - 1;
+ // for the beginning, don't scroll
+ this->scroll_ = 0;
+
+ this->setConfigValues();
+ }
+
+ /**
+ @brief Destructor: Destroys the TextAreas.
+ */
+ InGameConsole::~InGameConsole()
+ {
+ this->deactivate();
+
+ // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
+ InputManager::getInstance().destroyState("console");
+
+ Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+ if (ovMan)
+ {
+ if (this->consoleOverlayNoise_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
+ if (this->consoleOverlayCursor_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
+ Ogre::FontManager::getSingleton().remove("MonofurConsole");
+ if (this->consoleOverlayBorder_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
+ if (this->consoleOverlayTextAreas_)
+ {
+ for (int i = 0; i < LINES; i++)
+ {
+ if (this->consoleOverlayTextAreas_[i])
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+ this->consoleOverlayTextAreas_[i] = 0;
+ }
+
+ }
+ if (this->consoleOverlayContainer_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
+ }
+ if (this->consoleOverlayTextAreas_)
+ {
+ delete[] this->consoleOverlayTextAreas_;
+ this->consoleOverlayTextAreas_ = 0;
+ }
+
+ if (this->consoleOverlay_)
+ Ogre::OverlayManager::getSingleton().destroy(consoleOverlay_);
+ }
+
+ /**
+ @brief Sets the config values, describing the size of the console.
+ */
+ void InGameConsole::setConfigValues()
+ {
+ SetConfigValue(relativeWidth, 0.8);
+ SetConfigValue(relativeHeight, 0.4);
+ SetConfigValue(blinkTime, 0.5);
+ SetConfigValue(scrollSpeed_, 3.0f);
+ SetConfigValue(noiseSize_, 1.0f);
+ SetConfigValue(cursorSymbol_, '|');
+ SetConfigValue(bHidesAllInput_, false).callback(this, &InGameConsole::bHidesAllInputChanged);
+ }
+
+ /**
+ @brief Called whenever bHidesAllInput_ changes.
+ */
+ void InGameConsole::bHidesAllInputChanged()
+ {
+ if (inputState_)
+ {
+ if (bHidesAllInput_)
+ {
+ inputState_->setMouseHandler(&InputHandler::EMPTY);
+ inputState_->setJoyStickHandler(&InputHandler::EMPTY);
+ }
+ else
+ {
+ inputState_->setMouseHandler(0);
+ inputState_->setJoyStickHandler(0);
+ }
+ }
+ }
+
+ /**
+ @brief Initializes the InGameConsole.
+ */
+ void InGameConsole::initialise()
+ {
+ // create the corresponding input state
+ inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
+ inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
+ bHidesAllInputChanged();
+
+ // create overlay and elements
+ Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+
+ // create actual overlay
+ this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
+
+ // create a container
+ this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
+ this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
+ this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
+ this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
+ this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
+
+ // create BorderPanel
+ this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+ this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
+ this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
+ this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
+ this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+ this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+ this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+ this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+ this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
+
+ // create a new font to match the requested size exactly
+ Ogre::FontPtr font = static_cast<Ogre::FontPtr>
+ (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
+ font->setType(Ogre::FT_TRUETYPE);
+ font->setSource("Monofur.ttf");
+ font->setTrueTypeSize(18);
+ // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
+ font->setTrueTypeResolution(192);
+ font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
+ font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
+
+ // create the text lines
+ this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
+ for (int i = 0; i < LINES; i++)
+ {
+ this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
+ this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
+ this->consoleOverlayTextAreas_[i]->setCharHeight(18);
+ this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
+ this->consoleOverlayTextAreas_[i]->setLeft(8);
+ this->consoleOverlayTextAreas_[i]->setCaption("");
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+ }
+
+ // create cursor (also a text area overlay element)
+ this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
+ this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayCursor_->setFontName("MonofurConsole");
+ this->consoleOverlayCursor_->setCharHeight(18);
+ this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
+ this->consoleOverlayCursor_->setLeft(7);
+ this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
+
+ // create noise
+ this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
+ this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayNoise_->setPosition(5,0);
+ this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+ // comment following line to disable noise
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+
+ this->windowResized(this->getWindowWidth(), this->getWindowWidth());
+
+ // move overlay "above" the top edge of the screen
+ // we take -1.2 because the border makes the panel bigger
+ this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+
+ Shell::getInstance().addOutputLevel(true);
+
+ COUT(4) << "Info: InGameConsole initialized" << std::endl;
+ }
+
+ // ###############################
+ // ### ShellListener methods ###
+ // ###############################
+
+ /**
+ @brief Called if all output-lines have to be redrawn.
+ */
+ void InGameConsole::linesChanged()
+ {
+ std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+ int max = 0;
+ for (int i = 1; i < LINES; ++i)
+ {
+ if (it != Shell::getInstance().getEndIterator())
+ {
+ ++it;
+ max = i;
+ }
+ else
+ break;
+ }
+
+ for (int i = LINES - 1; i > max; --i)
+ this->print("", i, true);
+
+ for (int i = max; i >= 1; --i)
+ {
+ --it;
+ this->print(*it, i, true);
+ }
+ }
+
+ /**
+ @brief Called if only the last output-line has changed.
+ */
+ void InGameConsole::onlyLastLineChanged()
+ {
+ if (LINES > 1)
+ this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+ }
+
+ /**
+ @brief Called if a new output-line was added.
+ */
+ void InGameConsole::lineAdded()
+ {
+ this->numLinesShifted_ = 0;
+ this->shiftLines();
+ this->onlyLastLineChanged();
+ }
+
+ /**
+ @brief Called if the text in the input-line has changed.
+ */
+ void InGameConsole::inputChanged()
+ {
+ if (LINES > 0)
+ this->print(Shell::getInstance().getInput(), 0);
+
+ if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+ this->inputWindowStart_ = 0;
+ }
+
+ /**
+ @brief Called if the position of the cursor in the input-line has changed.
+ */
+ void InGameConsole::cursorChanged()
+ {
+ unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+ if (pos > maxCharsPerLine_)
+ pos = maxCharsPerLine_;
+
+ this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
+ this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24);
+ }
+
+ /**
+ @brief Called if the console gets closed.
+ */
+ void InGameConsole::exit()
+ {
+ this->deactivate();
+ }
+
+ // ###############################
+ // ### other external calls ###
+ // ###############################
+
+ /**
+ @brief Used to control the actual scrolling and the cursor.
+ */
+ void InGameConsole::update(const Clock& time)
+ {
+ if (this->scroll_ != 0)
+ {
+ float oldTop = this->consoleOverlayContainer_->getTop();
+
+ if (this->scroll_ > 0)
+ {
+ // scrolling down
+ // enlarge oldTop a little bit so that this exponential function
+ // reaches 0 before infinite time has passed...
+ float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_;
+ if (oldTop - deltaScroll >= 0)
+ {
+ // window has completely scrolled down
+ this->consoleOverlayContainer_->setTop(0);
+ this->scroll_ = 0;
+ }
+ else
+ this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+ }
+
+ else
+ {
+ // scrolling up
+ // note: +0.01 for the same reason as when scrolling down
+ float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
+ if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+ {
+ // window has completely scrolled up
+ this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+ this->scroll_ = 0;
+ this->consoleOverlay_->hide();
+ }
+ else
+ this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+ }
+ }
+
+ if (this->bActive_)
+ {
+ this->cursor_ += time.getDeltaTime();
+ if (this->cursor_ >= this->blinkTime)
+ {
+ this->cursor_ = 0;
+ bShowCursor_ = !bShowCursor_;
+ if (bShowCursor_)
+ this->consoleOverlayCursor_->show();
+ else
+ this->consoleOverlayCursor_->hide();
+ }
+
+ // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
+ float uRand = (rand() & 1023) / 1023.0f * 0.2f;
+ float vRand = (rand() & 1023) / 1023.0f * 0.2f;
+ this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
+ }
+ }
+
+ /**
+ @brief Resizes the console elements. Call if window size changes.
+ */
+ void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
+ {
+ this->windowW_ = newWidth;
+ this->windowH_ = newHeight;
+ this->consoleOverlayBorder_->setWidth(static_cast<int>(this->windowW_* this->relativeWidth));
+ this->consoleOverlayBorder_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight));
+ this->consoleOverlayNoise_->setWidth(static_cast<int>(this->windowW_ * this->relativeWidth) - 10);
+ this->consoleOverlayNoise_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight) - 5);
+ this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
+
+ // now adjust the text lines...
+ this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
+
+ if (LINES > 0)
+ this->maxCharsPerLine_ = std::max(10U, static_cast<unsigned int>(static_cast<float>(this->desiredTextWidth_) / CHAR_WIDTH));
+ else
+ this->maxCharsPerLine_ = 10;
+
+ for (int i = 0; i < LINES; i++)
+ {
+ this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+ this->consoleOverlayTextAreas_[i]->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24 - 14*i);
+ }
+
+ this->linesChanged();
+ this->cursorChanged();
+ }
+
+ // ###############################
+ // ### internal methods ###
+ // ###############################
+
+ /**
+ @brief Prints string to bottom line.
+ @param s String to be printed
+ */
+ void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
+ {
+ char level = 0;
+ if (text.size() > 0)
+ level = text[0];
+
+ std::string output = text;
+
+ if (level >= -1 && level <= 5)
+ output.erase(0, 1);
+
+ if (LINES > index)
+ {
+ this->colourLine(level, index);
+
+ if (index > 0)
+ {
+ unsigned int linesUsed = 1;
+ while (output.size() > this->maxCharsPerLine_)
+ {
+ ++linesUsed;
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
+ output.erase(0, this->maxCharsPerLine_);
+ output.insert(0, 1, ' ');
+ if (linesUsed > numLinesShifted_ || alwaysShift)
+ this->shiftLines();
+ this->colourLine(level, index);
+ }
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+ this->displayedText_ = output;
+ this->numLinesShifted_ = linesUsed;
+ }
+ else
+ {
+ if (output.size() > this->maxCharsPerLine_)
+ {
+ if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
+ this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
+ else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+ this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
+
+ output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
+ }
+ else
+ this->inputWindowStart_ = 0;
+ this->displayedText_ = output;
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+ }
+ }
+ }
+
+ /**
+ @brief Shows the InGameConsole.
+ */
+ void InGameConsole::activate()
+ {
+ if (!this->bActive_)
+ {
+ this->bActive_ = true;
+ InputManager::getInstance().enterState("console");
+ Shell::getInstance().registerListener(this);
+
+ this->windowResized(this->windowW_, this->windowH_);
+ this->linesChanged();
+ this->cursorChanged();
+ this->consoleOverlay_->show();
+
+ // scroll down
+ this->scroll_ = 1;
+ // the rest is done by tick
+ }
+ }
+
+ /**
+ @brief Hides the InGameConsole.
+ */
+ void InGameConsole::deactivate()
+ {
+ if (this->bActive_)
+ {
+ this->bActive_ = false;
+ InputManager::getInstance().leaveState("console");
+ Shell::getInstance().unregisterListener(this);
+
+ // scroll up
+ this->scroll_ = -1;
+ // the rest is done by tick
+ }
+ }
+
+ /**
+ @brief Shifts all output lines one line up
+ */
+ void InGameConsole::shiftLines()
+ {
+ for (unsigned int i = LINES - 1; i > 1; --i)
+ {
+ this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
+ this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
+ this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
+ }
+ }
+
+ void InGameConsole::colourLine(int colourcode, int index)
+ {
+ if (colourcode == -1)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.90, 0.90, 0.90, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
+ }
+ else if (colourcode == 1)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.25, 0.25, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
+ }
+ else if (colourcode == 2)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.50, 0.20, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
+ }
+ else if (colourcode == 3)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.50, 0.50, 0.95, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
+ }
+ else if (colourcode == 4)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.65, 0.48, 0.44, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
+ }
+ else if (colourcode == 5)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.40, 0.20, 0.40, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
+ }
+ else
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.21, 0.69, 0.21, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
+ }
+ }
+
+ // ###############################
+ // ### satic methods ###
+ // ###############################
+
+ /**
+ @brief Activates the console.
+ */
+ /*static*/ void InGameConsole::openConsole()
+ {
+ InGameConsole::getInstance().activate();
+ }
+
+ /**
+ @brief Deactivates the console.
+ */
+ /*static*/ void InGameConsole::closeConsole()
+ {
+ InGameConsole::getInstance().deactivate();
+ }
+}
Copied: code/branches/libraries2/src/orxonox/overlays/InGameConsole.h (from rev 5727, code/branches/libraries2/src/orxonox/InGameConsole.h)
===================================================================
--- code/branches/libraries2/src/orxonox/overlays/InGameConsole.h (rev 0)
+++ code/branches/libraries2/src/orxonox/overlays/InGameConsole.h 2009-08-31 20:51:36 UTC (rev 5732)
@@ -0,0 +1,118 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Felix Schulthess
+ * Co-authors:
+ * Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _InGameConsole_H__
+#define _InGameConsole_H__
+
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "util/OgreForwardRefs.h"
+#include "util/Singleton.h"
+#include "core/Shell.h"
+#include "core/WindowEventListener.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
+ {
+ friend class Singleton<InGameConsole>;
+ public: // functions
+ InGameConsole();
+ ~InGameConsole();
+
+ void initialise();
+ void destroy();
+ void setConfigValues();
+
+ void update(const Clock& time);
+
+ static void openConsole();
+ static void closeConsole();
+
+ private: // functions
+ InGameConsole(const InGameConsole& other);
+
+ void activate();
+ void deactivate();
+
+ void linesChanged();
+ void onlyLastLineChanged();
+ void lineAdded();
+ void inputChanged();
+ void cursorChanged();
+ void exit();
+
+ void shiftLines();
+ void colourLine(int colourcode, int index);
+ void setCursorPosition(unsigned int pos);
+ void print(const std::string& text, int index, bool alwaysShift = false);
+
+ void windowResized(unsigned int newWidth, unsigned int newHeight);
+
+ // config value related
+ void bHidesAllInputChanged();
+
+ private: // variables
+ bool bActive_;
+ int windowW_;
+ int windowH_;
+ int desiredTextWidth_;
+ unsigned int maxCharsPerLine_;
+ unsigned int numLinesShifted_;
+ int scroll_;
+ float cursor_;
+ unsigned int inputWindowStart_;
+ bool bShowCursor_;
+ std::string displayedText_;
+ Ogre::Overlay* consoleOverlay_;
+ Ogre::OverlayContainer* consoleOverlayContainer_;
+ Ogre::PanelOverlayElement* consoleOverlayNoise_;
+ Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
+ Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
+ Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+
+ // input related
+ InputState* inputState_;
+
+ // config values
+ float relativeWidth;
+ float relativeHeight;
+ float blinkTime;
+ float scrollSpeed_;
+ float noiseSize_;
+ char cursorSymbol_;
+ bool bHidesAllInput_;
+
+ static InGameConsole* singletonPtr_s;
+ };
+}
+
+#endif /* _InGameConsole_H__ */
Copied: code/branches/libraries2/src/orxonox/overlays/Map.cc (from rev 5727, code/branches/libraries2/src/orxonox/Map.cc)
===================================================================
--- code/branches/libraries2/src/orxonox/overlays/Map.cc (rev 0)
+++ code/branches/libraries2/src/orxonox/overlays/Map.cc 2009-08-31 20:51:36 UTC (rev 5732)
@@ -0,0 +1,456 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Si Sun
+ *
+ */
+
+#include "Map.h"
+
+#include <string>
+
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreCamera.h>
+#include <OgreEntity.h>
+#include <OgreHardwarePixelBuffer.h>
+#include <OgreMaterialManager.h>
+#include <OgreMovablePlane.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayContainer.h>
+#include <OgreOverlayManager.h>
+#include <OgrePass.h>
+#include <OgreRenderTexture.h>
+#include <OgreResourceGroupManager.h>
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreTechnique.h>
+#include <OgreTexture.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
+
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "interfaces/RadarViewable.h"
+#include "objects/Scene.h"
+#include "objects/controllers/HumanController.h"
+#include "objects/worldentities/CameraPosition.h"
+#include "objects/worldentities/ControllableEntity.h"
+
+ namespace orxonox
+ {
+ CreateFactory(Map);
+ SetConsoleCommand(Map, openMap, true);
+ //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
+ //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
+ SetConsoleCommand(Map, Zoom, true).setAsInputCommand();
+
+
+ Map* Map::singletonMap_s = 0;
+ Ogre::SceneManager* Map::mapSceneM_s = 0;
+ Ogre::Camera* Map::Cam_ = 0;
+ Ogre::SceneNode* Map::CamNode_ = 0;
+ Ogre::MaterialPtr Map::OverlayMaterial_;// = init();
+ Ogre::Overlay* Map::overlay_ = 0;
+/*
+Ogre::MaterialPtr Map::init()
+{
+ Ogre::MaterialPtr tmp;
+ tmp.setNull();
+ return tmp;
+}
+*/
+
+ //int Map::mouseLookSpeed_ = 200;
+ //Ogre::SceneNode* Map::playerShipNode_ = 0;
+
+ const int PITCH=-30;
+ const int DISTANCE=200;
+
+ Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
+ {
+ RegisterObject(Map);
+ Map::singletonMap_s=this;
+
+ //Getting Scene Manager (Hack)
+ if( !sManager_ )
+ {
+ ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
+ this->sManager_ = it->getSceneManager();
+ }
+ if( !Map::getMapSceneManager() )
+ {
+ Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
+ }
+
+ this->playerShipNode_ = 0;
+ //this->sNode_ = new Ogre::SceneNode(sManager_);
+ //oManager_ = Ogre::OverlayManager::getSingletonPtr();
+ //overlay_ = oManager_->create("Map");
+ //overlay_ is member of OrxonoxOverlay
+
+ //Not Showing the map as default
+ //this->isVisible_=false;
+ //overlay_->hide();
+ this->mouseLookSpeed_ = 200;
+
+ //TestEntity
+ //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
+
+ //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
+ /*sNode_->setPosition(0,0,-50);
+ overlay_->add3D(sNode_);
+ */
+
+
+
+
+
+ // Alter the camera aspect ratio to match the viewport
+ //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
+ if(!Map::Cam_)
+ Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
+ //Cam_->setPosition(200,170, -160);
+ //Cam_->lookAt(0,0,0);
+ Cam_->setAspectRatio(1);
+ //Cam_->setRenderingDistance(0);
+ if(!Map::CamNode_)
+ CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
+
+
+ //Create overlay material
+ if(Map::OverlayMaterial_.isNull())
+ Map::OverlayMaterial_ = this->createRenderCamera(Cam_, "RttMat");
+/*
+ Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
+
+ Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
+
+ renderTexture->addViewport(Cam_);
+ renderTexture->getViewport(0)->setClearEveryFrame(true);
+ renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
+ renderTexture->getViewport(0)->setOverlaysEnabled(false);
+
+ Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ Ogre::Technique *technique = material->createTechnique();
+ technique->createPass();
+ material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+ material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
+*/
+
+
+ // create overlay
+/*
+ Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1");
+
+ // Create a panel with RenderToTexture texture
+ Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
+ m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
+ m_pOverlayPanel->setPosition(10, 10);
+ m_pOverlayPanel->setDimensions(500, 300);
+ // Give overlay a texture
+ m_pOverlayPanel->setMaterialName(camMat_id);
+ pOverlay->add2D(m_pOverlayPanel);
+ pOverlay->show();
+*/
+ if(!this->overlay_)
+ {
+ this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
+ Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
+ //m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
+ //m_pOverlayPanel->setPosition(10, 10);
+ //m_pOverlayPanel->setDimensions(600, 400);
+ m_pOverlayPanel->setPosition(0.01, 0.003);
+ m_pOverlayPanel->setDimensions(0.5, 0.4);
+ // Give overlay a texture
+ m_pOverlayPanel->setMaterialName("RttMat");
+ overlay_->add2D(m_pOverlayPanel);
+
+ //Add Borders
+ Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
+ oBorder->setBorderSize( 0.003, 0.003 );
+ oBorder->setDimensions(0.5, 0.4);
+ oBorder->setBorderMaterialName("StatsBorder");
+ oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
+ oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
+ oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
+ oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+ oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+ oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+ oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+ oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+ //overlay_->add2D(oBorder);
+ m_pOverlayPanel->addChild(oBorder);
+ }
+
+
+ //Not Showing the map as default
+ this->isVisible_=false;
+ overlay_->hide();
+
+ //Create plane to show gridTypeError: blimport() takes no keyword arguments
+/* Ogre::Entity* plane_ent;
+ if(Map::getMapSceneManager()->hasEntity("MapPlane"))
+ plane_ent = Map::getMapSceneManager()->getEntity("MapPlane");
+ else
+ plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
+*/
+ this->movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
+ this->movablePlane_->normalise();
+
+ if(!Map::getMapSceneManager()->hasEntity("MapPlane"))
+ {
+ Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
+ planeNode_ = Map::getMapSceneManager()->createSceneNode();
+ //Create plane for calculations
+
+
+ //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
+ //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
+ //plane_ent->setMaterialName("mapgrid");
+ plane_ent->setMaterialName("Map/Grid");
+ planeNode_->attachObject(plane_ent);
+
+ planeNode_->scale(160,1,160);
+// planeNode_->attachObject(movablePlane_);
+ //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
+
+
+ //ToDo create material script
+ Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
+ myManualObjectMaterial->setReceiveShadows(false);
+ myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
+ myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
+ myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
+ myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
+ }
+ }
+
+ Map::~Map()
+ {
+ this->singletonMap_s = 0;
+ //delete this->overlay_;
+ /*if (this->isInitialized())
+ {
+ //delete sManager_;
+ //delete Map::getMapSceneManager()->getRootSceneNode();
+ //delete oManager_;
+ //delete CamNode_;
+ //delete Cam_;
+ //delete mapSceneM_s;
+ //Map::getMapSceneManager()->destroyAllEntities();
+ //Map::getMapSceneManager()->destroyAllCameras();
+ delete Map::getMapSceneManager();
+ }*/
+ }
+
+ Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, const std::string& matName)
+ {
+ Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(matName+"_tex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
+
+ Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
+
+ renderTexture->addViewport(cam);
+ renderTexture->getViewport(0)->setClearEveryFrame(true);
+ renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
+ renderTexture->getViewport(0)->setOverlaysEnabled(false);
+
+ Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ Ogre::Technique *technique = material->createTechnique();
+ technique->createPass();
+ material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+ material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex");
+ return material;
+ }
+
+ void Map::updatePositions()
+ {
+
+//Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh");
+ for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
+ it!=ObjectList<orxonox::RadarViewable>::end();
+ it++)
+ {
+ //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
+ //Ogre::SceneNode node = it->getMapNode();
+ //Ogre::Entity ent = it->getMapEntity();
+ if( !(it->MapNode_) )
+ {
+ it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() );
+ //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
+ /*if(it->getRadarObjectShape() == RadarViewable::Dot)
+ {
+ //if( !(it->MapEntity_) )//check wether the entity is already attached
+ //{
+ //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh");
+ //it->addEntity();
+ //it->MapNode_->attachObject( it->MapEntity_ );
+ //it->MapNode_->attachObject( it->line_ );
+ // }
+ }*/
+ it->addMapEntity();
+ }
+ if(it->isHumanShip_)
+ {
+ this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
+ if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_)
+ {
+ this->playerShipNode_ = it->MapNode_;
+ if(planeNode_ && this->planeNode_->getParent())
+ this->planeNode_->getParent()->removeChild(this->planeNode_);
+ this->playerShipNode_->addChild(this->planeNode_);
+ //Movable Plane needs to be attached direcly for calculations
+ //this->movablePlane_->detatchFromParent();
+ //this->movablePlane_->getParentSceneNode()->detachObject(this->movablePlane_);
+ //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
+ //it->MapNode_->attachObject(this->movablePlane_);
+ if(planeNode_ && this->CamNode_->getParent())
+ this->CamNode_->getParent()->removeChild(this->CamNode_);
+ this->playerShipNode_->addChild(this->CamNode_);
+ this->CamNode_->attachObject(this->Cam_);
+ //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode();
+ //this->CamNodeHelper_->attachObject(this->Cam_);
+ this->Cam_->setPosition(0, 0, DISTANCE);
+ this->Cam_->pitch( static_cast<Degree>(PITCH) );
+ this->Cam_->lookAt(this->playerShipNode_->getPosition());
+ //this->Cam_->setAutoTracking(true, this->playerShipNode_);
+ }
+ }
+ it->updateMapPosition();
+
+
+
+
+
+
+ }
+ }
+
+
+
+ void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+ {
+ SUPER(Map, XMLPort, xmlElement, mode);
+ }
+
+ void Map::changedOwner()
+ {
+ SUPER(Map, changedOwner);
+ //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
+
+ ControllableEntity* entity = orxonox_cast<ControllableEntity*>(this->getOwner());
+ if(entity && entity->getReverseCamera())
+ {
+ //COUT(0) << "foo";
+ entity->getReverseCamera()->attachCamera(this->Cam_);
+ }
+ }
+
+
+ void Map::toggleVisibility()
+ {
+ if (!(this->isVisible_))
+ {
+ this->overlay_->show();
+ this->isVisible_=1;
+ //set mouselook when showing map
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
+ HumanController::localController_s->controllableEntity_->mouseLook();
+ }
+ else
+ {
+ this->overlay_->hide();
+ this->isVisible_=0;
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
+ HumanController::localController_s->controllableEntity_->mouseLook();
+ }
+ }
+
+ //Static function to toggle visibility of the map
+ void Map::openMap()
+ {
+ for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
+ it!=ObjectList<orxonox::Map>::end();
+ it++)
+ {
+ //Map * m = it->getMap();
+ //COUT(0) << it->isVisible_ << std::endl;
+ it->toggleVisibility();
+ //it->updatePositions();
+ }
+ }
+
+ // HACK!
+ void Map::hackDestroyMap()
+ {
+ Map::OverlayMaterial_.setNull();
+ }
+
+ void Map::tick(float dt)
+ {
+ //Debug
+ //COUT(0) << "MovablePlane Position: " << this->movablePlane_->getParentSceneNode()->getName() << this->movablePlane_->getParentSceneNode()->getPosition() << std::endl;
+ //COUT(0) << "planeNode_ Position: " << this->planeNode_ ->getName() << this->planeNode_->getPosition() << std::endl;
+ //COUT(0) << "planeNode_ Parrent Position" << this->planeNode_->getParent()->getName() << this->planeNode_->getParent()->getPosition() << std::endl;
+ if( this->isVisible_ )
+ updatePositions();
+ //Cam_->roll(Degree(1));
+
+ }
+
+ void Map::rotateYaw(const Vector2& value)
+ {
+ if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+ return;
+
+/*
+ singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
+
+ Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
+ Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
+*/
+ singletonMap_s->CamNode_->yaw( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
+ }
+
+ void Map::rotatePitch(const Vector2& value)
+ {
+ if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+ return;
+ //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
+/* singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
+
+ Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
+ Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
+*/
+ singletonMap_s->CamNode_->pitch( static_cast<Degree>(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
+
+ }
+
+ void Map::Zoom(const Vector2& value)
+ {
+ if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+ return;
+ //COUT(0) << value.y << std::endl;
+ Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ );
+ }
+ }
Copied: code/branches/libraries2/src/orxonox/overlays/Map.h (from rev 5727, code/branches/libraries2/src/orxonox/Map.h)
===================================================================
--- code/branches/libraries2/src/orxonox/overlays/Map.h (rev 0)
+++ code/branches/libraries2/src/orxonox/overlays/Map.h 2009-08-31 20:51:36 UTC (rev 5732)
@@ -0,0 +1,118 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Si Sun
+ *
+ */
+
+#ifndef _Map_H__
+#define _Map_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreMaterial.h>
+
+#include "util/UtilPrereqs.h"
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OrxonoxOverlay.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Map : public OrxonoxOverlay, public Tickable
+ {
+
+ public: // functions
+ Map(BaseObject* creator);
+ virtual ~Map();
+
+ virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+ virtual void changedOwner();
+
+ static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, const std::string& matName);
+
+ static void openMap();
+ // HACK!
+ static void hackDestroyMap();
+
+//Not yet implemented
+ static const int maxRange_s=1000;
+
+ static void rotateYaw(const Vector2& value);
+ static void rotatePitch(const Vector2& value);
+ static void Zoom(const Vector2& value);
+ // variables
+
+
+ bool inline getVisibility()
+ { return this->isVisible_; };
+
+ static inline Ogre::SceneManager* getMapSceneManagerPtr()
+ {
+ return Map::singletonMap_s->mapSceneM_s;
+ }
+ static inline Map* getSingletonPtr()
+ {
+ return Map::singletonMap_s;
+ }
+
+ static inline Ogre::SceneManager* getMapSceneManager()
+ {
+ return Map::mapSceneM_s;
+ }
+
+
+
+ private: // functions
+
+ void toggleVisibility();
+ void updatePositions();
+// void changedPlayerNode();
+ static inline void setMapSceneManager( Ogre::SceneManager * sm)
+ {
+ Map::mapSceneM_s = sm;
+ }
+ //static Ogre::MaterialPtr init();
+
+ private: // variables
+ static Map* singletonMap_s;
+
+ Ogre::SceneManager* sManager_;
+ Ogre::OverlayManager * oManager_;
+
+ static Ogre::SceneManager* mapSceneM_s;
+ static Ogre::SceneNode* CamNode_;
+ static Ogre::Camera* Cam_;
+ static Ogre::MaterialPtr OverlayMaterial_;
+ static Ogre::Overlay* overlay_;
+ //Ogre::SceneNode* CamNodeHelper_;
+ Ogre::SceneNode* playerShipNode_;
+ Ogre::SceneNode* planeNode_;
+ Ogre::MovablePlane* movablePlane_;
+ int mouseLookSpeed_;
+ bool isVisible_;
+
+ friend class RadarViewable;
+ };
+}
+
+#endif /* _Map_H__ */
More information about the Orxonox-commit
mailing list