goat3d
annotate src/material.cc @ 13:798df5111b56
moving slowly onwards
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 10 Sep 2013 15:29:45 +0300 |
parents | |
children | f1b4c27382ce |
rev | line source |
---|---|
nuclear@9 | 1 #include "material.h" |
nuclear@9 | 2 |
nuclear@9 | 3 int Material::get_attrib_count() const |
nuclear@9 | 4 { |
nuclear@9 | 5 return (int)attrib.size(); |
nuclear@9 | 6 } |
nuclear@9 | 7 |
nuclear@9 | 8 const char *Material::get_attrib_name(int idx) const |
nuclear@9 | 9 { |
nuclear@9 | 10 if(idx < 0 || idx >= get_attrib_count()) { |
nuclear@9 | 11 return 0; |
nuclear@9 | 12 } |
nuclear@9 | 13 |
nuclear@9 | 14 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin(); |
nuclear@9 | 15 for(int i=0; i<idx; i++) it++; |
nuclear@9 | 16 return it->first.c_str(); |
nuclear@9 | 17 } |
nuclear@9 | 18 |
nuclear@9 | 19 MaterialAttrib &Material::operator [](int idx) |
nuclear@9 | 20 { |
nuclear@9 | 21 if(idx < 0 || idx >= get_attrib_count()) { |
nuclear@9 | 22 return def_attr; |
nuclear@9 | 23 } |
nuclear@9 | 24 |
nuclear@9 | 25 std::map<std::string, MaterialAttrib>::iterator it = attrib.begin(); |
nuclear@9 | 26 for(int i=0; i<idx; i++) it++; |
nuclear@9 | 27 return it->second; |
nuclear@9 | 28 } |
nuclear@9 | 29 |
nuclear@9 | 30 const MaterialAttrib &Material::operator [](int idx) const |
nuclear@9 | 31 { |
nuclear@9 | 32 if(idx < 0 || idx >= get_attrib_count()) { |
nuclear@9 | 33 return def_attr; |
nuclear@9 | 34 } |
nuclear@9 | 35 |
nuclear@9 | 36 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin(); |
nuclear@9 | 37 for(int i=0; i<idx; i++) it++; |
nuclear@9 | 38 return it->second; |
nuclear@9 | 39 } |
nuclear@9 | 40 |
nuclear@9 | 41 MaterialAttrib &Material::operator [](const std::string &name) |
nuclear@9 | 42 { |
nuclear@9 | 43 return attrib[name]; |
nuclear@9 | 44 } |
nuclear@9 | 45 |
nuclear@9 | 46 const MaterialAttrib &Material::operator [](const std::string &name) const |
nuclear@9 | 47 { |
nuclear@9 | 48 std::map<std::string, MaterialAttrib>::const_iterator it; |
nuclear@9 | 49 if((it = attrib.find(name)) != attrib.end()) { |
nuclear@9 | 50 return it->second; |
nuclear@9 | 51 } |
nuclear@9 | 52 return def_attr; |
nuclear@9 | 53 } |
nuclear@9 | 54 |