WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
WoWItem.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------*\
2| This file is part of WoW Model Viewer |
3| |
4| WoW Model Viewer is free software: you can redistribute it and/or |
5| modify it under the terms of the GNU General Public License as |
6| published by the Free Software Foundation, either version 3 of the |
7| License, or (at your option) any later version. |
8| |
9| WoW Model Viewer is distributed in the hope that it will be useful, |
10| but WITHOUT ANY WARRANTY; without even the implied warranty of |
11| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12| GNU General Public License for more details. |
13| |
14| You should have received a copy of the GNU General Public License |
15| along with WoW Model Viewer. |
16| If not, see <http://www.gnu.org/licenses/>. |
17\*----------------------------------------------------------------------*/
18
19#pragma once
21#include <map>
22#include <string>
23#include <vector>
24#include "WoWDatabase.h"
25#include "GameFile.h"
26#include "wow_enums.h"
27#include "Component.h"
28
29#include "pugixml.hpp"
30
31class Attachment;
32class WoWModel;
33
38class WoWItem : public Component
39{
40public:
42
43 void setId(int id);
44 int id() const { return id_; }
45
46 void setDisplayId(int id);
47 void setLevel(int level);
48 void setModifierId(int id);
49
50 CharSlots slot() const { return slot_; }
51
52 int quality() const { return quality_; }
53
54 void refresh();
55
56 void onParentSet(Component*) override;
57
58 void load();
59
60 unsigned int nbLevels() const { return nbLevels_; }
61
62 std::map<POSITION_SLOTS, WoWModel*> models() const { return itemModels_; }
63
64 void save(pugi::xml_node& parentNode) const;
65 void load(const std::string& filepath);
66
67private:
68 void unload();
69
70 bool isCustomizableTabard() const;
71
72 WoWModel* charModel_ = nullptr;
73
74 int id_ = -1;
75 int displayId_ = -1;
76 int quality_ = 0;
77 int level_ = 0;
78 int type_ = 0;
80 unsigned int nbLevels_ = 0;
81
83
84 static std::map<CharSlots, int> SLOT_LAYERS_;
85 static std::map<std::string, int> MODELID_OFFSETS_;
86
87 std::map<CharRegions, GameFile*> itemTextures_;
88 std::map<CharGeosets, int> itemGeosets_;
89 std::map<int, int> levelDisplayMap_;
90 std::map<int, int> modifierIdDisplayMap_;
91 std::map<POSITION_SLOTS, WoWModel*> itemModels_;
93
94 void updateItemModel(POSITION_SLOTS pos, int modelId, int textureId);
95 void mergeModel(CharSlots slot, int modelId, int textureId);
96
98
99 int getCustomModelId(size_t index) const;
100 int getCustomTextureId(size_t index) const;
101};
Scene-graph node that attaches a Displayable to a parent bone slot.
Definition Attachment.h:21
Base class for all scene-graph nodes in the component hierarchy.
Definition Component.h:11
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
Represents an equipped item on a character model.
Definition WoWItem.h:39
std::map< CharGeosets, int > itemGeosets_
Definition WoWItem.h:88
void setDisplayId(int id)
Definition WoWItem.cpp:112
WoWModel * charModel_
Definition WoWItem.h:72
int displayFlags_
Definition WoWItem.h:79
int displayId_
Definition WoWItem.h:75
std::map< int, int > modifierIdDisplayMap_
Definition WoWItem.h:90
int getCustomTextureId(size_t index) const
Definition WoWItem.cpp:1230
CharSlots slot_
Definition WoWItem.h:82
unsigned int nbLevels_
Definition WoWItem.h:80
int id() const
Definition WoWItem.h:44
int level_
Definition WoWItem.h:77
CharRegions getRegionForTexture(GameFile *file) const
Definition WoWItem.cpp:998
void setId(int id)
Definition WoWItem.cpp:34
void load()
Definition WoWItem.cpp:204
bool isCustomizableTabard() const
Definition WoWItem.cpp:863
std::map< int, int > levelDisplayMap_
Definition WoWItem.h:89
int getCustomModelId(size_t index) const
Definition WoWItem.cpp:1152
void save(pugi::xml_node &parentNode) const
Definition WoWItem.cpp:870
int type_
Definition WoWItem.h:78
int quality_
Definition WoWItem.h:76
CharSlots slot() const
Definition WoWItem.h:50
void onParentSet(Component *) override
Called after the parent has been set; override for custom logic.
Definition WoWItem.cpp:166
std::map< POSITION_SLOTS, WoWModel * > models() const
Definition WoWItem.h:62
void refresh()
Definition WoWItem.cpp:603
void mergeModel(CharSlots slot, int modelId, int textureId)
Definition WoWItem.cpp:969
void unload()
Definition WoWItem.cpp:171
static std::map< std::string, int > MODELID_OFFSETS_
Definition WoWItem.h:85
int quality() const
Definition WoWItem.h:52
WoWModel * mergedModel_
Definition WoWItem.h:92
std::map< CharRegions, GameFile * > itemTextures_
Definition WoWItem.h:87
int id_
Definition WoWItem.h:74
void setModifierId(int id)
Definition WoWItem.cpp:145
void setLevel(int level)
Definition WoWItem.cpp:123
unsigned int nbLevels() const
Definition WoWItem.h:60
static std::map< CharSlots, int > SLOT_LAYERS_
Definition WoWItem.h:20
std::map< POSITION_SLOTS, WoWModel * > itemModels_
Definition WoWItem.h:91
void updateItemModel(POSITION_SLOTS pos, int modelId, int textureId)
Definition WoWItem.cpp:942
Core WoW .m2 model: geometry, animation, textures, and character data.
Definition WoWModel.h:50
POSITION_SLOTS
Attachment point positions on a character model.
Definition wow_enums.h:80
CharRegions
Texture compositing region IDs for character texture layout.
Definition wow_enums.h:141
CharSlots
Character equipment slot indices.
Definition wow_enums.h:5