WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
ModelManager.cpp
Go to the documentation of this file.
1#include "ModelManager.h"
2#include "WoWModel.h"
3
4// Adds models to the model manager, used by WMO's
6{
7 int id;
8 const auto& qname = file->name();
9 if (names.find(qname) != names.end())
10 {
11 id = names[qname];
12 items[id]->addref();
13 return id;
14 }
15 // load new
16 WoWModel* model = new WoWModel(file);
17 id = nextID();
18 do_add(qname, id, model);
19 return id;
20}
21
22// Resets the animation back to default.
24{
25 for (const auto& item : items)
26 {
27 static_cast<WoWModel*>(item.second)->animcalc = false;
28 }
29}
30
31// same as other updateEmitter except does it for the all the models being managed - for WMO's
33{
34 for (const auto& item : items)
35 {
36 static_cast<WoWModel*>(item.second)->updateEmitters(dt);
37 }
38}
39
41{
42 for (const auto& item : items)
43 {
44 doDelete(item.first);
45 delete item.second;
46 }
47 items.clear();
48 names.clear();
49}
std::string name() const
Definition Component.cpp:52
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
std::map< int, ManagedItem * > items
Definition manager.h:50
virtual void doDelete(int)
Definition manager.h:96
std::map< std::string, int > names
Definition manager.h:49
void do_add(const std::string &name, int id, ManagedItem *item)
Definition manager.h:149
void resetAnim()
Reset animations on all managed models.
void clear()
Remove and destroy all managed models.
int add(GameFile *)
Add a model from the given game file and return its handle.
void updateEmitters(float dt)
Update particle and ribbon emitters on all managed models.
int nextID()
Definition manager.h:167
Core WoW .m2 model: geometry, animation, textures, and character data.
Definition WoWModel.h:50