goat3d

annotate src/material.cc @ 51:fa5c52ea9d59

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