Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/CameraManager.cc

    r7879 r8079  
    2929#include "CameraManager.h"
    3030
     31#include <cassert>
     32
    3133#include <OgreSceneManager.h>
    3234#include <OgreViewport.h>
    3335#include <OgreCompositorManager.h>
    3436
    35 #include "util/StringUtils.h"
    3637#include "util/ScopedSingletonManager.h"
    3738#include "core/GameMode.h"
    3839#include "core/GraphicsManager.h"
    39 #include "core/GUIManager.h"
    4040#include "core/ObjectList.h"
    4141#include "tools/Shader.h"
    4242#include "graphics/Camera.h"
    43 #include "Scene.h"
    4443
    4544namespace orxonox
     
    4847
    4948    CameraManager::CameraManager()
    50         : viewport_(GraphicsManager::getInstance().getViewport())
    5149    {
    5250        assert(GameMode::showsGraphics());
     
    5553    CameraManager::~CameraManager()
    5654    {
    57         GUIManager::getInstance().setCamera(0);
    5855    }
    5956
     
    9592            if (!this->cameraList_.empty())
    9693                this->cameraList_.front()->setFocus();
     94            else
     95                this->useCamera(NULL);
    9796        }
    9897        else
     
    102101    void CameraManager::useCamera(Ogre::Camera* camera)
    103102    {
    104         // This workaround is needed to avoid weird behaviour with active compositors while
    105         // switching the camera (like freezing the image)
    106         //
    107         // Last known Ogre version needing this workaround:
    108         // 1.4.8
    109         // 1.7.2
    110 
    111         // deactivate all compositors
    112         {
    113             Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();
    114             while (iterator.hasMoreElements())
    115                 Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false);
    116         }
    117 
    118         this->viewport_->setCamera(camera);
    119         GUIManager::getInstance().setCamera(camera);
    120 
    121         // reactivate all visible compositors
    122         {
    123             for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it)
    124                 it->updateVisibility();
    125         }
     103        GraphicsManager::getInstance().setCamera(camera);
    126104    }
    127105}
  • code/trunk/src/orxonox/CameraManager.h

    r6746 r8079  
    3838#include "OrxonoxPrereqs.h"
    3939
    40 #include <cassert>
    4140#include <list>
    4241#include "util/OgreForwardRefs.h"
    4342#include "util/Singleton.h"
    4443#include "core/OrxonoxClass.h"
    45 #include "core/SmartPtr.h"
    4644
    4745namespace orxonox
     
    6563
    6664            std::list<Camera*>    cameraList_;
    67             Ogre::Viewport*       viewport_;
    6865
    6966            static CameraManager* singletonPtr_s;
  • code/trunk/src/orxonox/ChatInputHandler.cc

    r7284 r8079  
    2828
    2929#include "ChatInputHandler.h"
     30
     31#include <cassert>
     32#include <string>
     33#include <CEGUIWindow.h>
     34#include <CEGUIWindowManager.h>
     35#include <elements/CEGUIListbox.h>
     36#include <elements/CEGUIListboxItem.h>
     37#include <elements/CEGUIListboxTextItem.h>
     38
    3039#include "util/ScopedSingletonManager.h"
    3140#include "core/CoreIncludes.h"
    3241#include "core/GUIManager.h"
    33 #include "core/CorePrereqs.h"
    3442#include "core/command/ConsoleCommand.h"
    35 #include <CEGUIWindow.h>
    36 #include <elements/CEGUIListbox.h>
    37 #include <elements/CEGUIListboxItem.h>
    38 #include <elements/CEGUIListboxTextItem.h>
    39 #include <CEGUIWindowManager.h>
    40 #include <string>
     43#include "core/input/InputBuffer.h"
     44#include "core/input/InputManager.h"
     45#include "core/input/InputState.h"
     46#include "network/Host.h"
     47
     48#include "PlayerManager.h"
     49#include "infos/PlayerInfo.h"
    4150
    4251namespace orxonox
     
    7281    this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
    7382    this->inputState->setKeyHandler(this->inpbuf);
     83  }
     84
     85  ChatInputHandler::~ChatInputHandler()
     86  {
     87    /* Clean up */
     88    InputManager::getInstance().destroyState("chatinput");
     89    delete this->inpbuf;
    7490  }
    7591
     
    125141    // reds
    126142    for( i = 0; i < NumberOfColors/3; ++i )
    127     { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
    128       assert( this->text_colors[ i ] );
     143    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
    129144      green += 0.2f, blue += 0.2f;
    130145    }
     
    133148    red = 0.5, green = 1, blue = 0.5;
    134149    for( ; i < NumberOfColors*2/3; ++i )
    135     { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
    136       assert( this->text_colors[ i ] );
     150    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
    137151      red += 0.2f, blue += 0.2f;
    138152    }
     
    141155    red = 0.5, green = 0.5, blue = 1;
    142156    for( ; i < NumberOfColors; ++i )
    143     { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
    144       assert( this->text_colors[ i ] );
     157    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
    145158      red += 0.2f, green += 0.2f;
    146159    }
     
    196209
    197210    /* set the color according to the hash */
    198     tocolor->setTextColours( *(this->text_colors[ hash ]) );
     211    tocolor->setTextColours( this->text_colors[ hash ] );
    199212  }
    200213
  • code/trunk/src/orxonox/ChatInputHandler.h

    r7163 r8079  
    3030#define _ChatInputHandler_H__
    3131
    32 /* std includes */
    33 #include <deque>
     32#include <OrxonoxPrereqs.h>
     33
    3434#include <string>
    35 #include <fstream>
    36 #include <iostream>
    37 #include <cassert>
    3835#include <CEGUIForwardRefs.h>
     36#include <CEGUIcolour.h>
    3937
    40 /* project includes */
    41 #include <OrxonoxPrereqs.h>
    42 #include <core/BaseObject.h>
    43 #include <core/PathConfig.h>
    44 
    45 #include "core/input/InputBuffer.h"
    46 #include "core/input/InputManager.h"
    47 #include "core/input/InputState.h"
    48 
    49 #include <network/ChatListener.h>
    50 #include <PlayerManager.h>
    51 #include <infos/PlayerInfo.h>
    52 
    53 #include "../libraries/network/Host.h"
    54 #include <util/Singleton.h>
     38#include "util/Singleton.h"
     39#include "network/ChatListener.h"
    5540
    5641namespace orxonox // tolua_export
     
    7055      /* colors for nickname coloring */
    7156      static const int NumberOfColors = 10;
    72       CEGUI::colour *text_colors[ NumberOfColors ];
     57      CEGUI::colour text_colors[ NumberOfColors ];
    7358
    7459      /** input state */
     
    11095      /** constructor */
    11196      ChatInputHandler();
     97      ~ChatInputHandler();
    11298      friend class Singleton<ChatInputHandler>;
    11399
  • code/trunk/src/orxonox/LevelInfo.h

    r7804 r8079  
    109109            @return Returns the XML-filename (including *.oxw extension) of the Level.
    110110            */
    111             inline const std::string& getXMLFilename(void) { return this->xmlfilename_; } // tolua_export
     111            inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export
    112112
    113113        protected:
     
    212212    {
    213213        bool operator() (const LevelInfoItem* lhs, const LevelInfoItem* rhs) const
    214             { return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0; }
     214            {
     215                if(getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) == 0)
     216                    return getLowercase(lhs->getXMLFilename()).compare(getLowercase(rhs->getXMLFilename())) < 0;
     217                return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0;
     218            }
    215219    };
    216220   
  • code/trunk/src/orxonox/LevelManager.cc

    r7839 r8079  
    7575    LevelManager::~LevelManager()
    7676    {
     77        // Delete all the LevelInfoItem objects because the LevelManager created them
     78        std::set<LevelInfoItem*, LevelInfoCompare>::iterator it = availableLevels_.begin();
     79        for (; it != availableLevels_.end(); ++it)
     80            delete *it;
    7781    }
    7882
     
    237241    void LevelManager::compileAvailableLevelList()
    238242    {
     243        // Get all files matching the level criteria
    239244        Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
    240         // Iterate over all *.oxw level files.
     245
     246        // We only want to load as little as possible
     247        ClassTreeMask mask;
     248        mask.exclude(Class(BaseObject));
     249        mask.include(Class(LevelInfo));
     250
     251        // Iterate over all the found *.oxw files
    241252        COUT(3) << "Loading LevelInfos..." << std::endl;
     253        std::set<std::string> names;
    242254        for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
    243255        {
    244             //TODO: Replace with tag?
     256            // TODO: Replace with tag?
    245257            if (it->find("old/") != 0)
    246258            {
    247                 size_t pos = it->find(".oxw");
     259                LevelInfoItem* info = NULL;
    248260
    249261                // Load the LevelInfo object from the level file.
    250                 bool infoExists = false;
    251262                XMLFile file = XMLFile(*it);
    252                 ClassTreeMask mask = ClassTreeMask();
    253                 mask.exclude(ClassIdentifier<BaseObject>::getIdentifier());
    254                 mask.include(ClassIdentifier<LevelInfo>::getIdentifier());
    255                 Loader::load(&file, mask, false);
    256                 // Iterate over all LevelInfos.
     263                Loader::load(&file, mask, false, true);
     264
     265                // Find the LevelInfo object we've just loaded (if there was one)
    257266                for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)
     267                    if(item->getXMLFilename() == *it)
     268                        info = item->copy();
     269
     270                // We don't need the loaded stuff anymore
     271                Loader::unload(&file);
     272
     273                if(info == NULL)
    258274                {
    259                     LevelInfoItem* info = item->copy();
    260                     if(info->getXMLFilename() == *it) // If the LevelInfo for this level exists we insert it into the list of available levels.
    261                     {
    262                         this->availableLevels_.insert(info);
    263                         infoExists = true;
    264                     }
     275                    // Create a default LevelInfoItem object that merely contains the name
     276                    std::string filenameWOExtension = it->substr(0, it->find(".oxw"));
     277                    info = new LevelInfoItem(filenameWOExtension, *it);
    265278                }
    266                 Loader::unload(&file, mask);
    267                 if(!infoExists) // If the LevelInfo for this level doesn't exist, we create a new one and insert it into the list of available levels.
    268                     this->availableLevels_.insert(new LevelInfoItem(it->substr(0, pos), *it));
     279
     280                // Warn about levels with the same name.
     281                if(!names.insert(info->getName()).second)
     282                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << std::endl;
     283
     284                // Warn about multiple items so that it gets fixed quickly
     285                if(availableLevels_.find(info) != availableLevels_.end())
     286                {
     287                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl;
     288                    // Delete LevelInfoItem to avoid a dangling pointer
     289                    delete info;
     290                }
     291                else
     292                    this->availableLevels_.insert(info);
    269293            }
    270294        }
  • code/trunk/src/orxonox/LevelManager.h

    r7804 r8079  
    112112            // Helpers to allow fast access to the availableLevels list.
    113113            unsigned int nextIndex_; //! The next expected index to be accessed.
    114             std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The nex expected Level to be accessed.
     114            std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The next expected Level to be accessed.
    115115
    116116            // config values
  • code/trunk/src/orxonox/controllers/HumanController.cc

    r7863 r8079  
    6161    SetConsoleCommand("HumanController", "cycleNavigationFocus",   &HumanController::cycleNavigationFocus).addShortcut();
    6262    SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut();
     63    SetConsoleCommand("HumanController", "myposition",             &HumanController::myposition    ).addShortcut();
    6364
    6465    CreateUnloadableFactory(HumanController);
     
    200201    void HumanController::toggleGodMode()
    201202    {
    202         HumanController::getLocalControllerSingleton()->setGodMode( !HumanController::getLocalControllerSingleton()->getGodMode() );
     203        if (HumanController::localController_s)
     204            HumanController::localController_s->setGodMode(!HumanController::localController_s->getGodMode());
     205    }
     206
     207    void HumanController::myposition()
     208    {
     209        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     210        {
     211            const Vector3& position = HumanController::localController_s->controllableEntity_->getPosition();
     212            const Quaternion& orientation = HumanController::localController_s->controllableEntity_->getOrientation();
     213
     214            COUT(0) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" ";
     215            COUT(0) << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << std::endl;
     216        }
    203217    }
    204218
  • code/trunk/src/orxonox/controllers/HumanController.h

    r7533 r8079  
    7373            static void suicide();
    7474            static void toggleGodMode();
     75            static void myposition();
    7576
    7677            static void addBots(unsigned int amount);
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r7879 r8079  
    4646#include "LevelManager.h"
    4747#include "PlayerManager.h"
     48#include "GSRoot.h"
    4849
    4950namespace orxonox
     
    5556
    5657    SetConsoleCommand(__CC_startMainMenu_name, &GSLevel::startMainMenu).deactivate();
    57     SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues(BLANKSTRING).deactivate();
     58    SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues("").deactivate();
    5859
    5960    GSLevel::GSLevel(const GameStateInfo& info)
     
    156157        COUT(0) << "Loading level..." << std::endl;
    157158        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
    158         Loader::open(startFile_);
     159        bool loaded = Loader::open(startFile_);
    159160
    160161        Core::getInstance().updateLastLevelTimestamp();
     162        if(!loaded)
     163            GSRoot::delayedStartMainMenu();
    161164    }
    162165
     
    202205    /*static*/ void GSLevel::changeGame(const std::string& level)
    203206    {
    204         if(level != BLANKSTRING)
     207        if(level != "")
    205208            LevelManager::getInstance().setDefaultLevel(level);
    206209
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r7876 r8079  
    5757    static const std::string __CC_setMainMenuSoundPath_name = "setMMSoundPath";
    5858
    59     SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).defaultValues(BLANKSTRING).deactivate();
    60     SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).defaultValues(BLANKSTRING).deactivate();
    61     SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).defaultValues(BLANKSTRING).deactivate();
    62     SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).defaultValues(BLANKSTRING).deactivate();
     59    SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).defaultValues("").deactivate();
     60    SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).defaultValues("").deactivate();
     61    SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).defaultValues("").deactivate();
     62    SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).defaultValues("").deactivate();
    6363    SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
    6464
     
    9696    {
    9797        // show main menu
     98        GraphicsManager::getInstance().setCamera(this->camera_);
    9899        GUIManager::getInstance().showGUI("MainMenu", true);
    99         GUIManager::getInstance().setCamera(this->camera_);
    100100        GUIManager::getInstance().setBackgroundImage("MainMenuBackground", "Background");
    101         GraphicsManager::getInstance().setCamera(this->camera_);
    102101
    103102        InputManager::getInstance().enterState("MainMenuHackery");
     
    129128        InputManager::getInstance().leaveState("MainMenuHackery");
    130129
    131         GUIManager::getInstance().setCamera(0);
     130        GraphicsManager::getInstance().setCamera(0);
    132131        GUIManager::getInstance().setBackgroundImage("");
    133132        GUIManager::hideGUI("MainMenu");
    134         GraphicsManager::getInstance().setCamera(0);
    135133
    136134        ModifyConsoleCommand(__CC_startStandalone_name).deactivate();
     
    178176    void GSMainMenu::startStandalone(const std::string& level)
    179177    {
    180         if(level != BLANKSTRING)
     178        if(level != "")
    181179            LevelManager::getInstance().setDefaultLevel(level);
    182180
     
    194192    void GSMainMenu::startServer(const std::string& level)
    195193    {
    196         if(level != BLANKSTRING)
     194        if(level != "")
    197195            LevelManager::getInstance().setDefaultLevel(level);
    198196
     
    210208    void GSMainMenu::startClient(const std::string& destination)
    211209    {
    212         if(destination != BLANKSTRING)
     210        if(destination != "")
    213211            Client::getInstance()->setDestination(destination, NETWORK_PORT);
    214212
     
    226224    void GSMainMenu::startDedicated(const std::string& level)
    227225    {
    228         if(level != BLANKSTRING)
     226        if(level != "")
    229227            LevelManager::getInstance().setDefaultLevel(level);
    230228
  • code/trunk/src/orxonox/gamestates/GSMainMenu.h

    r7876 r8079  
    5353        void setMainMenuSoundPath(const std::string& path);
    5454
    55         static void startStandalone(const std::string& level = BLANKSTRING); //!< Start a level in standalone mode.
    56         static void startServer(const std::string& level = BLANKSTRING); //!< Start a level in server mode.
    57         static void startClient(const std::string& destination = BLANKSTRING); //!< Connect to a game as client.
    58         static void startDedicated(const std::string& level = BLANKSTRING); //!< Start a level in dedicated mode.
     55        static void startStandalone(const std::string& level = ""); //!< Start a level in standalone mode.
     56        static void startServer(const std::string& level = ""); //!< Start a level in server mode.
     57        static void startClient(const std::string& destination = ""); //!< Connect to a game as client.
     58        static void startDedicated(const std::string& level = ""); //!< Start a level in dedicated mode.
    5959        static void startIOConsole();
    6060
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r7284 r8079  
    3838#include "tools/interfaces/Tickable.h"
    3939
     40#include "GSLevel.h"
     41
    4042namespace orxonox
    4143{
     
    4345
    4446    static const std::string __CC_setTimeFactor_name = "setTimeFactor";
     47    static const std::string __CC_setPause_name = "setPause";
    4548    static const std::string __CC_pause_name = "pause";
     49
     50    /*static*/ bool GSRoot::startMainMenu_s = false;
    4651
    4752    SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
    4853    SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0);
     54    SetConsoleCommand(__CC_setPause_name,      &GSRoot::setPause     ).accessLevel(AccessLevel::Master).hide();
    4955    SetConsoleCommand(__CC_pause_name,         &GSRoot::pause        ).accessLevel(AccessLevel::Master);
    5056
     
    8389
    8490        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this);
     91        ModifyConsoleCommand(__CC_setPause_name).setObject(this);
    8592        ModifyConsoleCommand(__CC_pause_name).setObject(this);
    8693    }
     
    8996    {
    9097        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0);
     98        ModifyConsoleCommand(__CC_setPause_name).setObject(0);
    9199        ModifyConsoleCommand(__CC_pause_name).setObject(0);
    92100    }
     
    94102    void GSRoot::update(const Clock& time)
    95103    {
     104        if(startMainMenu_s)
     105        {
     106            delayedStartMainMenu();
     107            startMainMenu_s = false;
     108        }
     109
    96110        for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
    97111        {
     
    157171    }
    158172
     173    void GSRoot::setPause(bool pause)
     174    {
     175        if (GameMode::isMaster())
     176        {
     177            if (pause != this->bPaused_)
     178                this->pause();
     179        }
     180    }
     181
    159182    void GSRoot::changedTimeFactor(float factor_new, float factor_old)
    160183    {
     
    162185            callStaticNetworkFunction(&TimeFactorListener::setTimeFactor, CLIENTID_UNKNOWN, factor_new);
    163186    }
     187
     188    /*static*/ void GSRoot::delayedStartMainMenu(void)
     189    {
     190        if(!startMainMenu_s)
     191            startMainMenu_s = true;
     192        else
     193            GSLevel::startMainMenu();
     194    }
     195
    164196}
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r7172 r8079  
    5151        // when taking the function address.
    5252        void setTimeFactor(float factor);
     53        void setPause(bool pause);
    5354        void pause();
     55
     56        static void delayedStartMainMenu(void);
    5457
    5558    protected:
     
    5962        bool                  bPaused_;
    6063        float                 timeFactorPauseBackup_;
     64        static bool           startMainMenu_s;
    6165    };
    6266}
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r7801 r8079  
    3030
    3131#include "util/Math.h"
     32#include "core/Core.h"
    3233#include "core/CoreIncludes.h"
    3334#include "core/ConfigValueIncludes.h"
     
    386387                    if (allplayersready && hashumanplayers)
    387388                    {
    388                         this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
     389                        // If in developer's mode, there is no start countdown.
     390                        if(Core::getInstance().inDevMode())
     391                            this->gtinfo_->startCountdown_ = 0;
     392                        else
     393                            this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    389394                        this->gtinfo_->bStartCountdownRunning_ = true;
    390395                    }
  • code/trunk/src/orxonox/graphics/Camera.cc

    r7163 r8079  
    6969        this->bHasFocus_ = false;
    7070        this->bDrag_ = false;
    71         this->nearClipDistance_ = 1;
    7271        this->lastDtLagged_ = false;
    7372
     
    7574
    7675        this->setConfigValues();
     76
     77        this->configvaluecallback_changedFovAndAspectRatio();
    7778        this->configvaluecallback_changedNearClipDistance();
    7879    }
     
    8283        if (this->isInitialized())
    8384        {
    84             if (GUIManager::getInstance().getCamera() == this->camera_)
    85                 GUIManager::getInstance().setCamera(NULL);
    8685            this->releaseFocus();
    8786
     
    9998    void Camera::setConfigValues()
    10099    {
    101         SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance);
     100        SetConfigValue(fov_, 80.0f)
     101            .description("Horizontal field of view in degrees")
     102            .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio);
     103        SetConfigValue(aspectRatio_, 1.0f)
     104            .description("Aspect ratio of pixels (width / height)")
     105            .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio);
     106        SetConfigValue(nearClipDistance_, 1.0f)
     107            .description("Distance from the camera where close objects will be clipped")
     108            .callback(this, &Camera::configvaluecallback_changedNearClipDistance);
     109    }
     110
     111    /**
     112        @brief Update FOV and the aspect ratio of the camera after the config values or the window's size have changed.
     113    */
     114    void Camera::configvaluecallback_changedFovAndAspectRatio()
     115    {
     116        // the aspect ratio of the window (width / height) has to be multiplied with the pixels aspect ratio (this->aspectRatio_)
     117        float aspectRatio = this->aspectRatio_ * this->getWindowWidth() / this->getWindowHeight();
     118        this->camera_->setAspectRatio(aspectRatio);
     119
     120        // Since we use horizontal FOV, we have to calculate FOVy by dividing by the aspect ratio and using some tangents
     121        Radian fovy(2 * atan(tan(Degree(this->fov_).valueRadians() / 2) / aspectRatio));
     122        this->camera_->setFOVy(fovy);
    102123    }
    103124
     
    105126    {
    106127        this->camera_->setNearClipDistance(this->nearClipDistance_);
     128    }
     129
     130    /**
     131        @brief Inherited from WindowEventListener.
     132    */
     133    void Camera::windowResized(unsigned int newWidth, unsigned int newHeight)
     134    {
     135        this->configvaluecallback_changedFovAndAspectRatio();
    107136    }
    108137
  • code/trunk/src/orxonox/graphics/Camera.h

    r6417 r8079  
    3333
    3434#include "util/OgreForwardRefs.h"
     35#include "core/WindowEventListener.h"
    3536#include "tools/interfaces/Tickable.h"
    3637#include "tools/interfaces/TimeFactorListener.h"
     
    3940namespace orxonox
    4041{
    41     class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener
     42    class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener
    4243    {
    4344        friend class CameraManager;
     
    6667            void removeFocus();
    6768            void setFocus();
     69
     70            void configvaluecallback_changedFovAndAspectRatio();
    6871            void configvaluecallback_changedNearClipDistance();
     72
     73            void windowResized(unsigned int newWidth, unsigned int newHeight);
    6974
    7075            Ogre::Camera*    camera_;
     
    7479            bool             bDrag_;
    7580            bool             lastDtLagged_;
     81            float            fov_;
     82            float            aspectRatio_;
    7683    };
    7784}
  • code/trunk/src/orxonox/graphics/GlobalShader.cc

    r5781 r8079  
    6161        SUPER(GlobalShader, XMLPort, xmlelement, mode);
    6262
    63         XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositor, getCompositor, xmlelement, mode);
     63        XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositorName, getCompositorName, xmlelement, mode);
    6464    }
    6565
     
    6767    {
    6868        registerVariable(this->bVisible_,                                         VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
    69         registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
     69        registerVariable(const_cast<std::string&>(this->shader_.getCompositorName()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositorName));
    7070    }
    7171
  • code/trunk/src/orxonox/graphics/GlobalShader.h

    r7163 r8079  
    5353        private:
    5454            void registerVariables();
    55             void changedCompositor();
    5655
    5756            Shader shader_;
  • code/trunk/src/orxonox/graphics/Model.cc

    r7183 r8079  
    6060    void Model::setConfigValues()
    6161    {
    62         SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableModelLoD", true)
     62        SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableMeshLoD", true)
    6363            .description("Enable level of detail for models");
    6464    }
  • code/trunk/src/orxonox/items/Engine.cc

    r7547 r8079  
    102102    void Engine::setConfigValues()
    103103    {
    104         SetConfigValue(blurStrength_, 3.0f);
     104        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
     105            .description("Enable or disable the motion blur effect when moving very fast")
     106            .callback(this, &Engine::changedEnableMotionBlur);
     107        SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
     108            .description("Defines the strength of the motion blur effect");
    105109    }
    106110
     
    204208        this->ship_->setSteeringDirection(Vector3::ZERO);
    205209
    206         if (!this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
     210        if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
    207211        {
    208212            this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
    209             this->boostBlur_->setCompositor("Radial Blur");
     213            this->boostBlur_->setCompositorName("Radial Blur");
    210214        }
    211215
    212216        if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    213             this->boostBlur_->setParameter("Ogre/Compositor/Radial_Blur", 0, 0, "sampleStrength", this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f));
     217        {
     218            float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f);
     219
     220            this->boostBlur_->setVisible(blur > 0);
     221            this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     222        }
    214223    }
    215224
     
    257266        return this->ship_->getWorldPosition();
    258267    }
     268
     269    void Engine::changedEnableMotionBlur()
     270    {
     271        if (!this->bEnableMotionBlur_)
     272        {
     273            this->boostBlur_->destroy();
     274            this->boostBlur_ = 0;
     275        }
     276    }
    259277}
  • code/trunk/src/orxonox/items/Engine.h

    r7552 r8079  
    127127            void registerVariables();
    128128            void networkcallback_shipID();
     129            void changedEnableMotionBlur();
    129130
    130131            SpaceShip* ship_;
     
    150151            Shader* boostBlur_;
    151152            float blurStrength_;
     153            bool bEnableMotionBlur_;
    152154    };
    153155}
  • code/trunk/src/orxonox/overlays/InGameConsole.cc

    r7689 r8079  
    6060    const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
    6161
    62     SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole).addShortcut();
    63     SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole).addShortcut();
     62    SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
     63    SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
    6464
    6565    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
  • code/trunk/src/orxonox/sound/AmbientSound.cc

    r7856 r8079  
    2929#include "AmbientSound.h"
    3030
     31#include "core/CoreIncludes.h"
    3132#include "core/GameMode.h"
    3233#include "core/Resource.h"
     
    3839        : bPlayOnLoad_(false)
    3940    {
     41        RegisterObject(AmbientSound);
     42
    4043        // Ambient sounds always fade in
    4144        this->setVolume(0);
Note: See TracChangeset for help on using the changeset viewer.