goat3d

view src/material.cc @ 14:188c697b3b49

- added a document describing the goat3d file format chunk hierarchy - started an alternative XML-based file format - added the openctm library
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Sep 2013 04:47:05 +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 }