Merged
commit
4597295e20
@ -1,43 +1,22 @@
|
||||
#ifndef _GAME_RENDER_CELL_H
|
||||
#define _GAME_RENDER_CELL_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class CellRef;
|
||||
}
|
||||
|
||||
namespace ESMS
|
||||
{
|
||||
class CellStore;
|
||||
}
|
||||
#ifndef GAME_RENDER_CELL_H
|
||||
#define GAME_RENDER_CELL_H
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
/// Base class for cell render, that implements inserting references into a cell in a
|
||||
/// cell type- and render-engine-independent way.
|
||||
|
||||
class CellRender
|
||||
{
|
||||
public:
|
||||
CellRender() {}
|
||||
virtual ~CellRender() {}
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (const ESM::CellRef &ref) = 0;
|
||||
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
virtual void insertMesh(const std::string &mesh) = 0;
|
||||
virtual ~CellRender() {};
|
||||
|
||||
/// insert a light related to the most recent insertBegin call.
|
||||
virtual void insertLight(float r, float g, float b, float radius) = 0;
|
||||
/// Make the cell visible. Load the cell if necessary.
|
||||
virtual void show() = 0;
|
||||
|
||||
/// finish inserting a new reference and return a handle to it.
|
||||
virtual std::string insertEnd() = 0;
|
||||
|
||||
void insertCell(const ESMS::CellStore &cell);
|
||||
/// Remove the cell from rendering, but don't remove it from
|
||||
/// memory.
|
||||
virtual void hide() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
#ifndef _GAME_RENDER_CELLIMP_H
|
||||
#define _GAME_RENDER_CELLIMP_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class CellRef;
|
||||
}
|
||||
|
||||
namespace ESMS
|
||||
{
|
||||
class CellStore;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
/// Base class for cell render, that implements inserting references into a cell in a
|
||||
/// cell type- and render-engine-independent way.
|
||||
|
||||
class CellRenderImp
|
||||
{
|
||||
public:
|
||||
CellRenderImp() {}
|
||||
virtual ~CellRenderImp() {}
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (const ESM::CellRef &ref) = 0;
|
||||
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
virtual void insertMesh(const std::string &mesh) = 0;
|
||||
|
||||
/// insert a light related to the most recent insertBegin call.
|
||||
virtual void insertLight(float r, float g, float b, float radius) = 0;
|
||||
|
||||
/// finish inserting a new reference and return a handle to it.
|
||||
virtual std::string insertEnd() = 0;
|
||||
|
||||
void insertCell(const ESMS::CellStore &cell);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -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