#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 "rockingTransform.h"
#ifndef M_PI
#include <math.h>
#endif
MObject rockingTransformNode::aRockInX;
MTypeId rockingTransformNode::id(kRockingTransformNodeID);
MTypeId rockingTransformMatrix::id(kRockingTransformMatrixID);
rockingTransformMatrix::rockingTransformMatrix()
{
rockXValue = 0.0;
}
void *rockingTransformMatrix::creator()
{
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;
}
: ParentClass(tm)
{
rockXValue = 0.0;
}
void rockingTransformNode::postConstructor()
{
ParentClass::postConstructor();
if (NULL == baseTransformationMatrix) {
}
MPlug aRockInXPlug(thisMObject(), aRockInX);
}
{
{
MPlug rockInXPlug( thisMObject(), aRockInX );
ReturnOnError(status);
rockingTransformMatrix *ltm = getRockingTransformMatrix();
if (ltm)
ltm->setRockInX(rockXValue);
else
}
}
rockingTransformNode::~rockingTransformNode()
{
}
{
return new rockingTransformMatrix();
}
void *rockingTransformNode::creator()
{
return new rockingTransformNode();
}
MStatus rockingTransformNode::initialize()
{
addAttribute(aRockInX);
attributeAffects(aRockInX, matrix);
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;
if ( plug == aRockInX )
{
ReturnOnError(status);
blockHandle.
set(rockInX);
rockXValue = rockInX;
rockingTransformMatrix *ltm = getRockingTransformMatrix();
if (ltm)
ltm->setRockInX(rockXValue);
else
dirtyMatrix();
return status;
}
return ParentClass::validateAndSetValue(plug, handle);
}
rockingTransformMatrix *rockingTransformNode::getRockingTransformMatrix()
{
rockingTransformMatrix *ltm = (rockingTransformMatrix *) baseTransformationMatrix;
return ltm;
}
double DegreeRadianConverter::degreesToRadians( double degrees )
{
return degrees * ( M_PI/ 180.0 );
}
double DegreeRadianConverter::radiansToDegrees( double radians )
{
return radians * (180.0/M_PI);
}