goat3d

view src/material.cc @ 39:0e48907847ad

slugishly progressing with the blender exporter
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 09 Oct 2013 16:40:59 +0300
parents 04bb114fcf05
children 498ca7ac7047
line source
1 #include "material.h"
3 MaterialAttrib Material::def_attr;
5 int Material::get_attrib_count() const
6 {
7 return (int)attrib.size();
8 }
10 const char *Material::get_attrib_name(int idx) const
11 {
12 if(idx < 0 || idx >= get_attrib_count()) {
13 return 0;
14 }
16 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
17 for(int i=0; i<idx; i++) it++;
18 return it->first.c_str();
19 }
21 MaterialAttrib &Material::operator [](int idx)
22 {
23 if(idx < 0 || idx >= get_attrib_count()) {
24 return def_attr;
25 }
27 std::map<std::string, MaterialAttrib>::iterator it = attrib.begin();
28 for(int i=0; i<idx; i++) it++;
29 return it->second;
30 }
32 const MaterialAttrib &Material::operator [](int idx) const
33 {
34 if(idx < 0 || idx >= get_attrib_count()) {
35 return def_attr;
36 }
38 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
39 for(int i=0; i<idx; i++) it++;
40 return it->second;
41 }
43 MaterialAttrib &Material::operator [](const std::string &name)
44 {
45 return attrib[name];
46 }
48 const MaterialAttrib &Material::operator [](const std::string &name) const
49 {
50 std::map<std::string, MaterialAttrib>::const_iterator it;
51 if((it = attrib.find(name)) != attrib.end()) {
52 return it->second;
53 }
54 return def_attr;
55 }