#ifndef _dx11ShaderUniformParamBuilder_h_
#define _dx11ShaderUniformParamBuilder_h_
#include <maya/MUniformParameter.h>
#define WIN32_LEAN_AND_MEAN
#include <d3d11.h>
#if _MSC_VER >= 1700
#include <dxgi.h>
#else
#include <d3dx11.h>
#endif
#include <d3dx11effect.h>
#if USE_DIRECTXSDK_D3DX11EFFECTS
#ifndef USE_BOOL
#define USE_BOOL // use BOOL instead of bool
#endif
#include <stdint.h>
#endif
#include <map>
#include <string>
class dx11ShaderNode;
class CUniformParameterBuilder
{
public:
CUniformParameterBuilder();
void init(ID3DX11EffectVariable* inEffectVariable,dx11ShaderNode* inShader, int order);
bool build();
bool isValidUniformParameter()
{return mValidUniformParameter;}
{return mParam;}
ID3DX11EffectVariable* getEffectVariable()
{return mEffectVariable; }
{return mWarnings;}
enum ELightParameterType
{
eUndefined,
eLightPosition,
eLightDirection,
eLightColor,
eLightSpecularColor,
eLightAmbientColor,
eLightDiffuseColor,
eLightRange,
eLightFalloff,
eLightAttenuation0,
eLightAttenuation1,
eLightAttenuation2,
eLightTheta,
eLightPhi,
eLightShadowMap,
eLightShadowMapBias,
eLightShadowColor,
eLightShadowViewProj,
eLightShadowOn,
eLightIntensity,
eLightHotspot,
eLightEnable,
eLightType,
eDecayRate,
eLightAreaPosition0,
eLightAreaPosition1,
eLightAreaPosition2,
eLightAreaPosition3,
eLastParameterType,
};
ELightParameterType getLightParameterType()
{return mParamType;}
static MString& getLightParameterSemantic(
int lightParameterType);
enum ELightType
{
eNotLight,
eUndefinedLight,
ePointLight,
eSpotLight,
eDirectionalLight,
eAmbientLight,
eAreaLight,
};
ELightType getLightType()
{return mLightType;}
int getLightIndex()
{ return mLightIndex; }
int getUIGroupIndex()
{ return mUIGroupIndex; }
int getUIOrder()
{ return mUIOrder; }
static bool compareUIOrder(CUniformParameterBuilder* a, CUniformParameterBuilder* b)
{return (a->getUIOrder() < b->getUIOrder());}
protected:
bool getAnnotation(const char* name,LPCSTR& value);
bool getAnnotation(const char* name,float& value);
bool getAnnotation(const char* name,int& value);
bool getBOOLAnnotation(const char* name,BOOL& value);
ID3DX11EffectVariable* findAnnotationByName(ID3DX11EffectVariable *effectVariable, const char* name);
int getLength()
{
int rows = mDescType.Rows;
int columns = mDescType.Columns;
return rows * columns;
}
bool setParameterValueFromEffect();
void updateRangeFromAnnotation();
void updateUIVisibilityFromAnnotation();
void updateLightInfoFromSemantic();
void logUnrecognisedSemantic(const char* pSemantic);
ID3DX11EffectVariable* mEffectVariable;
dx11ShaderNode * mShader;
D3DX11_EFFECT_VARIABLE_DESC mDesc;
D3DX11_EFFECT_TYPE_DESC mDescType;
ELightParameterType mParamType;
ELightType mLightType;
int mLightIndex;
int mUIGroupIndex;
bool mValidUniformParameter;
int mUIOrder;
typedef std::map<std::string,uint32_t> TAnnotationIndex;
TAnnotationIndex mAnnotationIndex;
};
#endif