#include "CacheReaderAlembic.h"
#include "CacheWriterAlembic.h"
#include "gpuCacheShapeNode.h"
#include "gpuCacheDrawOverride.h"
#include "gpuCacheSubSceneOverride.h"
#include "gpuCacheCmd.h"
#include "gpuCacheConfig.h"
#include "gpuCacheUnitBoundingBox.h"
#include "gpuCacheVBOProxy.h"
#include <maya/MFnPlugin.h>
#include <maya/MDrawRegistry.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionMask.h>
#include "gpuCacheStrings.h"
using namespace GPUCache;
static MStatus registerMStringResources()
{
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"1.0",
"Any");
const MString& drawDbClassification =
(Config::vp2OverrideAPI() == Config::kMPxSubSceneOverride) ?
ShapeNode::drawDbClassificationSubScene :
ShapeNode::drawDbClassificationGeometry;
UserClassify += drawDbClassification;
status = plugin.registerShape(
ShapeNode::nodeTypeName, ShapeNode::id,
ShapeNode::creator, ShapeNode::initialize,
ShapeUI::creator,
&UserClassify );
if (!status) {
status.
perror(
"registerNode");
return status;
}
switch (Config::vp2OverrideAPI()) {
case Config::kMPxDrawOverride:
ShapeNode::drawDbClassificationGeometry,
ShapeNode::drawRegistrantId,
DrawOverride::creator);
if (!status) {
status.
perror(
"registerGeometryDrawCreator");
return status;
}
break;
case Config::kMPxSubSceneOverride:
default:
ShapeNode::drawDbClassificationSubScene,
ShapeNode::drawRegistrantId,
SubSceneOverride::creator);
if (!status) {
status.
perror(
"registerSubSceneOverrideCreator");
return status;
}
break;
}
status = plugin.registerUIStrings(registerMStringResources, "gpuCacheInitStrings");
if (!status)
{
status.
perror(
"registerUIStrings");
return status;
}
status = plugin.registerCommand(
"gpuCache", Command::creator, Command::cmdSyntax );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
if (!flag) {
status.
perror(
"registerSelectionType");
return MS::kFailure;
}
MString selectionGeomMenuItemLabel =
MString registerMenuItemCMD =
"addSelectTypeItem(\"Surface\",\"";
registerMenuItemCMD += ShapeNode::selectionMaskName;
registerMenuItemCMD += "\",\"";
registerMenuItemCMD += selectionGeomMenuItemLabel;
registerMenuItemCMD += "\")";
if (!status) {
status.
perror(
"addSelectTypeItem");
return status;
}
MString registerCustomFilterCMD =
"addCustomOutlinerFilter(\"gpuCache\",\"CustomGPUCacheFilter\",\"";
registerCustomFilterCMD += outlinerGeomMenuItemLabel;
registerCustomFilterCMD += "\",\"DefaultSubdivObjectsFilter\")";
if (!status) {
status.
perror(
"addCustomOutlinerFilter");
return status;
}
}
plugin.registerDisplayFilter(Config::kDisplayFilter,
displayFilterLabel,
drawDbClassification);
CacheWriter::registerWriter("Alembic", &AlembicCacheWriter::create);
CacheReader::registerReader("Alembic", &AlembicCacheReader::create);
return MS::kSuccess;
}
{
MString unregisterCustomFilterCMD =
"deleteCustomOutlinerFilter(\"CustomGPUCacheFilter\")";
if (!status) {
status.
perror(
"deleteCustomOutlinerFilter");
return status;
}
MString unregisterMenuItemCMD =
"deleteSelectTypeItem(\"Surface\",\"";
unregisterMenuItemCMD += ShapeNode::selectionMaskName;
unregisterMenuItemCMD += "\")";
if (!status) {
status.
perror(
"deleteSelectTypeItem");
return status;
}
if (!flag) {
status.
perror(
"deregisterSelectionType");
return MS::kFailure;
}
}
plugin.deregisterDisplayFilter(Config::kDisplayFilter);
switch (Config::vp2OverrideAPI()) {
case Config::kMPxDrawOverride:
ShapeNode::drawDbClassificationGeometry,
ShapeNode::drawRegistrantId);
if (!status) {
status.
perror(
"deregisterDrawOverrideCreator");
return status;
}
break;
case Config::kMPxSubSceneOverride:
default:
ShapeNode::drawDbClassificationSubScene,
ShapeNode::drawRegistrantId);
if (!status) {
status.
perror(
"deregisterSubSceneOverrideCreator");
return status;
}
break;
}
VBOBuffer::clear();
UnitBoundingBox::clear();
status = ShapeNode::uninitialize();
if (!status) {
status.
perror(
"ShapeNode::uninitialize()");
return status;
}
status = plugin.deregisterNode( ShapeNode::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
status = plugin.deregisterCommand( "gpuCache" );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
return MS::kSuccess;
}