goat3d

diff 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 diff
     1.1 --- a/src/material.h	Sat Aug 17 16:10:26 2013 +0300
     1.2 +++ b/src/material.h	Sat Aug 17 23:51:24 2013 +0300
     1.3 @@ -1,8 +1,44 @@
     1.4  #ifndef MATERIAL_H_
     1.5  #define MATERIAL_H_
     1.6  
     1.7 +#include <string>
     1.8 +#include <map>
     1.9 +#include <vmath/vmath.h>
    1.10 +
    1.11 +struct MaterialAttrib {
    1.12 +	Vector4 value;
    1.13 +	std::string map;
    1.14 +};
    1.15 +
    1.16 +#define MAT_ATTR_DIFFUSE		"diffuse"
    1.17 +#define MAT_ATTR_SPECULAR		"specular"
    1.18 +#define MAT_ATTR_SHININESS		"shininess"
    1.19 +#define MAT_ATTR_NORMAL			"normal"
    1.20 +#define MAT_ATTR_BUMP			"bump"
    1.21 +#define MAT_ATTR_REFLECTION		"reflection"
    1.22 +#define MAT_ATTR_TRANSMISSION	"transmission"
    1.23 +#define MAT_ATTR_IOR			"ior"
    1.24 +
    1.25  class Material {
    1.26 -	// TODO
    1.27 +private:
    1.28 +	static MaterialAttrib def_attr;
    1.29 +
    1.30 +	std::map<std::string, MaterialAttrib> attrib;
    1.31 +
    1.32 +public:
    1.33 +	MaterialAttrib &operator [](const std::string &name)
    1.34 +	{
    1.35 +		return attrib[name];
    1.36 +	}
    1.37 +
    1.38 +	const MaterialAttrib &operator [](const std::string &name) const
    1.39 +	{
    1.40 +		std::map<std::string, MaterialAttrib>::const_iterator it;
    1.41 +		if((it = attrib.find(name)) != attrib.end()) {
    1.42 +			return it->second;
    1.43 +		}
    1.44 +		return def_attr;
    1.45 +	}
    1.46  };
    1.47  
    1.48  #endif	// MATERIAL_H_