goat3d

annotate src/material.cc @ 17:1d85d7dd0038

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