pull/7/head
Nicolay Korslund 15 years ago
commit 69cc88bcaf

@ -5,7 +5,7 @@
using namespace MWRender;
template<typename T>
void insertObj(CellRenderImp& cellRender, T& liveRef)
void insertObj(CellRenderImp& cellRender, T& liveRef, const ESMS::ESMStore& store)
{
assert (liveRef.base != NULL);
const std::string &model = liveRef.base->model;
@ -18,7 +18,7 @@ void insertObj(CellRenderImp& cellRender, T& liveRef)
}
template<>
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>& liveRef)
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>& liveRef, const ESMS::ESMStore& store)
{
assert (liveRef.base != NULL);
const std::string &model = liveRef.base->model;
@ -40,39 +40,57 @@ void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld:
}
}
template<>
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>& liveRef, const ESMS::ESMStore& store)
{
std::string headID = liveRef.base->head;
//get the part of the bodypart id which describes the race and the gender
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
std::string headModel = "meshes\\" + store.bodyParts.find(headID)->model;
cellRender.insertBegin(liveRef.ref);
cellRender.insertMesh(headModel);
//TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the right place
cellRender.insertMesh("meshes\\" + store.bodyParts.find(bodyRaceID + "chest")->model);
liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled()));
}
template<typename T>
void insertCellRefList (CellRenderImp& cellRender, T& cellRefList)
void insertCellRefList (CellRenderImp& cellRender, const ESMS::ESMStore& store, T& cellRefList)
{
for(typename T::List::iterator it = cellRefList.list.begin();
it != cellRefList.list.end(); it++)
{
insertObj (cellRender, *it);
insertObj (cellRender, *it, store);
}
}
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell)
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ESMS::ESMStore& store)
{
// Loop through all references in the cell
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);
insertCellRefList (*this, store, cell.activators);
insertCellRefList (*this, store, cell.potions);
insertCellRefList (*this, store, cell.appas);
insertCellRefList (*this, store, cell.armors);
insertCellRefList (*this, store, cell.books);
insertCellRefList (*this, store, cell.clothes);
insertCellRefList (*this, store, cell.containers);
insertCellRefList (*this, store, cell.creatures);
insertCellRefList (*this, store, cell.doors);
insertCellRefList (*this, store, cell.ingreds);
// insertCellRefList (*this, store, cell.creatureLists);
// insertCellRefList (*this, store, cell.itemLists);
insertCellRefList (*this, store, cell.lights);
insertCellRefList (*this, store, cell.lockpicks);
insertCellRefList (*this, store, cell.miscItems);
insertCellRefList (*this, store, cell.npcs);
insertCellRefList (*this, store, cell.probes);
insertCellRefList (*this, store, cell.repairs);
insertCellRefList (*this, store, cell.statics);
insertCellRefList (*this, store, cell.weapons);
}

@ -12,6 +12,11 @@ namespace ESM
class CellRef;
}
namespace ESMS
{
class ESMStore;
}
namespace MWRender
{
/// Base class for cell render, that implements inserting references into a cell in a
@ -35,7 +40,7 @@ namespace MWRender
/// finish inserting a new reference and return a handle to it.
virtual std::string insertEnd (bool Enable) = 0;
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ESMS::ESMStore& store);
};
}

@ -186,7 +186,7 @@ void InteriorCellRender::show()
configureAmbient();
configureFog();
insertCell(cell);
insertCell(cell, store);
}
void InteriorCellRender::hide()

@ -43,6 +43,7 @@ namespace MWRender
static bool lightOutQuadInLin;
ESMS::CellStore<MWWorld::RefData> &cell;
const ESMS::ESMStore &store;
MWScene &scene;
/// The scene node that contains all objects belonging to this
@ -78,8 +79,8 @@ namespace MWRender
public:
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWScene &_scene)
: cell(_cell), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, const ESMS::ESMStore& _store, MWScene &_scene)
: cell(_cell), store(_store), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
virtual ~InteriorCellRender() { destroy(); }

@ -455,7 +455,7 @@ namespace MWWorld
// This connects the cell data with the rendering scene.
std::pair<CellRenderCollection::iterator, bool> result =
mActiveCells.insert (std::make_pair (cell,
new MWRender::InteriorCellRender (*cell, mScene)));
new MWRender::InteriorCellRender (*cell, mStore, mScene)));
if (result.second)
{

@ -618,13 +618,13 @@ public:
return convertToUTF8(res);
}
// Convert a string from ISO-8859-1 encoding to UTF-8
// Convert a string from the encoding used by Morrowind to UTF-8
std::string convertToUTF8(std::string input)
{
std::string output = "";
//create convert description
iconv_t cd = iconv_open("UTF-8", "ISO-8859-1");
iconv_t cd = iconv_open("UTF-8", "WINDOWS-1252");
if (cd == (iconv_t)-1) //error handling
{

Loading…
Cancel
Save