goat3d

view src/material.h @ 8:cd71f0b92f44

a bit more...
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 21 Aug 2013 05:52:28 +0300
parents e46529a5d057
children 04bb114fcf05
line source
1 #ifndef MATERIAL_H_
2 #define MATERIAL_H_
4 #include <string>
5 #include <map>
6 #include <vmath/vmath.h>
8 struct MaterialAttrib {
9 Vector4 value;
10 std::string map;
11 };
13 #define MAT_ATTR_DIFFUSE "diffuse"
14 #define MAT_ATTR_SPECULAR "specular"
15 #define MAT_ATTR_SHININESS "shininess"
16 #define MAT_ATTR_NORMAL "normal"
17 #define MAT_ATTR_BUMP "bump"
18 #define MAT_ATTR_REFLECTION "reflection"
19 #define MAT_ATTR_TRANSMISSION "transmission"
20 #define MAT_ATTR_IOR "ior"
22 class Material {
23 private:
24 static MaterialAttrib def_attr;
26 std::map<std::string, MaterialAttrib> attrib;
28 public:
29 std::string name;
31 MaterialAttrib &operator [](const std::string &name)
32 {
33 return attrib[name];
34 }
36 const MaterialAttrib &operator [](const std::string &name) const
37 {
38 std::map<std::string, MaterialAttrib>::const_iterator it;
39 if((it = attrib.find(name)) != attrib.end()) {
40 return it->second;
41 }
42 return def_attr;
43 }
44 };
46 #endif // MATERIAL_H_