goat3d
view src/material.cc @ 57:76d0f55f9d5f
mesh and animation saving looks done...
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Jan 2014 03:57:15 +0200 |
parents | f1b4c27382ce |
children | dad392c710df |
line source
1 #include "material.h"
3 using namespace g3dimpl;
5 MaterialAttrib Material::def_attr;
7 int Material::get_attrib_count() const
8 {
9 return (int)attrib.size();
10 }
12 const char *Material::get_attrib_name(int idx) const
13 {
14 if(idx < 0 || idx >= get_attrib_count()) {
15 return 0;
16 }
18 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
19 for(int i=0; i<idx; i++) it++;
20 return it->first.c_str();
21 }
23 MaterialAttrib &Material::operator [](int idx)
24 {
25 if(idx < 0 || idx >= get_attrib_count()) {
26 return def_attr;
27 }
29 std::map<std::string, MaterialAttrib>::iterator it = attrib.begin();
30 for(int i=0; i<idx; i++) it++;
31 return it->second;
32 }
34 const MaterialAttrib &Material::operator [](int idx) const
35 {
36 if(idx < 0 || idx >= get_attrib_count()) {
37 return def_attr;
38 }
40 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
41 for(int i=0; i<idx; i++) it++;
42 return it->second;
43 }
45 MaterialAttrib &Material::operator [](const std::string &name)
46 {
47 return attrib[name];
48 }
50 const MaterialAttrib &Material::operator [](const std::string &name) const
51 {
52 std::map<std::string, MaterialAttrib>::const_iterator it;
53 if((it = attrib.find(name)) != attrib.end()) {
54 return it->second;
55 }
56 return def_attr;
57 }