goat3d

view src/material.cc @ 58:d317eb4f83da

- made everything compile properly on windows again - removed libanim/libvmath, we'll use them as external dependencies - added new maxgoat_stub 3dsmax plugin project. Gets loaded as a max plugin and loads the actual maxgoat (and later maxgoat_anim) exporters on demand, to allow reloading the actual exporters without having to restart 3dsmax (which takes AGES).
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Mar 2014 03:19:55 +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 }