maya履带动画绑定插件代码
好酷屋教程网小编为您收集和整理了maya履带动画绑定插件代码的相关教程:下面的maya履带动画api源码,需要大家自己在vs里编译。//首先是头文件代码://头文件名称:glideDeformer.h#ifndefglideDeformer_h#defineglideD
下面的maya履带动画api源码,需要大家自己在vs里编译。
//首先是头文件代码://头文件名称:glideDeformer.h#ifndefglideDeformer_h#defineglideDeformer_h#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeclassglideDeformer:publicMpxDeformerNode{public:glideDeformer(){};virtual~glideDeformer(){};staticvoid*creator(){returnnewglideDeformer;};staticMStatusinitializeAttr();virtualMStatusdeform(MDataBlock&block,MItGeometry&iter,constMMatrix&mat,unsignedintmultiIndex);boolgetClosestUVparam(Mpoint&point,MFnNurbsSurface&surfaceFn,MObjectsurfaceData,double¶mU,double¶mV);boolgetpointFroamSurfacepoint(Mpoint&point,MFnNurbsSurface&surfaceFn,MObjectsurfaceData,double¶mU,double¶mV,Mpoint&outpoint);boolgetpointAfterDeformed(Mpoint&pointInSurfaceMatrix,MFnNurbsSurface&surfaceFn,MObjectsurfaceData,double¶mU,double¶mV,Mpoint&pointAffterDeformed);staticMStringnodeName;staticMTypeIdnodeId;staticMObjectglide;staticMObjectfixedBase;staticMObjectaimDirection;staticMObjectdrivenSurface;staticMObjectbaseSurface;};#endif//Cpp文件#include”glideDeformer.h”MStringglideDeformer::nodeName=MString(“glideDeformer”);MTypeIdglideDeformer::nodeId=MTypeId(0x87031);MObjectglideDeformer::glide;MObjectglideDeformer::fixedBase;MObjectglideDeformer::aimDirection;MObjectglideDeformer::drivenSurface;MObjectglideDeformer::baseSurface;usingstd::cout;usingstd::endl;MStatusglideDeformer::initializeAttr(){MFnNumericAttributenumattr;MFnTypedAttributetypedattr;MFnEnumAttributeenumattr;glide=numattr.create(“glide”,”gld”,MFnNumericData::kFloat,0.0);numattr.setKeyable(true);numattr.setStorable(true);fixedBase=numattr.create(“fixedBase”,”fxb”,MFnNumericData::kBoolean,0);numattr.setKeyable(true);numattr.setStorable(true);aimDirection=enumattr.create(“aimDirection”,”adr”,0);enumattr.addField(“directionU”,0);enumattr.addField(“directionV”,1);enumattr.setKeyable(true);enumattr.setStorable(true);drivenSurface=typedattr.create(“drivenSurface”,”dsf”,MFnData::kNurbsSurface);typedattr.setStorable(false);baseSurface=typedattr.create(“baseSurface”,”bsf”,MFnData::kNurbsSurface);typedattr.setStorable(false);//addAttribtueaddAttribute(glide);addAttribute(fixedBase);addAttribute(drivenSurface);addAttribute(baseSurface);addAttribute(aimDirection);attributeAffects(glide,outputGeom);attributeAffects(fixedBase,outputGeom);attributeAffects(aimDirection,outputGeom);attributeAffects(drivenSurface,outputGeom);attributeAffects(baseSurface,outputGeom);returnMS::kSuccess;};boolglideDeformer::getClosestUVparam(Mpoint&point,MFnNurbsSurface&surfaceFn,MObjectsurfaceData,double¶mU,double¶mV){surfaceFn.setObject(surfaceData);Mpointtmppoint=surfaceFn.closestpoint(point,0,0,false,0.001,MSpace::kWorld);MStatusstat=surfaceFn.getparamAtpoint(tmppoint,paramU,paramV,true,MSpace::kWorld,0.001);returntrue;};boolglideDeformer::getpointFroamSurfacepoint(Mpoint&point,MFnNurbsSurface&surfaceFn,MObjectsurfaceData,double¶mU,double¶mV,Mpoint&outpoint){surfaceFn.setObject(surfaceData);MVectortangentU;MVectortangentV;MVectornormal;Mpointsurfacepoint;surfaceFn.getpointAtparam(paramU,paramV,surfacepoint,MSpace::kWorld);normal=surfaceFn.normal(paramU,paramV,MSpace::kWorld);surfaceFn.getTangents(paramU,paramV,tangentU,tangentV,MSpace::kWorld);tangentU.normalize();tangentV.normalize();normal.normalize();doublematrix={{tangentU.x,tangentU.y,tangentU.z,0.0},{normal.x,normal.y,normal.z,0.0},{tangentV.x,tangentV.y,tangentV.z,0.0},{surfacepoint.x,surfacepoint.y,surfacepoint.z,1.0}};MMatrixsurfacepointMatrix=MMatrix(matrix);//cout<<“baseSurfacepointMatrix:”<<surfacepointmatrix<<endl;outpoint=point*surfacepointMatrix.inverse();//cout<<"pointInSurfaceMatrixposition:"<<outpoint<<endl;returntrue;};boolglideDeformer::getpointAfterDeformed(Mpoint&pointInSurfaceMatrix,MFnNurbsSurface&surfaceFn,MObjectsurfaceData,double¶mU,double¶mV,Mpoint&pointAffterDeformed){surfaceFn.setObject(surfaceData);MVectortangentU;MVectortangentV;MVectornormal;Mpointsurfacepoint;surfaceFn.getpointAtparam(paramU,paramV,surfacepoint,MSpace::kWorld);normal=surfaceFn.normal(paramU,paramV,MSpace::kWorld);surfaceFn.getTangents(paramU,paramV,tangentU,tangentV,MSpace::kWorld);tangentU.normalize();tangentV.normalize();normal.normalize();doublematrix={{tangentU.x,tangentU.y,tangentU.z,0.0},{normal.x,normal.y,normal.z,0.0},{tangentV.x,tangentV.y,tangentV.z,0.0},{surfacepoint.x,surfacepoint.y,surfacepoint.z,1.0}};MMatrixsurfacepointMatrix=MMatrix(matrix);//cout<<"drivenSurfacepointMatrix:"<<surfacepointmatrix<<endl;pointAffterDeformed=pointInSurfaceMatrix*surfacepointMatrix;//cout<<"pointAffterDeformedposition:"<<pointaffterdeformed<<endl;returntrue;};MStatusglideDeformer::deform(MDataBlock&block,MItGeometry&iter,constMMatrix&mat,unsignedintmultiIndex){//cout<<"deform()方法调用…"<<endl;MDataHandleenvelopehandle=block.inputValue(envelope);MDataHandleglidehandle=block.inputValue(glide);MDataHandlefixedBasehandle=block.inputValue(fixedBase);MDataHandleaimDirectionhandle=block.inputValue(aimDirection);floatenvelopevalue=envelopehandle.asFloat();floatglidevalue=glidehandle.asFloat();shortaimDirectionvalue=aimDirectionhandle.asShort();boolfixedBasevalue=fixedBasehandle.asBool();if(envelopevalue==0.0){//cout<<"envelope值为0,跳过deform方法…"<<endl;returnMS::kSuccess;};MDataHandledrivenSurfacehandle=block.inputValue(drivenSurface);MDataHandlebaseSurfacehandle=block.inputValue(baseSurface);MFnNurbsSurfaceDatasurfaceDataFn;MFnNurbsSurfacesurfaceFn;MObjectdrivenSurfaceData=drivenSurfacehandle.asNurbsSurface();MObjectbaseSurfaceData=baseSurfacehandle.asNurbsSurface();MObjectdrivenSurfaceObj=surfaceDataFn.create();MObjectbaseSurfaceObj=surfaceDataFn.create();surfaceFn.setObject(drivenSurfaceData);surfaceFn.copy(drivenSurfaceObj);intdrivenSurfaceCvU=surfaceFn.numCVsInU();intdrivenSurfaceCvV=surfaceFn.numCVsInV();surfaceFn.setObject(baseSurfaceData);surfaceFn.copy(baseSurfaceObj);intbaseSurfaceCvU=surfaceFn.numCVsInU();intbaseSurfaceCvV=surfaceFn.numCVsInV();cout<<drivensurfacecvu<<" "<<drivensurfacecvv<<" "<<basesurfacecvu<<" "<<basesurfacecvv<<" "<<endl;if(drivenSurfaceCvU==0||drivenSurfaceCvV==0||drivenSurfaceCvU==0||baseSurfaceCvU==0||baseSurfaceCvV==0){//cout<<"drivenSurface或baseSurface不正确,变形不产生…"<<endl;MGlobal::displayWarning("drivenSurface或baseSurface不正确,变形不产生…");returnMS::kSuccess;};if(drivenSurfaceCvU!=baseSurfaceCvU||drivenSurfaceCvV!=baseSurfaceCvV){//cout<<"drivenSurface与baseSurface不匹配,变形不产生…"<<endl;MGlobal::displayWarning("drivenSurface与baseSurface不匹配,变形不产生…");returnMS::kSuccess;};Mpointpt;MpointptAfterDeformed;MpointpointInSurfacepointMatrix;doubleparamU;doubleparamV;doublenewparamU;doublenewparamV;intindex;floatweight;booltest;if(fixedBasevalue==false){//cout<<"履带模式…"<<endl;for(iter.reset();!iter.isDone();iter.next()){index=iter.index();//cout<<"index:"<<index<<endl;weight=weightValue(block,multiIndex,index);//cout<<"weight:"<<weight<<endl;if(weight==0){//cout<<"权重为0,此点变形不产生…"<<endl;continue;};pt=iter.position(MSpace::kObject);pt=pt*mat;//cout<<"position:"<<pt<<endl;
</pt<<endl;</endl;</weight<<endl;</index<<endl;</endl;</endl;</endl;</drivensurfacecvu<<" "<<drivensurfacecvv<<" "<<basesurfacecvu<<" "<<basesurfacecvv<<" "<<endl;</endl;</endl;</pointaffterdeformed<<endl;</surfacepointmatrix<<endl;</outpoint<<endl;</surfacepointmatrix<<endl;
以上就是好酷屋教程网小编为您收集和整理的maya履带动画绑定插件代码相关内容,如果对您有帮助,请帮忙分享这篇文章^_^
本文来源: https://www.haoku5.com/IT/6440cf7d8d29a26e1509897e.html
相关推荐
热门专题
PS快捷键_PS快捷键大全
经典的Photoshop快捷键大全,如果你是入门阶段的水平,熟读此文并掌握,马上进阶为中级水平。matlab怎么换行?matlab换行教程
今天小编为大家带来的是matlab换行的教程,想知道怎么换行的小伙伴来看看接下来的这篇文章吧,相信一定会帮到你们的。matlab怎么换行?matlab换行教程1、首先在matlab主页面板中点击【Matlab求矩阵的乘积的操作方法
很多用户在使用Matlab的时候,不是很熟悉其中怎么求矩阵的乘积的?本期为你们带来的教程就描述了Matlab求矩阵的乘积的操作方法。Matlab求矩阵的乘积的操作方法打Matlab,在命令行窗口goldwave怎么启用延迟录制计时器?goldwave启用延迟录制计时器教程
很多小伙伴在使用goldwave的时候,想知道怎么启用延迟录制计时器,下面小编就为大家分享教程,感兴趣的小伙伴不要错过哦!goldwave怎么启用延迟录制计时器?goldwave启用延迟录制计时器教分区工具diskgenius强制删除文件的具体使用流程
很多人不知道分区工具diskgenius如何强制删除文件?今日为你们带来的文章是关于分区工具diskgenius强制删除文件的具体含义讲解,还有不清楚小伙伴和小编一起去学习一下吧。分区工具diskgpycharm使用技巧
今天小编给大家讲解pycharm使用技巧,有需要或者有兴趣的朋友们可以看一看下文,相信对大家会有所帮助的。pycharm使用技巧使用PyCharm软件需要python运行环境,这里我已经下载好。CAD看图软件哪个好用?如何使用CAD看图软件
在CAD中,大家都知道CAD图纸是使用CAD制图软件来绘制完成的,那保存的格式就是为dwg格式和dxf格式的。那需要对图纸内容进行查看的时候,就要适用到CAD看图软件。但看图软件有很多,那么CAD看图diskgenius怎么将分区中的文件复制到指定目录?diskgenius将分区中的文件复制到指定目录方法
使用diskgenius的时候,很多小伙伴不知道怎么将分区中的文件复制到指定目录,下面小编就给大家带来方法,有需要的小伙伴不要错过哦。diskgenius怎么将分区中的文件复制到指定目录?diskg分区工具diskgenius将硬盘合并分区的详细流程
说起分区工具diskgenius伙伴们都不陌生,那么使用怎么使用分区工具将硬盘合并分区呢?下面一起看看关于分区工具diskgenius将硬盘合并分区的详细流程吧。分区工具diskgenius将硬盘合MathType中公式与文字错位的处理方法
最近有很多朋友向我咨询关于MathType中公式与文字错位的问题,今天就为大家介绍MathType中公式与文字错位的处理方法,希望能够帮助到大家。MathType中公式与文字错位的处理方法方法一