|
|
|
@ -18,6 +18,7 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
|
|
|
|
: mStorage(storage)
|
|
|
|
|
, mParent(parent)
|
|
|
|
|
, mResourceSystem(resourceSystem)
|
|
|
|
|
, mBorderVisible(false)
|
|
|
|
|
{
|
|
|
|
|
mTerrainRoot = new osg::Group;
|
|
|
|
|
mTerrainRoot->setNodeMask(nodeMask);
|
|
|
|
@ -28,12 +29,6 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
|
|
|
|
|
|
|
|
|
mTerrainRoot->setName("Terrain Root");
|
|
|
|
|
|
|
|
|
|
mBorderRoot = new osg::Switch;
|
|
|
|
|
mBorderRoot->setName("Border Root");
|
|
|
|
|
mBorderRoot->setNodeMask(borderMask);
|
|
|
|
|
|
|
|
|
|
mTerrainRoot->addChild(mBorderRoot);
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Camera> compositeCam = new osg::Camera;
|
|
|
|
|
compositeCam->setRenderOrder(osg::Camera::PRE_RENDER, -1);
|
|
|
|
|
compositeCam->setProjectionMatrix(osg::Matrix::identity());
|
|
|
|
@ -52,44 +47,52 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
|
|
|
|
|
|
|
|
|
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
|
|
|
|
|
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer));
|
|
|
|
|
|
|
|
|
|
mCellBorder.reset(new MWRender::CellBorder(this,mTerrainRoot.get()));
|
|
|
|
|
mCellBorder.reset(new MWRender::CellBorder(this,mTerrainRoot.get(),borderMask));
|
|
|
|
|
|
|
|
|
|
mResourceSystem->addResourceManager(mChunkManager.get());
|
|
|
|
|
mResourceSystem->addResourceManager(mTextureManager.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setBordersVisible(false);
|
|
|
|
|
World::~World()
|
|
|
|
|
{
|
|
|
|
|
mResourceSystem->removeResourceManager(mChunkManager.get());
|
|
|
|
|
mResourceSystem->removeResourceManager(mTextureManager.get());
|
|
|
|
|
|
|
|
|
|
mParent->removeChild(mTerrainRoot);
|
|
|
|
|
|
|
|
|
|
mCompositeMapCamera->removeChild(mCompositeMapRenderer);
|
|
|
|
|
mCompositeMapCamera->getParent(0)->removeChild(mCompositeMapCamera);
|
|
|
|
|
|
|
|
|
|
delete mStorage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void World::setBordersVisible(bool visible)
|
|
|
|
|
{
|
|
|
|
|
mBorderVisible = visible;
|
|
|
|
|
|
|
|
|
|
if (visible)
|
|
|
|
|
mBorderRoot->setAllChildrenOn();
|
|
|
|
|
{
|
|
|
|
|
for (std::set<std::pair<int,int>>::iterator it = mLoadedCells.begin(); it != mLoadedCells.end(); ++it)
|
|
|
|
|
mCellBorder->createCellBorderGeometry(it->first,it->second);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mBorderRoot->setAllChildrenOff();
|
|
|
|
|
mCellBorder->destroyCellBorderGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void World::loadCell(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
mCellBorder->createCellBorderGeometry(x,y);
|
|
|
|
|
}
|
|
|
|
|
if (mBorderVisible)
|
|
|
|
|
mCellBorder->createCellBorderGeometry(x,y);
|
|
|
|
|
|
|
|
|
|
void World::unloadCell(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
mCellBorder->destroyCellBorderGeometry(x,y);
|
|
|
|
|
mLoadedCells.insert(std::pair<int,int>(x,y));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
World::~World()
|
|
|
|
|
void World::unloadCell(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
mResourceSystem->removeResourceManager(mChunkManager.get());
|
|
|
|
|
mResourceSystem->removeResourceManager(mTextureManager.get());
|
|
|
|
|
|
|
|
|
|
mParent->removeChild(mTerrainRoot);
|
|
|
|
|
if (mBorderVisible)
|
|
|
|
|
mCellBorder->destroyCellBorderGeometry(x,y);
|
|
|
|
|
|
|
|
|
|
mCompositeMapCamera->removeChild(mCompositeMapRenderer);
|
|
|
|
|
mCompositeMapCamera->getParent(0)->removeChild(mCompositeMapCamera);
|
|
|
|
|
|
|
|
|
|
delete mStorage;
|
|
|
|
|
mLoadedCells.erase(std::pair<int,int>(x,y));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void World::setTargetFrameRate(float rate)
|
|
|
|
|