EMI: Share all materials for a given costume

This commit is contained in:
Dries Harnie 2012-07-14 11:55:41 +02:00
parent 0193a50f13
commit cf1d73420b
2 changed files with 17 additions and 0 deletions

View File

@ -92,6 +92,8 @@ void EMICostume::load(Common::SeekableReadStream *data) {
if (_emiSkel) {
_emiMesh->_obj->setSkeleton(_emiSkel->_obj);
}
for (unsigned int z = 0; z < _emiMesh->_obj->_numTextures; ++z)
_materials.push_back(_emiMesh->_obj->_mats[z]);
} else if (component->isComponentType('s','k','e','l')) {
_emiSkel = static_cast<EMISkelComponent *>(component);
if (_emiMesh) {
@ -220,6 +222,18 @@ int EMICostume::update(uint time) {
return marker;
}
Material * EMICostume::findSharedMaterial(const Common::String &name) {
Common::List<Material *>::iterator it = _materials.begin();
for (; it != _materials.end(); ++it)
if ((*it)->getFilename() == name)
return *it;
Material * mat = g_resourceloader->loadMaterial(name.c_str(), NULL);
_materials.push_back(mat);
return mat;
}
void EMICostume::saveState(SaveGame *state) const {
// TODO
return;

View File

@ -34,6 +34,7 @@ typedef uint32 tag32;
class EMISkelComponent;
class EMIMeshComponent;
class Material;
class EMICostume : public Costume {
public:
@ -47,9 +48,11 @@ public:
void saveState(SaveGame *state) const;
bool restoreState(SaveGame *state);
Material * findSharedMaterial(const Common::String &name);
public:
EMISkelComponent *_emiSkel;
EMIMeshComponent *_emiMesh;
Common::List<Material *> _materials;
private:
Component *loadComponent(Component *parent, int parentID, const char *name, Component *prevComponent);