Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2011, 6:32:28 PM (14 years ago)
Author:
rgrieder
Message:

Merged revisions 7940-7974 from kicklib to kicklib2.

Location:
code/branches/kicklib2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib2

  • code/branches/kicklib2/src/libraries/core/GraphicsManager.cc

    r8079 r8283  
    3535#include <boost/shared_array.hpp>
    3636
    37 #include <OgreArchiveFactory.h>
    38 #include <OgreArchiveManager.h>
    3937#include <OgreFrameListener.h>
    4038#include <OgreRoot.h>
     
    6058#include "GUIManager.h"
    6159#include "Loader.h"
    62 #include "MemoryArchive.h"
    6360#include "PathConfig.h"
    6461#include "ViewportEventListener.h"
     
    10299    GraphicsManager::GraphicsManager(bool bLoadRenderer)
    103100        : ogreWindowEventListener_(new OgreWindowEventListener())
    104 #if OGRE_VERSION < 0x010600
    105         , memoryArchiveFactory_(new MemoryArchiveFactory())
    106 #endif
    107101        , renderWindow_(0)
    108102        , viewport_(0)
     
    195189
    196190        this->loadRenderer();
    197 
    198 #if OGRE_VERSION < 0x010600
    199         // WORKAROUND: There is an incompatibility for particle scripts when trying
    200         // to support both Ogre 1.4 and 1.6. The hacky solution is to create
    201         // scripts for the 1.6 version and then remove the inserted "particle_system"
    202         // keyword. But we need to supply these new scripts as well, which is why
    203         // there is an extra Ogre::Archive dealing with it in the memory.
    204         using namespace Ogre;
    205         ArchiveManager::getSingleton().addArchiveFactory(memoryArchiveFactory_.get());
    206         const StringVector& groups = ResourceGroupManager::getSingleton().getResourceGroups();
    207         // Travers all groups
    208         for (StringVector::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup)
    209         {
    210             FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo(*itGroup, "*.particle");
    211             for (FileInfoList::const_iterator itFile = files->begin(); itFile != files->end(); ++itFile)
    212             {
    213                 // open file
    214                 Ogre::DataStreamPtr input = ResourceGroupManager::getSingleton().openResource(itFile->filename, *itGroup, false);
    215                 std::stringstream output;
    216                 // Parse file and replace "particle_system" with nothing
    217                 while (!input->eof())
    218                 {
    219                     std::string line = input->getLine();
    220                     size_t pos = line.find("particle_system");
    221                     if (pos != std::string::npos)
    222                     {
    223                         // 15 is the length of "particle_system"
    224                         line.replace(pos, 15, "");
    225                     }
    226                     output << line << std::endl;
    227                 }
    228                 // Add file to the memory archive
    229                 shared_array<char> data(new char[output.str().size()]);
    230                 // Debug optimisations
    231                 const std::string& outputStr = output.str();
    232                 char* rawData = data.get();
    233                 for (unsigned i = 0; i < outputStr.size(); ++i)
    234                     rawData[i] = outputStr[i];
    235                 MemoryArchive::addFile("particle_scripts_ogre_1.4_" + *itGroup, itFile->filename, data, output.str().size());
    236             }
    237             if (!files->empty())
    238             {
    239                 // Declare the files, but using a new group
    240                 ResourceGroupManager::getSingleton().addResourceLocation("particle_scripts_ogre_1.4_" + *itGroup,
    241                     "Memory", "particle_scripts_ogre_1.4_" + *itGroup);
    242             }
    243         }
    244 #endif
    245191
    246192        // Initialise all resources (do this AFTER the renderer has been loaded!)
Note: See TracChangeset for help on using the changeset viewer.