cgfxEffectDef.h
#ifndef _cgfxEffectDef_h_
#define _cgfxEffectDef_h_
#include "cgfxShaderCommon.h"
class cgfxShaderNode;
class cgfxEffect;
#include <maya/MDagPath.h>
#include <maya/MObjectHandle.h>
class cgfxVertexAttribute
{
public:
cgfxVertexAttribute();
MString fName;
MString fSemantic;
MString fUIName;
MString fType;
MString fSourceName;
enum
{
kNone,
kPosition,
kNormal,
kUV,
kTangent,
kBinormal,
kColor,
kBlindData,
kUnknown
} fSourceType;
int fSourceIndex;
cgfxVertexAttribute* fNext;
};
#define MAX_STRUCTURE_ELEMENTS 16
class cgfxVaryingParameterStructure
{
public:
int fLength;
int fSize;
struct cgfxVaryingParameterElement
{
cgfxVertexAttribute* fVertexAttribute;
int fSize;
};
cgfxVaryingParameterElement fElements[ MAX_STRUCTURE_ELEMENTS];
};
class cgfxStructureCache
{
public:
cgfxStructureCache( const MDagPath& shape, const MString& name, int stride, int count);
~cgfxStructureCache();
MObjectHandle fShape;
MString fName;
int fElementSize;
int fVertexCount;
char* fData;
cgfxStructureCache* fNext;
};
class cgfxVaryingParameter
{
public:
cgfxVaryingParameter( CGparameter parameter);
~cgfxVaryingParameter();
void setupAttributes( cgfxVertexAttribute*& vertexAttributes, CGprogram program);
cgfxVertexAttribute* setupAttribute( MString name, const MString& semantic, CGparameter parameter, cgfxVertexAttribute*& vertexAttributes);
void bind( const MDagPath& shape, cgfxStructureCache** cache,
int vertexCount, const float * vertexArray,
int normalsPerVertex, int normalCount, const float ** normalArrays,
int colorCount, const float ** colorArrays,
int texCoordCount, const float ** texCoordArrays);
bool bind( const float* data, int stride);
void null();
CGparameter fParameter;
MString fName;
int fGLType;
int fGLIndex;
cgfxVertexAttribute* fVertexAttribute;
cgfxVaryingParameterStructure* fVertexStructure;
cgfxVaryingParameter* fNext;
};
class cgfxPass
{
public:
cgfxPass( CGpass pass, cgfxEffect* effect);
~cgfxPass();
void setupAttributes( cgfxVertexAttribute*& vertexAttributes);
void bind( const MDagPath& shape,
int vertexCount, const float * vertexArray,
int normalsPerVertex, int normalCount, const float ** normalArrays,
int colorCount, const float ** colorArrays,
int texCoordCount, const float ** texCoordArrays);
CGpass fPass;
CGprogram fProgram;
MString fName;
cgfxEffect* fEffect;
cgfxVaryingParameter* fParameters;
cgfxPass* fNext;
};
class cgfxTechnique
{
public:
cgfxTechnique( CGtechnique technique, cgfxEffect* effect);
~cgfxTechnique();
void setupAttributes( cgfxVertexAttribute*& vertexAttributes);
CGtechnique fTechnique;
MString fName;
cgfxEffect* fEffect;
cgfxPass* fPasses;
bool fValid;
bool fMultiPass;
cgfxTechnique* fNext;
};
class cgfxEffect
{
public:
cgfxEffect();
~cgfxEffect();
void setEffect( CGeffect effect);
void setupAttributes( cgfxShaderNode* shader);
void flushCache();
void flushCache( const MDagPath& shape);
CGeffect fEffect;
cgfxTechnique* fTechnique;
cgfxTechnique* fTechniques;
cgfxStructureCache* fCache;
};
#undef VALID
#endif