#include <maya/MPxLocatorNode.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MVector.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MColor.h>
#include <maya/MFnPlugin.h>
#include <maya/MDistance.h>
#include <maya/MFnUnitAttribute.h>
#include <maya/MArrayDataBuilder.h>
#include <maya/MEvaluationNode.h>
#include <maya/MDrawRegistry.h>
#include <maya/MPxDrawOverride.h>
#include <maya/MUserData.h>
#include <maya/MDrawContext.h>
#include <maya/MHWGeometryUtilities.h>
#include <maya/MPointArray.h>
#include <maya/MGlobal.h>
#include <maya/MEventMessage.h>
#include <maya/MFnDependencyNode.h>
#include <assert.h>
static float sole[][3] = { { 0.00f, 0.0f, -0.70f },
{ 0.04f, 0.0f, -0.69f },
{ 0.09f, 0.0f, -0.65f },
{ 0.13f, 0.0f, -0.61f },
{ 0.16f, 0.0f, -0.54f },
{ 0.17f, 0.0f, -0.46f },
{ 0.17f, 0.0f, -0.35f },
{ 0.16f, 0.0f, -0.25f },
{ 0.15f, 0.0f, -0.14f },
{ 0.13f, 0.0f, 0.00f },
{ 0.00f, 0.0f, 0.00f },
{ -0.13f, 0.0f, 0.00f },
{ -0.15f, 0.0f, -0.14f },
{ -0.16f, 0.0f, -0.25f },
{ -0.17f, 0.0f, -0.35f },
{ -0.17f, 0.0f, -0.46f },
{ -0.16f, 0.0f, -0.54f },
{ -0.13f, 0.0f, -0.61f },
{ -0.09f, 0.0f, -0.65f },
{ -0.04f, 0.0f, -0.69f },
{ -0.00f, 0.0f, -0.70f } };
static float heel[][3] = { { 0.00f, 0.0f, 0.06f },
{ 0.13f, 0.0f, 0.06f },
{ 0.14f, 0.0f, 0.15f },
{ 0.14f, 0.0f, 0.21f },
{ 0.13f, 0.0f, 0.25f },
{ 0.11f, 0.0f, 0.28f },
{ 0.09f, 0.0f, 0.29f },
{ 0.04f, 0.0f, 0.30f },
{ 0.00f, 0.0f, 0.30f },
{ -0.04f, 0.0f, 0.30f },
{ -0.09f, 0.0f, 0.29f },
{ -0.11f, 0.0f, 0.28f },
{ -0.13f, 0.0f, 0.25f },
{ -0.14f, 0.0f, 0.21f },
{ -0.14f, 0.0f, 0.15f },
{ -0.13f, 0.0f, 0.06f },
{ -0.00f, 0.0f, 0.06f } };
static int soleCount = 21;
static int heelCount = 17;
{
public:
footPrint();
~footPrint() override;
static void * creator();
public:
static MString drawDbClassification;
};
MString footPrint::drawDbClassification(
"drawdb/geometry/footPrint");
MString footPrint::drawRegistrantId(
"FootprintNodePlugin");
footPrint::footPrint() {}
footPrint::~footPrint() {}
{
if (plug == worldS)
{
{
}
return MS::kSuccess;
}
return MS::kUnknownParameter;;
}
bool footPrint::isBounded() const
{
return true;
}
{
MPlug plug( thisNode, size );
MPoint corner1( -0.17, 0.0, -0.7 );
MPoint corner2( 0.17, 0.0, 0.3 );
corner1 = corner1 * multiplier;
corner2 = corner2 * multiplier;
}
{
{
{
}
}
}
{
}
void* footPrint::creator()
{
return new footPrint();
}
{
public:
MColor fColor{1.f, 0.f, 0.f, 1.f};
unsigned int fDepthPriority;
};
{
public:
{
return new FootPrintDrawOverride(obj);
}
~FootPrintDrawOverride() override;
const MDagPath& cameraPath)
const override;
const MDagPath& cameraPath)
const override;
{
return false;
}
{
fputs("footPrintDrawOverride: ",stderr);
fputs(message.
asChar(),stderr);
fputs("\n",stderr);
}
private:
FootPrintDrawOverride(
const MObject& obj);
float getMultiplier(
const MDagPath& objPath)
const;
static void OnModelEditorChanged(void *clientData);
footPrint* fFootPrint;
MCallbackId fModelEditorChangedCbId;
};
FootPrintDrawOverride::FootPrintDrawOverride(
const MObject& obj)
:
MHWRender::MPxDrawOverride(obj, NULL, false)
{
"modelEditorChanged", OnModelEditorChanged, this);
fFootPrint = status ? dynamic_cast<footPrint*>(node.userNode()) : NULL;
}
FootPrintDrawOverride::~FootPrintDrawOverride()
{
fFootPrint = NULL;
if (fModelEditorChangedCbId != 0)
{
fModelEditorChangedCbId = 0;
}
}
void FootPrintDrawOverride::OnModelEditorChanged(void *clientData)
{
FootPrintDrawOverride *ovr = static_cast<FootPrintDrawOverride*>(clientData);
if (ovr && ovr->fFootPrint)
{
}
}
MHWRender::DrawAPI FootPrintDrawOverride::supportedDrawAPIs() const
{
return (MHWRender::kOpenGL | MHWRender::kDirectX11 | MHWRender::kOpenGLCoreProfile);
}
float FootPrintDrawOverride::getMultiplier(
const MDagPath& objPath)
const
{
if (status)
{
MPlug plug(footprintNode, footPrint::size);
{
{
}
}
}
return 1.0f;
}
bool FootPrintDrawOverride::isBounded(
const MDagPath& ,
{
return true;
}
{
MPoint corner1( -0.17, 0.0, -0.7 );
MPoint corner2( 0.17, 0.0, 0.3 );
float multiplier = getMultiplier(objPath);
corner1 = corner1 * multiplier;
corner2 = corner2 * multiplier;
}
MUserData* FootPrintDrawOverride::prepareForDraw(
{
FootPrintData* data = dynamic_cast<FootPrintData*>(oldData);
if (!data)
{
data = new FootPrintData();
}
float fMultiplier = getMultiplier(objPath);
data->fLineList.clear();
for (int i = 0; i <= soleCount - 2; i++)
{
data->fLineList.append(sole[i][0] * fMultiplier, sole[i][1] * fMultiplier, sole[i][2] * fMultiplier);
data->fLineList.append(sole[i+1][0] * fMultiplier, sole[i+1][1] * fMultiplier, sole[i+1][2] * fMultiplier);
}
for (int i = 0; i <= heelCount - 2; i++)
{
data->fLineList.append(heel[i][0] * fMultiplier, heel[i][1] * fMultiplier, heel[i][2] * fMultiplier);
data->fLineList.append(heel[i+1][0] * fMultiplier, heel[i+1][1] * fMultiplier, heel[i+1][2] * fMultiplier);
}
data->fTriangleList.clear();
for (int i = 1; i <= soleCount - 2; i++)
{
data->fTriangleList.append(sole[0][0] * fMultiplier, sole[0][1] * fMultiplier, sole[0][2] * fMultiplier);
data->fTriangleList.append(sole[i][0] * fMultiplier, sole[i][1] * fMultiplier, sole[i][2] * fMultiplier);
data->fTriangleList.append(sole[i+1][0] * fMultiplier, sole[i+1][1] * fMultiplier, sole[i+1][2] * fMultiplier);
}
for (int i = 1; i <= heelCount - 2; i++)
{
data->fTriangleList.append(heel[0][0] * fMultiplier, heel[0][1] * fMultiplier, heel[0][2] * fMultiplier);
data->fTriangleList.append(heel[i][0] * fMultiplier, heel[i][1] * fMultiplier, heel[i][2] * fMultiplier);
data->fTriangleList.append(heel[i+1][0] * fMultiplier, heel[i+1][1] * fMultiplier, heel[i+1][2] * fMultiplier);
}
{
case MHWRender::kLead:
case MHWRender::kActive:
case MHWRender::kHilite:
case MHWRender::kActiveComponent:
break;
default:
break;
}
return data;
}
void FootPrintDrawOverride::addUIDrawables(
{
FootPrintData* pLocatorData = (FootPrintData*)data;
if (!pLocatorData)
{
return;
}
drawManager.
setColor( pLocatorData->fColor );
}
MColor textColor( 0.1f, 0.8f, 0.8f, 1.0f );
}
{
stat = addAttribute( size );
if (!stat) {
return stat;
}
addAttribute( worldS );
attributeAffects(size, worldS);
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerNode(
"footPrint",
footPrint::id,
&footPrint::creator,
&footPrint::initialize,
&footPrint::drawDbClassification);
if (!status) {
status.
perror(
"registerNode");
return status;
}
footPrint::drawDbClassification,
footPrint::drawRegistrantId,
FootPrintDrawOverride::Creator);
if (!status) {
status.
perror(
"registerDrawOverrideCreator");
return status;
}
return status;
}
{
footPrint::drawDbClassification,
footPrint::drawRegistrantId);
if (!status) {
status.
perror(
"deregisterDrawOverrideCreator");
return status;
}
status = plugin.deregisterNode( footPrint::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
return status;
}