#include "cgfxShaderCommon.h"
#include "cgfxShaderNode.h"
#include "cgfxProfile.h"
#include "cgfxShaderCmd.h"
#include "cgfxTextureCache.h"
#include "cgfxVector.h"
#include <maya/MFnPlugin.h>
#include <maya/MIOStream.h>
#include <maya/MSceneMessage.h>
#include <maya/MNodeMessage.h>
#include <maya/MGlobal.h>
#include <maya/MFileIO.h>
#include <maya/MItDependencyNodes.h>
#include <maya/MDGMessage.h>
#if defined(_SWATCH_RENDERING_SUPPORTED_)
#include <maya/MHWShaderSwatchGenerator.h>
#include <maya/MHardwareRenderer.h>
#include <maya/MViewport2Renderer.h>
#endif
#include <maya/MDrawRegistry.h>
static void cgfxShaderFileSaveCB(void* clientData );
{
MString sVer = cgfxShaderNode::getPluginVersion();
#if defined(_SWATCH_RENDERING_SUPPORTED_)
const char *cgfxEnvVar = getenv("CGFX_SWATCH_RENDERING");
MString UserClassify =
MString(
"shader/surface/utility:drawdb/shader/surface/cgfxShader" );
{
#ifdef _WIN32
if (!cgfxEnvVar)
UserClassify =
MString(
"shader/surface/utility/:drawdb/shader/surface/cgfxShader:swatch/"+swatchName );
else
{
if ( 0 != strcmp(cgfxEnvVar,"0") )
UserClassify =
MString(
"shader/surface/utility/:drawdb/shader/surface/cgfxShader:swatch/"+swatchName );
}
#else
if ( cgfxEnvVar && ( 0 != strcmp(cgfxEnvVar,"0") ) )
{
UserClassify =
MString(
"shader/surface/utility/:drawdb/shader/surface/cgfxShader:swatch/"+swatchName );
}
#endif
}
#else
const MString UserClassify(
"shader/surface/utility:drawdb/shader/surface/cgfxShader" );
#endif
"cgfxShaderPluginInitStrings" ));
#if defined(_SWATCH_RENDERING_SUPPORTED_)
{
if (pRenderer) {
unsigned int width = 64, height = 64;
width,
height );
}
}
}
#else
#error "CgFx requires the Maya version 7 or greater"
#endif
cgfxTextureCache::initialize();
cgfxShaderNode::sCgContext = cgCreateContext();
cgSetErrorCallback(cgfxShaderNode::cgErrorCallBack);
cgSetErrorHandler(cgfxShaderNode::cgErrorHandler, 0);
cgGLRegisterStates(cgfxShaderNode::sCgContext);
cgGLSetManageTextureParameters(cgfxShaderNode::sCgContext, CG_TRUE);
cgSetAutoCompile(cgfxShaderNode::sCgContext, CG_COMPILE_LAZY);
cgSetLockingPolicy(CG_NO_LOCKS_POLICY);
cgGLSetDebugMode(CG_FALSE);
cgfxProfile::initialize();
if (cgfxProfile::getBestProfile() == NULL) {
MString(
"No supported Cg profiles were found. CgFx plugin will not be loaded.")
);
}
{
s += sVer;
}
cgfxShaderNode::sId,
cgfxShaderNode::creator,
cgfxShaderNode::initialize,
&UserClassify));
cgfxVector::sId,
cgfxVector::creator,
cgfxVector::initialize));
cgfxShaderCmd::creator,
cgfxShaderCmd::newSyntax));
cgfxShaderOverride::drawDbClassification,
cgfxShaderOverride::drawRegistrantId,
cgfxShaderOverride::Creator));
cgfxShaderCmd::sPluginPath = plugin.loadPath();
{
MString sCmd =
"evalDeferred \"source \\\"cgfxShader_initUI.mel\\\"\"";
}
cgfxShaderFileSaveCB, NULL, &status);
cgfxShaderFileSaveCB, NULL, &status);
}
{
cgDestroyContext(cgfxShaderNode::sCgContext);
cgfxProfile::uninitialize();
cgfxTextureCache::uninitialize();
cgfxShaderOverride::drawDbClassification, cgfxShaderOverride::drawRegistrantId));
}
static void cgfxShaderFileSaveCB(void* clientData )
{
workspace);
if (!status)
{
}
{
if (fnNode.typeId() == cgfxShaderNode::sId)
{
cgfxShaderNode* pNode = (cgfxShaderNode*)fnNode.userNode();
MString ShaderFxFile = pNode->shaderFxFile();
{
MPlug plShader = fnNode.findPlug( pNode->sShader );
OutputDebugString("CGFX shader pathname saved as: ");
OutputDebugString(ShaderFxFile.
asChar());
OutputDebugString("\n");
}
if( pNode->getTexturesByName())
{
cgfxAttrDefList::iterator it(pNode->attrDefList());
while (it)
{
cgfxAttrDef* aDef = (*it);
MObject oNode = pNode->thisMObject();
switch (aDef->fType)
{
case cgfxAttrDef::kAttrTypeColor1DTexture:
case cgfxAttrDef::kAttrTypeColor2DTexture:
case cgfxAttrDef::kAttrTypeColor3DTexture:
case cgfxAttrDef::kAttrTypeColor2DRectTexture:
case cgfxAttrDef::kAttrTypeNormalTexture:
case cgfxAttrDef::kAttrTypeBumpTexture:
case cgfxAttrDef::kAttrTypeCubeTexture:
case cgfxAttrDef::kAttrTypeEnvTexture:
case cgfxAttrDef::kAttrTypeNormalizationTexture:
{
aDef->getValue(oNode, pathname);
{
aDef->setValue(oNode, pathname);
OutputDebugString("CGFX texture pathname saved as: ");
OutputDebugString(pathname.
asChar());
OutputDebugString("\n");
}
}
break;
default:
break;
}
++it;
}
}
}
}
}