#include <maya/MFnPlugin.h>
#include <maya/MDagPath.h>
#include <maya/MFnMesh.h>
#include <maya/MMeshIntersector.h>
#include <maya/MItSelectionList.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MObject.h>
#include <maya/MSelectionList.h>
#include <maya/MArgList.h>
#include <maya/MFloatPoint.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnPointLight.h>
#include <maya/MFloatPointArray.h>
#include <maya/MPxCommand.h>
#include <maya/MDGModifier.h>
#include <maya/MFnDagNode.h>
#include <maya/MDagPath.h>
#include <maya/MGlobal.h>
#include <maya/MIOStream.h>
#define MERR_CHK(status,msg) if ( !status ) { MGlobal::displayError(msg); } // cerr << msg << endl; }
{
    public:
        closestPointCmd();
        virtual ~closestPointCmd();
        static void* creator();
};
closestPointCmd::closestPointCmd()
{
}
closestPointCmd::~closestPointCmd()
{
}
void* closestPointCmd::creator()
{
   return new closestPointCmd;
}
bool closestPointCmd::isUndoable() const
{
   return false;
}
{
    {
    }
    int i;
    for ( i = 0; i < 2; i++)
    {
        status = args.
get(i, strCurrSelection);
    }
    float fX = 0;
    float fY = 0;
    float fZ = 0;
    for ( ; !iter.isDone(); iter.next() )
    {
        MObject tempObjectParent, tempObjectChild;
 
        iter.getDependNode(tempObjectParent);
        {
            tempObjectChild = dagNod.
child(0, &status);
        }
        
        {
                    "Couldn't get a path to the pointlight");
            MERR_CHK(fnLight.
setObject(pathToLight), 
"Failure on assigning light");
            {
            }
            pTempPlug = fnDN.
findPlug(
"translateY", &status);
            {
            }
            pTempPlug = fnDN.
findPlug(
"translateZ", &status);
            {
            }   
        }
        {
                "Couldn't get a path to the pointlight");
        }
        else
        {
        }
    }
    status = intersector.
create( node, matrix );
    if ( status )
    {
        cout << "Using point: " << point << endl;
        if ( status )
        {
            createDisplay( pointInfo, matrix );
        }
        else
        {
        }
    }
    else
    {
    }
    return status;
}
{
    
    return status;
}
{
    worldPoint = worldPoint * matrix;
    worldNormal = worldNormal * matrix;
    MString strCommandString = 
"string $strBall[] = `polySphere -r 0.5`;";
 
    strCommandString += "$strBallName = $strBall[0];";
    strCommandString += "setAttr ($strBallName + \".tx\") ";
    strCommandString += worldPoint.x;
    strCommandString += ";";
    strCommandString += "setAttr ($strBallName + \".ty\") ";
    strCommandString += worldPoint.y;
    strCommandString += ";";
    strCommandString += "setAttr ($strBallName + \".tz\") ";
    strCommandString += worldPoint.z;
    strCommandString += ";";
    
    cout << 
"Normal: " << worldNormal << 
" face id: " << info.
faceIndex() << 
}
{
    MFnPlugin plugin(obj, PLUGIN_COMPANY, 
"9.0", 
"Any");
 
    status = plugin.registerCommand("closestPointCmd", closestPointCmd::creator);
    return status;
}
{
    plugin.deregisterCommand("closestPointCmd");
    return status;
}