1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 03:32:36 +00:00
scrawl b1d4bb5708 Add CompositeMapRenderer
Temporarily render all terrain using composite maps for testing purposes
2017-03-14 19:27:55 +01:00

56 lines
1.5 KiB
C++

#include "world.hpp"
#include <osg/Group>
#include <osgUtil/IncrementalCompileOperation>
#include <components/resource/resourcesystem.hpp>
#include "storage.hpp"
#include "texturemanager.hpp"
#include "chunkmanager.hpp"
#include "compositemaprenderer.hpp"
namespace Terrain
{
World::World(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico,
Storage* storage, int nodeMask)
: mStorage(storage)
, mParent(parent)
, mResourceSystem(resourceSystem)
, mIncrementalCompileOperation(ico)
{
mTerrainRoot = new osg::Group;
mTerrainRoot->setNodeMask(nodeMask);
mTerrainRoot->getOrCreateStateSet()->setRenderingHint(osg::StateSet::OPAQUE_BIN);
mTerrainRoot->setName("Terrain Root");
osg::ref_ptr<CompositeMapRenderer> renderer (new CompositeMapRenderer);
mTerrainRoot->addChild(renderer);
mParent->addChild(mTerrainRoot);
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), renderer));
mResourceSystem->addResourceManager(mChunkManager.get());
mResourceSystem->addResourceManager(mTextureManager.get());
}
World::~World()
{
mResourceSystem->removeResourceManager(mChunkManager.get());
mResourceSystem->removeResourceManager(mTextureManager.get());
mParent->removeChild(mTerrainRoot);
delete mStorage;
}
float World::getHeightAt(const osg::Vec3f &worldPos)
{
return mStorage->getHeightAt(worldPos);
}
}