2010-07-02 07:24:16 +00:00
|
|
|
#include "cellimp.hpp"
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-12 11:34:15 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
using namespace MWRender;
|
2010-06-06 22:33:45 +00:00
|
|
|
|
2010-06-25 20:28:59 +00:00
|
|
|
template<typename T>
|
2010-07-02 12:00:28 +00:00
|
|
|
void insertObj(CellRenderImp& cellRender, T& liveRef)
|
2010-06-12 11:34:15 +00:00
|
|
|
{
|
|
|
|
assert (liveRef.base != NULL);
|
|
|
|
const std::string &model = liveRef.base->model;
|
|
|
|
if(!model.empty())
|
|
|
|
{
|
|
|
|
cellRender.insertBegin (liveRef.ref);
|
|
|
|
cellRender.insertMesh ("meshes\\" + model);
|
2010-07-09 14:07:03 +00:00
|
|
|
liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled()));
|
2010-06-12 11:34:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-25 20:28:59 +00:00
|
|
|
|
|
|
|
template<>
|
2010-07-03 13:41:20 +00:00
|
|
|
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>& liveRef)
|
2010-06-12 11:34:15 +00:00
|
|
|
{
|
|
|
|
assert (liveRef.base != NULL);
|
|
|
|
const std::string &model = liveRef.base->model;
|
|
|
|
if(!model.empty())
|
|
|
|
{
|
|
|
|
cellRender.insertBegin (liveRef.ref);
|
2010-06-25 20:28:59 +00:00
|
|
|
|
2010-06-12 11:34:15 +00:00
|
|
|
cellRender.insertMesh ("meshes\\" + model);
|
2010-06-25 20:28:59 +00:00
|
|
|
|
2010-06-23 01:13:16 +00:00
|
|
|
// Extract the color and convert to floating point
|
|
|
|
const int color = liveRef.base->data.color;
|
|
|
|
const float r = ((color >> 0) & 0xFF) / 255.0f;
|
|
|
|
const float g = ((color >> 8) & 0xFF) / 255.0f;
|
|
|
|
const float b = ((color >> 16) & 0xFF) / 255.0f;
|
|
|
|
const float radius = float(liveRef.base->data.radius);
|
|
|
|
cellRender.insertLight(r, g, b, radius);
|
2010-06-25 20:28:59 +00:00
|
|
|
|
2010-07-09 14:07:03 +00:00
|
|
|
liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled()));
|
2010-06-25 20:28:59 +00:00
|
|
|
}
|
2010-06-12 11:34:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2010-07-02 12:00:28 +00:00
|
|
|
void insertCellRefList (CellRenderImp& cellRender, T& cellRefList)
|
2010-06-12 11:34:15 +00:00
|
|
|
{
|
2010-07-02 12:00:28 +00:00
|
|
|
for(typename T::List::iterator it = cellRefList.list.begin();
|
2010-06-12 11:34:15 +00:00
|
|
|
it != cellRefList.list.end(); it++)
|
|
|
|
{
|
|
|
|
insertObj (cellRender, *it);
|
2010-06-25 20:28:59 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-12 11:34:15 +00:00
|
|
|
|
2010-07-03 13:41:20 +00:00
|
|
|
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &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
|
|
|
}
|
|
|
|
|
|
|
|
|