/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NSHADER_TREE__
#define	__NSHADER_TREE__


		#include "math/vector.h"
		#include "container/nlist.h"
		#include "memory/nshared_ptr.h"
		#include "nstring/nstring.h"


namespace GS {
	namespace Core {
		struct ShaderBlock;

/*
	@short	Shader tree.
	@author	Emmanuel Julien (ejulien@gsworks.fr)
*/
class	ShaderTree : public SharedObject
{
protected:

		/// Extract block from the map.
		void			GatherBlockList(List <ShaderBlock *> &block_list, ShaderBlock *root = 0);

public:

enum	ShaderSinkType
{
		SinkVertex	=	0,

		SinkNormal,
		SinkDiffuse,
		SinkModulate,
		SinkSpecular,
		SinkGlossiness,
		SinkConstant,
		SinkOpacity,
		SinkReflection,

		SinkInvalid
};

		String			name;

		Vector2			pos;
		ShaderBlock		*sink[SinkInvalid];

		/// Return a sink compatibility.
		int				GetSinkCompatibility(ShaderSinkType) const;

		/// Free map and all blocks.
		void			Free();

		bool			FromMetaTag(NML::Tag &);
		NML::Tag		*AsMetaTag() const;

		ShaderTree();
		~ShaderTree();
};

typedef	SharedPtr <ShaderTree> sShaderTree;

	} // Core
} // GS


#endif	// __NSHADER_TREE__
