Changeset 5689 for code/branches/resource2/src/core
- Timestamp:
- Aug 29, 2009, 10:04:04 PM (15 years ago)
- Location:
- code/branches/resource2/src/core
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/CMakeLists.txt
r5654 r5689 31 31 Language.cc 32 32 LuaState.cc 33 MemoryArchive.cc 33 34 ObjectListBase.cc 34 35 OrxonoxClass.cc -
code/branches/resource2/src/core/CorePrereqs.h
r5654 r5689 134 134 class Loader; 135 135 class LuaState; 136 class MemoryArchive; 137 class MemoryArchiveFactory; 136 138 class MetaObjectList; 137 139 class MetaObjectListElement; -
code/branches/resource2/src/core/GraphicsManager.cc
r5682 r5689 28 28 */ 29 29 30 /**31 @file32 @brief33 Implementation of an partial interface to Ogre.34 */35 36 30 #include "GraphicsManager.h" 37 31 38 32 #include <fstream> 33 #include <sstream> 39 34 #include <boost/filesystem.hpp> 40 35 #include <boost/shared_array.hpp> 36 37 #include <OgreArchiveFactory.h> 38 #include <OgreArchiveManager.h> 41 39 #include <OgreFrameListener.h> 42 40 #include <OgreRoot.h> 43 41 #include <OgreLogManager.h> 44 #include <OgreException.h>45 42 #include <OgreRenderWindow.h> 46 43 #include <OgreRenderSystem.h> … … 62 59 #include "GameMode.h" 63 60 #include "Loader.h" 61 #include "MemoryArchive.h" 64 62 #include "WindowEventListener.h" 65 63 #include "XMLFile.h" … … 88 86 GraphicsManager::GraphicsManager(bool bLoadRenderer) 89 87 : ogreWindowEventListener_(new OgreWindowEventListener()) 88 #if OGRE_VERSION < 0x010600 89 , memoryArchiveFactory_(new MemoryArchiveFactory()) 90 #endif 90 91 , renderWindow_(0) 91 92 , viewport_(0) … … 165 166 166 167 this->loadRenderer(); 168 169 #if OGRE_VERSION < 0x010600 170 // WORKAROUND: There is an incompatibility for particle scripts when trying 171 // to support both Ogre 1.4 and 1.6. The hacky solution is to create 172 // scripts for the 1.6 version and then remove the inserted "particle_system" 173 // keyword. But we need to supply these new scripts as well, which is why 174 // there is an extra Ogre::Archive dealing with in the memory. 175 using namespace Ogre; 176 ArchiveManager::getSingleton().addArchiveFactory(memoryArchiveFactory_.get()); 177 const StringVector& groups = ResourceGroupManager::getSingleton().getResourceGroups(); 178 // Travers all groups 179 for (StringVector::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup) 180 { 181 FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo(*itGroup, "*.particle"); 182 for (FileInfoList::const_iterator itFile = files->begin(); itFile != files->end(); ++itFile) 183 { 184 // open file 185 Ogre::DataStreamPtr input = ResourceGroupManager::getSingleton().openResource(itFile->filename, *itGroup, false); 186 std::stringstream output; 187 // Parse file and replace "particle_system" with nothing 188 while (!input->eof()) 189 { 190 std::string line = input->getLine(); 191 size_t pos = line.find("particle_system"); 192 if (pos != std::string::npos) 193 { 194 // 15 is the length of "particle_system" 195 line.replace(pos, 15, ""); 196 } 197 output << line << std::endl; 198 } 199 // Add file to the memory archive 200 shared_array<char> data(new char[output.str().size()]); 201 // Debug optimisations 202 const std::string outputStr = output.str(); 203 char* rawData = data.get(); 204 for (unsigned i = 0; i < outputStr.size(); ++i) 205 rawData[i] = outputStr[i]; 206 MemoryArchive::addFile("particle_scripts_ogre_1.4_" + *itGroup, itFile->filename, data, output.str().size()); 207 } 208 if (!files->empty()) 209 { 210 // Declare the files, but using a new group 211 ResourceGroupManager::getSingleton().addResourceLocation("particle_scripts_ogre_1.4_" + *itGroup, 212 "Memory", "particle_scripts_ogre_1.4_" + *itGroup); 213 } 214 } 215 #endif 167 216 168 217 // Initialise all resources (do this AFTER the renderer has been loaded!) -
code/branches/resource2/src/core/GraphicsManager.h
r5670 r5689 91 91 92 92 scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h 93 #if OGRE_VERSION < 0x010600 94 scoped_ptr<MemoryArchiveFactory> memoryArchiveFactory_; //!< Stores the modified particle scripts 95 #endif 93 96 scoped_ptr<Ogre::LogManager> ogreLogger_; 94 97 scoped_ptr<Ogre::Root> ogreRoot_; //!< Ogre's root
Note: See TracChangeset
for help on using the changeset viewer.