Changeset 3438

Show
Ignore:
Timestamp:
02/21/10 14:47:32 (5 months ago)
Author:
trichards
Message:

Added a lot more debugging statements in an effort to track down an initialization bug. Final bug was fixed by calling setActive().
Also implemented pumpSystemMessages() in ZOgre.

Location:
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/Camera.cpp

    r3435 r3438  
    3131#include <Zen/Core/Math/Vector3.hpp> 
    3232 
     33#include <iostream> 
     34 
    3335//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    3436namespace Zen { 
     
    5961Camera::setAspectRatio(const Math::Real& _ratio) 
    6062{ 
     63    std::cout << "OGRE: Ogre::Camera::setAspectRatio(_ratio);" << std::endl;; 
    6164    m_camera.setAspectRatio(_ratio); 
    6265} 
     
    6770{ 
    6871    Ogre::Radian fov(_fov); 
     72    std::cout << "OGRE: Ogre::Camera::setFOVy(fov);" << std::endl;; 
    6973    m_camera.setFOVy(fov); 
    7074} 
     
    7478Camera::setNearClipDistance(const Math::Real _nearDistance) 
    7579{ 
     80    std::cout << "OGRE: Ogre::Camera::setNearClipDistance(_nearDistance);" << std::endl;; 
    7681    m_camera.setNearClipDistance(_nearDistance); 
    7782} 
     
    8186Camera::setFarClipDistance(const Math::Real _farDistance) 
    8287{ 
     88    std::cout << "OGRE: Ogre::Camera::setFarClipDistance(_farDistance);" << std::endl;; 
    8389    m_camera.setFarClipDistance(_farDistance); 
    8490} 
     
    97103    if (m_pSceneNode) 
    98104    { 
     105        std::cout << "OGRE: Ogre::SceneNode::setPosition(_x, _y, _z);" << std::endl;; 
    99106        m_pSceneNode->setPosition(_x, _y, _z); 
    100107    } 
    101108    else 
    102109    { 
     110        std::cout << "OGRE: Ogre::Camera::setPosition(_x, _y, _z);" << std::endl;; 
    103111        m_camera.setPosition(_x, _y, _z); 
    104112    } 
     
    127135Camera::setDirection(const Math::Real _x, const Math::Real _y, const Math::Real _z) 
    128136{ 
     137    std::cout << "OGRE: Ogre::SceneNode::setDirection(_x, _y, _z);" << std::endl;; 
    129138    m_camera.setDirection(_x, _y, _z); 
    130139} 
     
    156165Camera::lookAt(const Math::Real _x, const Math::Real _y, const Math::Real _z) 
    157166{ 
     167    std::cout << "OGRE: Ogre::SceneNode::lookAt(_x, _y, _z);" << std::endl;; 
    158168    m_camera.lookAt(_x, _y, _z); 
    159169} 
     
    246256    if(m_pSceneNode) 
    247257    { 
     258        std::cout << "OGRE: Ogre::SceneNode::_update(true, false);" << std::endl;; 
     259 
    248260        m_pSceneNode->getParentSceneNode()->_update(true,false); 
    249261    } 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/RenderingCanvas.cpp

    r3435 r3438  
    3636 
    3737#include <OgreRenderSystem.h> 
     38#include <OgreWindowEventUtilities.h> 
    3839 
    3940#include <stddef.h> 
     
    5354{ 
    5455    // Get the default scene manager 
     56    std::cout << "OGRE: Ogre::Root::getSingleton().getSceneManager(\"default\");" << std::endl; 
    5557    m_pSceneManager = Ogre::Root::getSingleton().getSceneManager("default"); 
    5658 
    5759    assert(m_pSceneManager != NULL); 
     60 
     61    std::cout << "Using scene type " << m_pSceneManager->getTypeName() << std::endl; 
    5862 
    5963    // Create the default camera 
     
    6165 
    6266    std::cout << "adding Viewport" << std::endl; 
     67    std::cout << "OGRE: Ogre::RenderWindow::addViewPort(&m_pCurrentCamera->getOgreCamera());" << std::endl; 
    6368    m_pViewPort = _pView->getRenderWindow().addViewport(&m_pCurrentCamera->getOgreCamera()); 
    6469 
    65     m_pSceneManager->setViewport(m_pViewPort); 
    66  
    67     // Select the camera, just in case somehow another camera was created. 
    68     std::cout << "selectCamera" << std::endl; 
    69     selectCamera("default"); 
     70    //m_pSceneManager->setViewport(m_pViewPort); 
     71 
     72    //// Select the camera, just in case somehow another camera was created. 
     73    //std::cout << "selectCamera" << std::endl; 
     74    //selectCamera("default"); 
    7075 
    7176    // HACK Why do we have to do this on Linux? 
     
    7378    { 
    7479        std::cout << "RenderingCanvas::RenderingCanvas(): Warning!  OGRE RenderSystem viewPort was not set.  Why not?" << std::endl; 
     80        std::cout << "OGRE: Ogre::Root::getSingleton().getRenderSystem()->_setViewport(m_pViewPort);" << std::endl; 
    7581        Ogre::Root::getSingleton().getRenderSystem()->_setViewport(m_pViewPort); 
    7682        assert(m_pViewPort); 
     
    7884    } 
    7985 
     86    // HACK This should only be done for windows apps 
     87    Ogre::RenderSystem* const pRenderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
     88    pRenderSystem->setWaitForVerticalBlank(false); 
     89    m_pRenderingView->getRenderWindow().setActive(true); 
     90    m_pRenderingView->getRenderWindow().setVisible(true); 
     91 
    8092    std::cout << "setting background color" << std::endl; 
     93    std::cout << "OGRE: Ogre::Viewport::setBackgroundColour(Ogre::ColourValue(0.5f, 0.0f, 0.0f));" << std::endl; 
    8194    m_pViewPort->setBackgroundColour(Ogre::ColourValue(0.5f, 0.0f, 0.0f)); 
    8295 
     
    123136{ 
    124137    std::cout << "RenderingCanvas::resize(): " << _x << " " << _y << " " << _width << " " << _height << std::endl; 
     138    std::cout << "OGRE: Ogre::RenderWindow::reposition(_x, _y);" << std::endl; 
    125139    m_pRenderingView->getRenderWindow().reposition(_x, _y); 
     140    std::cout << "OGRE: Ogre::RenderWindow::resize(_width, _height);" << std::endl; 
    126141    m_pRenderingView->getRenderWindow().resize(_width, _height); 
    127142 
     143    std::cout << "OGRE: Ogre::RenderWindow::windowMovedOrResized();" << std::endl; 
    128144    m_pRenderingView->getRenderWindow().windowMovedOrResized(); 
    129145 
     
    228244    { 
    229245        // Camera wasn't found, so create it 
     246        std::cout << "OGRE: Ogre::SceneManager::createCamera(_name);" << std::endl; 
    230247        Ogre::Camera* pOgreCamera = m_pSceneManager->createCamera(_name); 
    231248        assert(pOgreCamera); 
     
    236253 
    237254        // Default the aspect ratio 
    238         pCamera->setAspectRatio((Ogre::Real)getWidth() / (Ogre::Real)getHeight()); 
    239  
    240         std::cout << "Creating camera " << getWidth() << " x " << getHeight() << std::endl; 
     255        //pCamera->setAspectRatio((Ogre::Real)getWidth() / (Ogre::Real)getHeight()); 
    241256 
    242257        // If the current camera hasn't been set, set it 
     
    300315        std::cout << "found it, getting the ogre camera" << std::endl; 
    301316        // Set the current camera for this viewport 
     317        std::cout << "OGRE: Ogre::Viewport::setCamera(&iter->second->getOgreCamera());" << std::endl; 
    302318        m_pViewPort->setCamera(&iter->second->getOgreCamera()); 
    303319 
     
    439455 
    440456//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     457void 
     458RenderingCanvas::pumpSystemMessages() 
     459{ 
     460    Ogre::WindowEventUtilities::messagePump(); 
     461} 
     462 
     463//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    441464}   // namespace ZOgre 
    442465}   // namespace Zen 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/RenderingCanvas.hpp

    r2430 r3438  
    7474 
    7575    virtual void querySceneNodes(Math::Real _x, Math::Real _y, I_SceneNodeVisitor& _visitor); 
     76 
     77    virtual void pumpSystemMessages(); 
    7678    /// @} 
    7779 
     
    122124    // TODO This should be abstracted into an I_InputService 
    123125    OIS::Keyboard*      m_pKeyboard; 
    124 #endif // deprecated  
     126#endif // deprecated 
    125127 
    126128    std::map< std::string, bool >   m_compositors; 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/RenderingService.cpp

    r3409 r3438  
    4747 
    4848    // TODO Where should this go? 
    49  
     49    std::cout << "OGRE: m_root.restoreConfig()" << std::endl; 
    5050    if (m_root.restoreConfig()) 
    5151    { 
     
    5353        std::cout << "Rendering configuration loaded from file 'ogre.cfg'.  Delete it to show dialog at startup." << std::endl; 
    5454        m_root.initialise(false); 
     55        Ogre::ResourceGroupManager::getSingleton().addResourceLocation("./materials/textures", "FileSystem", "General", false); 
    5556        return; 
    5657    } 
    5758 
    5859    // there was no valid ogre.cfg file to read from, so let's show the dialog 
     60    std::cout << "OGRE: m_root.showConfigDialog()" << std::endl; 
    5961    if (m_root.showConfigDialog()) 
    6062    { 
    6163        std::cout << "Rendering configuration loaded from on-screen dialog." << std::endl; 
    6264        m_root.initialise(false); 
     65        Ogre::ResourceGroupManager::getSingleton().addResourceLocation("./materials/textures", "FileSystem", "General", false); 
    6366        return; 
    6467    } 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/RenderingView.cpp

    r3420 r3438  
    3131 
    3232#include <iostream> 
     33#include <sstream> 
    3334 
    3435//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     
    7879    { 
    7980        Ogre::Root::getSingleton().getRenderSystem()->setConfigOption("Full Screen", "No"); 
    80         Ogre::Root::getSingleton().getRenderSystem()->setConfigOption("Video Mode", "800 x 600"); 
     81 
     82        std::stringstream str; 
     83        str << _width << " x " << _height; 
     84        Ogre::Root::getSingleton().getRenderSystem()->setConfigOption("Video Mode", str.str()); 
    8185    } 
    8286 
     87    std::cout << "OGRE: Ogre::Root::getSingleton().initialise(!useParentWindow, _windowName.c_str());" << std::endl; 
    8388    Ogre::Root::getSingleton().initialise(!useParentWindow, _windowName.c_str()); 
    8489 
    8590    if (useParentWindow) 
    8691    { 
     92        std::cout << "OGRE: m_root.createRenderWindow(_windowName.c_str(), _width, _height, false, &nvpl);" << std::endl; 
    8793        m_pRenderWindow = m_root.createRenderWindow(_windowName.c_str(), _width, _height, false, &nvpl); 
    8894    } 
    8995    else 
    9096    { 
     97        std::cout << "OGRE: m_root.getAutoCreatedWindow();" << std::endl; 
    9198        m_pRenderWindow = m_root.getAutoCreatedWindow(); 
    9299    } 
     100 
     101    // Dunno why this is done. 
     102    std::cout << "OGRE: Ogre::RenderWindow::removeAllViewports()" << std::endl; 
     103    m_pRenderWindow->removeAllViewports(); 
    93104 
    94105    // Set the window value in the _context 
     
    100111    { 
    101112        // TODO This might be different depending on the OS. 
     113        std::cout << "OGRE: Ogre::RenderWindow::getCustomAttribute(\"WINDOW\", &pContext->m_pHandle);" << std::endl; 
    102114        m_pRenderWindow->getCustomAttribute("WINDOW", &pContext->m_pHandle); 
    103115    } 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/SceneService.cpp

    r3409 r3438  
    5151    assert(!sm_bCreated); 
    5252    sm_bCreated = true; 
     53    std::cout << "OGRE: Ogre::Root::getSingleton().createSceneManager(_sceneType, _name);" << std::endl; 
    5354    m_pSceneManager = Ogre::Root::getSingleton().createSceneManager(_sceneType, _name); 
    5455    assert(m_pSceneManager != NULL); 
     56 
    5557} 
    5658 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZOgre/src/ZOgreModule.cpp

    r2945 r3438  
    8989 
    9090//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    91 ZOgreModule&  
     91ZOgreModule& 
    9292ZOgreModule::instance() 
    9393{ 
     
    100100    if (pRoot == NULL) 
    101101    { 
     102        std::cout << "OGRE: new Ogre::Root();" << std::endl; 
    102103#ifdef _DEBUG 
    103104            pRoot = new Ogre::Root("plugins-debug.cfg", "ogre.cfg", "Ogre.log"); 
     
    111112 
    112113//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    113 Zen::Plugins::I_Module::plugin_name_collection_type&  
     114Zen::Plugins::I_Module::plugin_name_collection_type& 
    114115ZOgreModule::getPluginNames() 
    115116{ 
     
    121122ZOgreModule::getPlugin(const plugin_name_type& _PluginName) 
    122123{ 
    123     // TODO: Return the appropriate plugin;  
     124    // TODO: Return the appropriate plugin; 
    124125    // For now since only one type is supported then return that. 
    125126    return m_pPlugin; 
     
    127128 
    128129//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    129 void  
     130void 
    130131ZOgreModule::destroyPlugin(Plugins::I_Module::plugin_ptr_type _pPlugin) 
    131132{