goat3d

view 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
line source
1 #include "material.h"
3 int Material::get_attrib_count() const
4 {
5 return (int)attrib.size();
6 }
8 const char *Material::get_attrib_name(int idx) const
9 {
10 if(idx < 0 || idx >= get_attrib_count()) {
11 return 0;
12 }
14 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
15 for(int i=0; i<idx; i++) it++;
16 return it->first.c_str();
17 }
19 MaterialAttrib &Material::operator [](int idx)
20 {
21 if(idx < 0 || idx >= get_attrib_count()) {
22 return def_attr;
23 }
25 std::map<std::string, MaterialAttrib>::iterator it = attrib.begin();
26 for(int i=0; i<idx; i++) it++;
27 return it->second;
28 }
30 const MaterialAttrib &Material::operator [](int idx) const
31 {
32 if(idx < 0 || idx >= get_attrib_count()) {
33 return def_attr;
34 }
36 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
37 for(int i=0; i<idx; i++) it++;
38 return it->second;
39 }
41 MaterialAttrib &Material::operator [](const std::string &name)
42 {
43 return attrib[name];
44 }
46 const MaterialAttrib &Material::operator [](const std::string &name) const
47 {
48 std::map<std::string, MaterialAttrib>::const_iterator it;
49 if((it = attrib.find(name)) != attrib.end()) {
50 return it->second;
51 }
52 return def_attr;
53 }