#include <maya/MTypeId.h>
#include <maya/MTypes.h>
#include <maya/MPxManipulatorNode.h>
#include <maya/MFnPlugin.h>
#include <maya/MObjectHandle.h>
#include <maya/MPxCommand.h>
#include <maya/MSyntax.h>
#include <maya/MDagModifier.h>
#include <maya/MPxDrawOverride.h>
#include <maya/M3dView.h>
#include <maya/MPoint.h>
#include <maya/MGLFunctionTable.h>
#include "manipulatorMath.h"
class squareScaleManipulator : public MPxManipulatorNode
{
public:
squareScaleManipulator();
~squareScaleManipulator();
virtual void draw(
M3dView& view,
const MDagPath& path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status);
virtual MStatus doPress(M3dView& view);
virtual MStatus doDrag(M3dView& view);
virtual MStatus doRelease(M3dView& view);
MStatus updateDragInformation();
static void* creator();
static MStatus initialize();
static MTypeId id;
static MString classification;
static MString registrantId;
static const MPoint topLeft;
static const MPoint topRight;
static const MPoint bottomLeft;
static const MPoint bottomRight;
private:
bool shouldDraw(const MDagPath& camera) const;
MGLuint activeName, topName, rightName, bottomName, leftName;
friend class squareScaleManipulatorOverride;
float tl[4], tr[4], br[4], bl[4];
planeMath plane;
MPoint mousePointGlName;
};
class squareScaleManipulatorOverride : public MHWRender::MPxDrawOverride
{
public:
static MHWRender::MPxDrawOverride* Creator(const MObject& obj)
{
return new squareScaleManipulatorOverride(obj);
}
virtual ~squareScaleManipulatorOverride();
virtual MHWRender::DrawAPI supportedDrawAPIs() const;
virtual bool isBounded(
const MDagPath& objPath,
const MDagPath& cameraPath) const;
virtual MBoundingBox boundingBox(
const MDagPath& objPath,
const MDagPath& cameraPath) const;
virtual bool disableInternalBoundingBoxDraw() const;
virtual MUserData* prepareForDraw(
const MDagPath& objPath,
const MDagPath& cameraPath,
const MHWRender::MFrameContext& frameContext,
MUserData* oldData);
static void draw(
const MHWRender::MDrawContext& context,
const MUserData* data);
private:
squareScaleManipulatorOverride(const MObject& obj);
};