#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 <assert.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;
}
{
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();
}
MQuaternion rockingTransformMatrix::preRotation()
const
{
DegreeRadianConverter conv;
double newTheta = conv.degreesToRadians(getRockInX());
return quat;
}
rockingTransformNode::rockingTransformNode()
: ParentClass()
{
}
void rockingTransformNode::postConstructor()
{
ParentClass::postConstructor();
MPlug aRockInXPlug(thisMObject(), aRockInX);
}
{
ReturnOnError(status);
rockingTransformMatrix* ltm = dynamic_cast<rockingTransformMatrix*>(xform);
assert(ltm);
ltm->setRockInX(rockInXHandle.
asDouble());
return ParentClass::computeLocalTransformation(xform, block);
}
{
{
rockingTransformMatrix *ltm = getRockingTransformMatrix();
if (ltm) {
computeLocalTransformation(ltm, block);
} 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);
rockingTransformMatrix *ltm = getRockingTransformMatrix();
if (ltm)
ltm->setRockInX(rockInX);
else
dirtyMatrix();
return status;
}
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);
}