2010-06-06 22:33:45 +00:00
|
|
|
#include "cell.hpp"
|
|
|
|
|
2010-06-12 11:34:15 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include "esm_store/cell_store.hpp"
|
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
using namespace MWRender;
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-12 11:34:15 +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)
|
|
|
|
{
|
|
|
|
assert (liveRef.base != NULL);
|
|
|
|
const std::string &model = liveRef.base->model;
|
|
|
|
if(!model.empty())
|
|
|
|
{
|
|
|
|
cellRender.insertBegin (liveRef.ref);
|
|
|
|
|
|
|
|
cellRender.insertMesh ("meshes\\" + model);
|
|
|
|
|
|
|
|
int color = liveRef.base->data.color;
|
|
|
|
|
2010-06-15 13:33:24 +00:00
|
|
|
cellRender.insertLight(color & 255,
|
|
|
|
(color >> 8) & 255,
|
|
|
|
(color >> 16) & 255,
|
|
|
|
liveRef.base->data.radius);
|
2010-06-12 11:34:15 +00:00
|
|
|
|
|
|
|
cellRender.insertEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-12 11:01:20 +00:00
|
|
|
void CellRender::insertCell(const ESMS::CellStore &cell)
|
2010-06-06 22:33:45 +00:00
|
|
|
{
|
2010-06-09 18:46:14 +00:00
|
|
|
// Loop through all references in the cell
|
2010-06-12 11:01:20 +00:00
|
|
|
insertCellRefList (*this, cell.activators);
|
|
|
|
insertCellRefList (*this, cell.potions);
|
|
|
|
insertCellRefList (*this, cell.appas);
|
|
|
|
insertCellRefList (*this, cell.armors);
|
|
|
|
insertCellRefList (*this, cell.books);
|
|
|
|
insertCellRefList (*this, cell.clothes);
|
|
|
|
insertCellRefList (*this, cell.containers);
|
|
|
|
insertCellRefList (*this, cell.creatures);
|
|
|
|
insertCellRefList (*this, cell.doors);
|
|
|
|
insertCellRefList (*this, cell.ingreds);
|
|
|
|
// insertCellRefList (*this, cell.creatureLists);
|
|
|
|
// insertCellRefList (*this, cell.itemLists);
|
|
|
|
insertCellRefList (*this, cell.lights);
|
|
|
|
insertCellRefList (*this, cell.lockpicks);
|
|
|
|
insertCellRefList (*this, cell.miscItems);
|
|
|
|
insertCellRefList (*this, cell.npcs);
|
|
|
|
insertCellRefList (*this, cell.probes);
|
|
|
|
insertCellRefList (*this, cell.repairs);
|
|
|
|
insertCellRefList (*this, cell.statics);
|
|
|
|
insertCellRefList (*this, cell.weapons);
|
2010-06-06 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|