Skip to content

Commit

Permalink
GRAPHICS: Add Model::getStates() and getNodes()
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 29, 2014
1 parent 6fcb05e commit c3b53aa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/graphics/aurora/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,34 @@ Model::~Model() {
delete s->second;
}

std::vector<Common::UString> Model::getStates() const {
std::vector<Common::UString> names;

for (StateMap::const_iterator s = _states.begin(); s != _states.end(); ++s)
names.push_back(s->first);

return names;
}

std::vector<Common::UString> Model::getNodes() const {
std::vector<Common::UString> names;

State *state = _currentState;
if (!state) {
StateMap::const_iterator rootState = _states.find("");
if (rootState != _states.end())
state = rootState->second;
}

if (!state)
return names;

for (NodeEntities::const_iterator n = state->nodeEntities.begin(); n != state->nodeEntities.end(); ++n)
names.push_back(n->first);

return names;
}

bool Model::setState(const Common::UString &name) {
StateMap::iterator s = _states.find(name);
if (s == _states.end())
Expand Down
6 changes: 6 additions & 0 deletions src/graphics/aurora/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class Model : public Renderable {
Model();
~Model();

/** Return the name of every state in this model. */
std::vector<Common::UString> getStates() const;

/** Return the name of node in this state of the model. */
std::vector<Common::UString> getNodes() const;

/** Set the model into a different state. */
bool setState(const Common::UString &name);

Expand Down

0 comments on commit c3b53aa

Please sign in to comment.