| Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
| Updating Strategies http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=238 |
Page 3 of 3 |
| Author: | GM_Riscvul [ Thu Aug 04, 2011 2:16 pm ] |
| Post subject: | Re: Updating Strategies |
Ok. This is a little off the topic of polyvox, but do you know any resource that can help me understand how to use the Ogre paging component? I'm reading through the code, but it would be nice to have a good example. I don't know if I am using the wrong search terms but it is starting to look as if no one on the internet has ever referenced the Ogre Paging Component. I'll probably figure it out eventually, but it is always nice to have a little documentation or some examples. |
|
| Author: | beyzend [ Fri Aug 05, 2011 1:32 am ] |
| Post subject: | Re: Updating Strategies |
I thought Ogre's terrain sample contained an example of the paging system. Actually, I believe it references TerrainPaging and TerrainPagingWorldSection. These two files are found in the Terrain component. These two files implements classes from the Paging component. In my system I do this (I'm little bit tired right now so I may be making no sense): Basically you will need a Ogre::PageManager. This PageManager manages Ogre Paging. You will need to use this object to create an Ogre::World and also register a factory object which creates Ogre::WorldSection. For the actual paging, on the top-most level there is the Ogre::PageWorld (you can reference Ogre's docs for the specifics) which contains Ogre::WorldSections. You will need to derive WorldSections and implement the WorldSection's interfaces to do the actual paging is done. There is also a PageProvider which I suppose provides procedural page generation but Ogre terrain's sample doesn't use this, it only has a DummyPageProvider which does nothing. So I followed suite. For example, in my child WorldSection class's overridden virtual method I have: Code: /** * THis method hooks into volume maps for creating pages. */ void VolumePagedWorldSection::loadPage(PageID pageID, bool forceSynchronous) { if (!mParent->getManager()->getPagingOperationsEnabled()) return; PageMap::iterator i = mPages.find(pageID); if (i == mPages.end()) { long x, y; _unpackIndex(pageID, &x, &y); std::stringstream ss; ss << "++++++++++++++Load PageID: " << x << "," << -y << "++++++++++++++++\n"; Ogre::LogManager::getSingleton().logMessage(Ogre::LML_NORMAL, ss.str()); _volumeMap->loadPage(pageID); } PagedWorldSection::loadPage(pageID, forceSynchronous); } You can reference Ogre's terrain sample for all of this. Notice how I'm calling _volumeMap->loadPage(pageID). _volumeMap is my own class which handles the paging. Of course you will have to attach _volumeMap at some point. To make all this work, I have a function (actually it's a class) which has this function: Code: VolumePagedWorldSection* VolumeMapPaging::createWorldSection(PagedWorld* world, VolumeMap* volumeMap, Real loadRadius, Real holdRadius, Ogre::int32 minX, Ogre::int32 minY, Ogre::int32 maxX, Ogre::int32 maxY, SceneManager* scnMgr, const String& sectionName) { VolumePagedWorldSection* ret = static_cast<VolumePagedWorldSection*> (world->createSection(scnMgr, SectionFactory::FACTORY_NAME, sectionName)); ret->init(volumeMap); ret->setLoadRadius(loadRadius); ret->setHoldRadius(holdRadius); ret->setPageRange(minX, minY, maxX, maxY); return ret; } This creates the world section. By this point you will need to have registered the world section factory with Ogre::PageManager. (Again, all this is can be found in Ogre's terrain sample. I duplicated that system in it's entirety. I may alter this sometime down the line). Here is the code to initialize everything: Code: void
WorldController::_loadWorldMap(WorldMapConfig &config) { //_worldMap.reset(new WorldMap()); //_worldMap->load(); //We should implement load from configuration file. size_t numOfPagesPerAxis = (config.unloadRadius / WORLD_BLOCK_WIDTH * 2 + 1); size_t numOfPagesPerAxisInView = (config.loadRadius / WORLD_BLOCK_WIDTH * 2 + 1); //_volumeMap.reset(new VolumeMap(_scnMgr, numOfPagesPerAxis, config.forceSync)); _volumeMap.reset(new VolumeMap(_scnMgr, numOfPagesPerAxis, numOfPagesPerAxisInView, config.forceSync, config.forceBlock)); _volumeMap->load(_physicsMgr.get()); _pageManager.setPageProvider(&_pageProvider); _pageManager.addCamera(_cam); _volumePaging = OGRE_NEW_T(VolumeMapPaging(&_pageManager), Ogre::MEMCATEGORY_GENERAL); Ogre::PagedWorld* world = _pageManager.createWorld(); _volumePaging->createWorldSection(world, _volumeMap.get(), config.loadRadius, config.unloadRadius, config.minx, config.miny, config.maxx, config.maxy, _scnMgr); } |
|
| Author: | GM_Riscvul [ Fri Aug 05, 2011 7:34 pm ] |
| Post subject: | Re: Updating Strategies |
Actually I was reading this sample code, and it mostly made sense to me. Hopefully I'm just missing something obvious, but isn't everything associated with the terrain paging only 2d? I thought it only paged along the x and z axis. I am pretty sure I need to page along all three axis. Is there a simple change to turn it from 2d to 3d? |
|
| Author: | beyzend [ Tue Aug 09, 2011 9:02 am ] |
| Post subject: | Re: Updating Strategies |
There's a 3d paging strategy that you can plug in |
|
| Author: | GM_Riscvul [ Tue Aug 09, 2011 2:04 pm ] |
| Post subject: | Re: Updating Strategies |
Quote: There's a 3d paging strategy that you can plug in Where is this located? I only see a 2DGridStrategy available. I'm using Ogre 1.7.2 but I also downloaded 1.7.3 to check if it had anything different. |
|
| Page 3 of 3 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|