mirror of https://github.com/OpenMW/openmw.git
improved cell handling; added world.* files (should have been added a few commits ago)
parent
ea6d342a24
commit
f8a1a0ab8c
@ -0,0 +1,61 @@
|
||||
|
||||
#include "world.hpp"
|
||||
|
||||
#include "components/bsa/bsa_archive.hpp"
|
||||
#include "components/engine/ogre/renderer.hpp"
|
||||
|
||||
#include "apps/openmw/mwrender/sky.hpp"
|
||||
#include "apps/openmw/mwrender/interior.hpp"
|
||||
|
||||
namespace OMW
|
||||
{
|
||||
World::World (Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
||||
const std::string& master, const std::string& startCell)
|
||||
: mSkyManager (0), mScene (renderer), mPlayerPos (mScene.getCamera())
|
||||
{
|
||||
boost::filesystem::path masterPath (dataDir);
|
||||
masterPath /= master;
|
||||
|
||||
std::cout << "Loading ESM " << masterPath.string() << "\n";
|
||||
|
||||
// This parses the ESM file and loads a sample cell
|
||||
mEsm.open (masterPath.file_string());
|
||||
mStore.load (mEsm);
|
||||
|
||||
mInteriors[startCell].loadInt (startCell, mStore, mEsm);
|
||||
|
||||
std::cout << "\nSetting up cell rendering\n";
|
||||
|
||||
// This connects the cell data with the rendering scene.
|
||||
mActiveCells.insert (std::make_pair (&mInteriors[startCell],
|
||||
new MWRender::InteriorCellRender (mInteriors[startCell], mScene)));
|
||||
|
||||
// Load the cell and insert it into the renderer
|
||||
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
||||
iter!=mActiveCells.end(); ++iter)
|
||||
iter->second->show();
|
||||
|
||||
// Optionally enable the sky
|
||||
// if (mEnableSky)
|
||||
// mpSkyManager = MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera());
|
||||
|
||||
}
|
||||
|
||||
World::~World()
|
||||
{
|
||||
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
||||
iter!=mActiveCells.end(); ++iter)
|
||||
delete iter->second;
|
||||
|
||||
for (CellRenderCollection::iterator iter (mBufferedCells.begin());
|
||||
iter!=mBufferedCells.end(); ++iter)
|
||||
delete iter->second;
|
||||
|
||||
delete mSkyManager;
|
||||
}
|
||||
|
||||
MWRender::PlayerPos& World::getPlayerPos()
|
||||
{
|
||||
return mPlayerPos;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
#ifndef WORLD_H
|
||||
#define WORLD_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "components/esm_store/cell_store.hpp"
|
||||
|
||||
#include "apps/openmw/mwrender/playerpos.hpp"
|
||||
#include "apps/openmw/mwrender/mwscene.hpp"
|
||||
|
||||
namespace Render
|
||||
{
|
||||
class OgreRenderer;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class SkyManager;
|
||||
class CellRender;
|
||||
}
|
||||
|
||||
namespace OMW
|
||||
{
|
||||
/// \brief The game world and its visual representation
|
||||
|
||||
class World
|
||||
{
|
||||
typedef std::map<ESMS::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
||||
|
||||
MWRender::SkyManager* mSkyManager;
|
||||
MWRender::MWScene mScene;
|
||||
MWRender::PlayerPos mPlayerPos;
|
||||
CellRenderCollection mActiveCells;
|
||||
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
|
||||
ESM::ESMReader mEsm;
|
||||
ESMS::ESMStore mStore;
|
||||
std::map<std::string, ESMS::CellStore> mInteriors;
|
||||
|
||||
// not implemented
|
||||
World (const World&);
|
||||
World& operator= (const World&);
|
||||
|
||||
public:
|
||||
|
||||
World (Render::OgreRenderer& renderer, const boost::filesystem::path& master,
|
||||
const std::string& dataDir, const std::string& startCell);
|
||||
|
||||
~World();
|
||||
|
||||
MWRender::PlayerPos& getPlayerPos();
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue