Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 940 for code/branches/network


Ignore:
Timestamp:
Mar 27, 2008, 8:22:37 PM (17 years ago)
Author:
rgrieder
Message:
  • Captured Ogre log messages. Can now be configured in [GraphicsEngine] section of orxonox.ini
  • boeggfix in InputHandler for older OIS versions.
Location:
code/branches/network/src/orxonox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/orxonox/GraphicsEngine.cc

    r929 r940  
    3535#include <OgreException.h>
    3636#include <OgreConfigFile.h>
     37#include <OgreLogManager.h>
    3738#include <OgreTextureManager.h>
    3839#include <OgreRenderWindow.h>
     
    6970  {
    7071    SetConfigValue(dataPath_, dataPath_).description("relative path to media data");
    71 
    72   }
    73 
     72    SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use to \"\" to suppress log file creation.");
     73    SetConfigValue(ogreLogLevelTrivial_ , 5).description("relative path to media data");
     74    SetConfigValue(ogreLogLevelNormal_  , 4).description("relative path to media data");
     75    SetConfigValue(ogreLogLevelCritical_, 2).description("relative path to media data");
     76  }
     77
     78  /**
     79    @brief Creates the Ogre Root object and sets up the ogre log.
     80  */
    7481  void GraphicsEngine::setup()
    7582  {
     
    8693    std::string plugin_filename = "plugins.cfg";
    8794#endif
     95
     96    // create a logManager
     97    LogManager *logger;
     98                if(LogManager::getSingletonPtr() == 0)
     99                        logger = new LogManager();
     100    else
     101      logger = LogManager::getSingletonPtr();
     102
     103    // create our own log that we can listen to
     104    Log *myLog;
     105    if (this->ogreLogfile_ == "")
     106      myLog = logger->createLog("ogre.log", true, false, true);
     107    else
     108      myLog = logger->createLog(this->ogreLogfile_, true, false, false);
     109
     110    myLog->setLogDetail(LL_BOREME);
     111    myLog->addListener(this);
     112
     113    // Root will detect that we've already created a Log
    88114    root_ = new Root(plugin_filename);
    89115  }
     
    196222  }
    197223
     224  /**
     225    @brief Method called by the LogListener interface from Ogre.
     226    We use it to capture Ogre log messages and handle it ourselves.
     227    @param message The message to be logged
     228    @param lml The message level the log is using
     229    @param maskDebug If we are printing to the console or not
     230    @param logName the name of this log (so you can have several listeners
     231                   for different logs, and identify them)
     232  */
     233  void GraphicsEngine::messageLogged(const std::string& message,
     234    LogMessageLevel lml, bool maskDebug, const std::string &logName)
     235  {
     236    int orxonoxLevel;
     237    switch (lml)
     238    {
     239      case LML_TRIVIAL:
     240        orxonoxLevel = this->ogreLogLevelTrivial_;
     241        break;
     242      case LML_NORMAL:
     243        orxonoxLevel = this->ogreLogLevelNormal_;
     244        break;
     245      case LML_CRITICAL:
     246        orxonoxLevel = this->ogreLogLevelCritical_;
     247        break;
     248      default:
     249        orxonoxLevel = 0;
     250    }
     251    OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
     252        << "*** Ogre: " << message << std::endl;
     253  }
    198254}
  • code/branches/network/src/orxonox/GraphicsEngine.h

    r929 r940  
    1111
    1212#include <OgrePrerequisites.h>
     13#include <OgreLog.h>
    1314#include <OgreRoot.h>
    1415#include <OgreSceneManager.h>
     
    2324   * graphics engine manager class
    2425 */
    25   class _OrxonoxExport GraphicsEngine : public OrxonoxClass
     26  class _OrxonoxExport GraphicsEngine : public OrxonoxClass, public Ogre::LogListener
    2627  {
    2728    public:
     
    5455
    5556    private:
     57      //! Method called by the LogListener from Ogre
     58      void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
     59                         bool maskDebug, const std::string &logName);
     60
    5661      Ogre::Root*         root_;        //!< Ogre's root
    5762      std::string         configPath_;  //!< path to config file
     
    6065      Ogre::RenderWindow* renderWindow_;//!< the current render window
    6166      //bool               bOverwritePath_; //!< overwrites path
     67      std::string         ogreLogfile_; //!< log file name for Ogre log messages
     68      int ogreLogLevelTrivial_;         //!< Corresponding Orxonx debug level for LL_TRIVIAL
     69      int ogreLogLevelNormal_;          //!< Corresponding Orxonx debug level for LL_NORMAL
     70      int ogreLogLevelCritical_;        //!< Corresponding Orxonx debug level for LL_CRITICAL
    6271
    6372  };
  • code/branches/network/src/orxonox/InputHandler.cc

    r934 r940  
    107107        COUT(ORX_DEBUG) << "*** InputHandler: Created OIS input system" << std::endl;
    108108
    109         // If possible create a buffered keyboard
    110         if (inputSystem_->numKeyboards() > 0)
    111         {
    112           keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true));
    113           keyboard_->setEventCallback(this);
    114           COUT(ORX_DEBUG) << "*** InputHandler: Created OIS mouse" << std::endl;
    115         }
    116 
    117         // If possible create a buffered mouse
    118         if (inputSystem_->numMice() > 0 )
    119         {
    120           mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
    121           mouse_->setEventCallback(this);
    122           COUT(ORX_DEBUG) << "*** InputHandler: Created OIS keyboard" << std::endl;
    123 
    124           // Set mouse region
    125           this->setWindowExtents(windowWidth, windowHeight);
    126         }
     109        // create a keyboard. If none are available the exception is caught.
     110        keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true));
     111        keyboard_->setEventCallback(this);
     112        COUT(ORX_DEBUG) << "*** InputHandler: Created OIS mouse" << std::endl;
     113
     114        // create a mouse. If none are available the exception is caught.
     115        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
     116        mouse_->setEventCallback(this);
     117        COUT(ORX_DEBUG) << "*** InputHandler: Created OIS keyboard" << std::endl;
     118
     119        // Set mouse region
     120        this->setWindowExtents(windowWidth, windowHeight);
    127121      }
    128122      catch (OIS::Exception ex)
Note: See TracChangeset for help on using the changeset viewer.