在使用动补数据的时候,经常会有手脚等部位的抖动,特意写了个command,直接将动画曲线平滑一下,不用动画师大量的进行手调,下面是代码:
smoothAnimationCurveCmd.h
#ifndef _smoothAnimationCurve_
#define _smoothAnimationCurve_
#include <maya/MPxCommand.h>
#include <maya/MObject.h>
#include <maya/MSyntax.h>
#include <maya/MFnAnimCurve.h>
#include <maya/MAnimCurveChange.h>
#include <maya/MItDependencyNodes.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
class SmoothAnimationCurveCmd: public MPxCommand
{
public:
SmoothAnimationCurveCmd();
virtual ~SmoothAnimationCurveCmd();
virtual MStatus doIt( const MArgList& );
virtual MStatus redoIt();
virtual MStatus undoIt();
virtual bool isUndoable() const { return true; }
static void *creator(){ return new SmoothAnimationCurveCmd; }
static MSyntax newSyntax();
MStatus compliceMethod( MFnAnimCurve &fnAnim, MAnimCurveChange *animCache );
MItSelectionList getSelectObjectsAnimCurves();
private:
MString type;
int method;
unsigned int iterations;
MAnimCurveChange* pAnimCache;
};
#endif
smoothAnimationCurveCmd.cpp
#include "smoothAnimationCurveCmd.h"
#include <maya/MGlobal.h>
#include <maya/MFnPlugin.h>
#include <maya/MDagPath.h>
#include <maya/MPlugArray.h>
#include <maya/MObjectArray.h>
#include <maya/MArgDatabase.h>
#include <maya/MAnimUtil.h>
using namespace std;
const char *typeFlag = "-t", *typeLongFlag = "-type";
const char *methodFlag = "-md", *methodLongFlag = "-method";
const char *iterationsFlag = "-it", *iterationsLongFlag = "-iterations";
const char *helpFlag = "-h", *helpLong