mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 05:09:43 +00:00
extended CellRender::show to show all types instead of only statics
This commit is contained in:
parent
f3d7f2e25a
commit
abbdffa0a1
2 changed files with 46 additions and 31 deletions
|
@ -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<Static>::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<Container>::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()
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _GAME_RENDER_CELL_H
|
||||
#define _GAME_RENDER_CELL_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#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<typename T>
|
||||
void insertObj(const T& liveRef)
|
||||
{
|
||||
assert (liveRef.base != NULL);
|
||||
insertMesh ("meshes\\" + liveRef.base->model, liveRef.ref);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue