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