diff --git a/game/mwrender/cell.cpp b/game/mwrender/cell.cpp index 98e6fb8c8..11aede27c 100644 --- a/game/mwrender/cell.cpp +++ b/game/mwrender/cell.cpp @@ -9,10 +9,8 @@ using namespace Ogre; using namespace ESMS; // Inserts one mesh into the scene -static void insertObj(SceneNode *base, // Parent scene node - SceneManager *mgr, // Scene manager - const std::string mesh, // NIF file - const CellRef &ref) // Reference information +void CellRender::insertMesh(const std::string mesh, // NIF file + const CellRef &ref) // Reference information { // Create and place scene node for this object SceneNode *node = base->createChildSceneNode(); @@ -38,7 +36,7 @@ static void insertObj(SceneNode *base, // Parent scene node // Finally, load the NIF mesh and attach it to the node NIFLoader::load(mesh); - MovableObject *ent = mgr->createEntity(mesh); + MovableObject *ent = scene.getMgr()->createEntity(mesh); node->attachObject(ent); } @@ -53,32 +51,27 @@ void CellRender::show() base = scene.getRoot()->createChildSceneNode(); - // Loop through all statics in the cell - CellRefList::List::const_iterator it; - for(it = cell.statics.list.begin(); - it != cell.statics.list.end(); - it++) - { - assert(it->base != NULL); - insertObj(base, scene.getMgr(), - "meshes\\" + it->base->model, - it->ref); - } - - /* - // Containers - CellRefList::List::const_iterator it; - - for(it = cell.containers.list.begin(); - it != cell.containers.list.end(); - it++) - { - assert(it->base != NULL); - - cout << "refID = " << it->ref.refID << " x" << it->ref.scale << endl; - cout << "flags = " << it->base->flags << endl; - } - */ + // Loop through all references in the cell + insertCellRefList (cell.activators); + insertCellRefList (cell.potions); + insertCellRefList (cell.appas); + insertCellRefList (cell.armors); + insertCellRefList (cell.books); + insertCellRefList (cell.clothes); + insertCellRefList (cell.containers); + insertCellRefList (cell.creatures); + insertCellRefList (cell.doors); + insertCellRefList (cell.ingreds); +// insertCellRefList (cell.creatureLists); +// insertCellRefList (cell.itemLists); + insertCellRefList (cell.lights); + insertCellRefList (cell.lockpicks); + insertCellRefList (cell.miscItems); + insertCellRefList (cell.npcs); + insertCellRefList (cell.probes); + insertCellRefList (cell.repairs); + insertCellRefList (cell.statics); + insertCellRefList (cell.weapons); } void CellRender::hide() diff --git a/game/mwrender/cell.hpp b/game/mwrender/cell.hpp index 6f3d64c9a..08c4e1edb 100644 --- a/game/mwrender/cell.hpp +++ b/game/mwrender/cell.hpp @@ -1,6 +1,8 @@ #ifndef _GAME_RENDER_CELL_H #define _GAME_RENDER_CELL_H +#include + #include "esm_store/cell_store.hpp" #include "mwscene.hpp" @@ -22,6 +24,26 @@ namespace MWRender /// cell. Ogre::SceneNode *base; + void insertMesh(const std::string mesh, // NIF file + const ESMS::CellRef &ref); // Reference information + + template + void insertObj(const T& liveRef) + { + assert (liveRef.base != NULL); + insertMesh ("meshes\\" + liveRef.base->model, liveRef.ref); + } + + template + void insertCellRefList (const T& cellRefList) + { + for(typename T::List::const_iterator it = cellRefList.list.begin(); + it != cellRefList.list.end(); it++) + { + insertObj (*it); + } + } + public: CellRender(const ESMS::CellStore &_cell, MWScene &_scene)