void Material::add_texture(Texture *tex, int type)
{
- textures.push_back(tex);
+ if(std::find(textures.begin(), textures.end(), tex) == textures.end()) {
+ textures.push_back(tex);
+ }
if(type != MTL_TEX_UNKNOWN) {
stdtex[type] = tex;
}
}
+void Material::remove_texture(Texture *tex)
+{
+ std::vector<Texture*>::iterator it = std::find(textures.begin(), textures.end(), tex);
+ if(it != textures.end()) {
+ textures.erase(it);
+ }
+
+ for(int i=0; i<NUM_MTL_TEXTURES; i++) {
+ if(stdtex[i] == tex) {
+ stdtex[i] = 0;
+ }
+ }
+}
+
int mtl_parse_type(const char *str)
{
if(strcmp(str, "diffuse") == 0) {