#include <maya/MPxTransform.h>
#include <maya/MPxTransformationMatrix.h>
#include <maya/MGlobal.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MTransformationMatrix.h>
#include <maya/MIOStream.h>
#include "rockingTransform2.h"
#ifndef M_PI
#include <math.h>
#endif
MObject rockingTransformNode::aRockInX;
MTypeId rockingTransformNode::id(kRockingTransformNodeID);
MTypeId rockingTransformMatrix::id(kRockingTransformMatrixID);
rockingTransformMatrix::rockingTransformMatrix()
{
rockXValue = 0.0;
}
{
return new rockingTransformMatrix();
}
double rockingTransformMatrix::getRockInX() const
{
return rockXValue;
}
void rockingTransformMatrix::setRockInX( double rock )
{
rockXValue = rock;
}
MMatrix rockingTransformMatrix::asMatrix()
const
{
MMatrix m = ParentClass::asMatrix();
DegreeRadianConverter conv;
double newTheta = conv.degreesToRadians( getRockInX() );
}
MMatrix rockingTransformMatrix::asMatrix(
double percent)
const
{
trans *= percent;
m.translateTo( trans );
MPoint rotatePivotTrans = m.rotatePivot();
rotatePivotTrans = rotatePivotTrans * percent;
m.setRotatePivot( rotatePivotTrans );
MPoint scalePivotTrans = m.scalePivotTranslation();
scalePivotTrans = scalePivotTrans * percent;
m.setScalePivotTranslation( scalePivotTrans );
DegreeRadianConverter conv;
double newTheta = conv.degreesToRadians( getRockInX() );
m.rotateBy( quat );
s.x = 1.0 + (s.x - 1.0)*percent;
s.y = 1.0 + (s.y - 1.0)*percent;
s.z = 1.0 + (s.z - 1.0)*percent;
return m.asMatrix();
}
MMatrix rockingTransformMatrix::asRotateMatrix()
const
{
return ParentClass::asRotateMatrix();
}
rockingTransformNode::rockingTransformNode()
: ParentClass()
{
rockXValue = 0.0;
}
void rockingTransformNode::postConstructor()
{
ParentClass::postConstructor();
MPlug aRockInXPlug(thisMObject(), aRockInX);
}
rockingTransformNode::~rockingTransformNode()
{
}
{
return new rockingTransformMatrix();
}
void *rockingTransformNode::creator()
{
return new rockingTransformNode();
}
MStatus rockingTransformNode::initialize()
{
addAttribute(aRockInX);
mustCallValidateAndSet(aRockInX);
return MS::kSuccess;
}
const char* rockingTransformNode::className()
{
return "rockingTransformNode";
}
void rockingTransformNode::resetTransformation (
const MMatrix &matrix)
{
ParentClass::resetTransformation( matrix );
}
{
ParentClass::resetTransformation( resetMatrix );
}
{
return MS::kFailure;
ReturnOnError(status);
if ( plug == aRockInX )
{
blockHandle.
set(rockInX);
rockXValue = rockInX;
rockingTransformMatrix *ltm = getRockingTransformMatrix();
if (ltm)
ltm->setRockInX(rockXValue);
dirtyMatrix();
}
return ParentClass::validateAndSetValue(plug, handle);
}
rockingTransformMatrix *rockingTransformNode::getRockingTransformMatrix()
{
rockingTransformMatrix *ltm = (rockingTransformMatrix *) transformationMatrixPtr();
return ltm;
}
double DegreeRadianConverter::degreesToRadians( double degrees )
{
return degrees * ( M_PI/ 180.0 );
}
double DegreeRadianConverter::radiansToDegrees( double radians )
{
return radians * (180.0/M_PI);
}