用六种算法实现maya动画曲线光滑

在使用动补数据的时候,经常会有手脚等部位的抖动,特意写了个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
评论 30
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值