goat3d

view src/material.h @ 1:e46529a5d057

some progress
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 17 Aug 2013 23:51:24 +0300
parents 2918358f5e6d
children cd71f0b92f44
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 MaterialAttrib &operator [](const std::string &name)
30 {
31 return attrib[name];
32 }
34 const MaterialAttrib &operator [](const std::string &name) const
35 {
36 std::map<std::string, MaterialAttrib>::const_iterator it;
37 if((it = attrib.find(name)) != attrib.end()) {
38 return it->second;
39 }
40 return def_attr;
41 }
42 };
44 #endif // MATERIAL_H_