2010-06-03 18:44:55 +00:00
|
|
|
#ifndef _GAME_RENDER_CELL_H
|
|
|
|
#define _GAME_RENDER_CELL_H
|
|
|
|
|
2010-06-09 18:46:14 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
#include "esm_store/cell_store.hpp"
|
2010-06-06 22:33:45 +00:00
|
|
|
#include "mwscene.hpp"
|
2010-06-03 18:44:55 +00:00
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
namespace MWRender
|
2010-06-03 18:44:55 +00:00
|
|
|
{
|
2010-06-12 11:01:20 +00:00
|
|
|
/// Base class for cell render, that implements inserting references into a cell in a
|
|
|
|
/// cell type- and render-engine-independent way.
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-03 18:44:55 +00:00
|
|
|
class CellRender
|
|
|
|
{
|
|
|
|
public:
|
2010-06-12 11:01:20 +00:00
|
|
|
CellRender() {}
|
|
|
|
virtual ~CellRender() {}
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-12 11:01:20 +00:00
|
|
|
/// start inserting a new reference.
|
|
|
|
virtual void insertBegin (const ESMS::CellRef &ref) = 0;
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-12 11:01:20 +00:00
|
|
|
/// insert a mesh related to the most recent insertBegin call.
|
|
|
|
virtual void insertMesh(const std::string &mesh) = 0;
|
|
|
|
|
|
|
|
/// finish inserting a new reference and return a handle to it.
|
|
|
|
virtual std::string insertEnd() = 0;
|
|
|
|
|
|
|
|
void insertCell(const ESMS::CellStore &cell);
|
2010-06-03 18:44:55 +00:00
|
|
|
};
|
2010-06-12 11:01:20 +00:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void insertObj(CellRender& cellRender, const T& liveRef)
|
|
|
|
{
|
|
|
|
assert (liveRef.base != NULL);
|
|
|
|
const std::string &model = liveRef.base->model;
|
|
|
|
if(!model.empty())
|
|
|
|
{
|
|
|
|
cellRender.insertBegin (liveRef.ref);
|
|
|
|
cellRender.insertMesh ("meshes\\" + model);
|
|
|
|
cellRender.insertEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void insertObj(CellRender& cellRender, const ESMS::LiveCellRef<ESM::Light>& liveRef);
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void insertCellRefList (CellRender& cellRender, const T& cellRefList)
|
|
|
|
{
|
|
|
|
for(typename T::List::const_iterator it = cellRefList.list.begin();
|
|
|
|
it != cellRefList.list.end(); it++)
|
|
|
|
{
|
|
|
|
insertObj (cellRender, *it);
|
|
|
|
}
|
|
|
|
}
|
2010-06-03 18:44:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|