maya,在曲线的cv点生成locator,控制曲线

本文介绍了一种使用Maya进行曲线或模型表面控制点(CVs)的集群创建方法,通过Mel脚本和Python脚本两种方式实现了为每个控制点创建定位器并设置集群变形的目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mel

string $sels[] = `ls -sl`;
string $sel;
for($sel in $sels){
int $numCVs = `getAttr -size ($sel+".controlPoints")`;
select -cl;
int $i;
for($i=0;$i<$numCVs;$i++){
select -r ($sel+".cv["+$i+"]");
string $clusternames[] = `cluster -envelope 1`;
vector $pointr = `xform -q -ws -t ($sel+".cv["+$i+"]")`;
string $spanum[] = `spaceLocator -p 0 0 0`;
xform -r -t ($pointr.x) ($pointr.y) ($pointr.z) $spanum[0] ;

pointConstraint $spanum[0] $clusternames[1];
setAttr ($clusternames[1]+".visibility") 0;
}
}

 

string $sels[] = `ls -sl`;
string $sel;
for($sel in $sels){
int $numCVs = `getAttr -size ($sel+".controlPoints")`;
select -cl;
int $i;
for($i=0;$i<$numCVs;$i++){


vector $pointr = `xform -q -ws -t ($sel+".cv["+$i+"]")`;
string $spanum[] = `spaceLocator `;
xform -r -t ($pointr.x) ($pointr.y) ($pointr.z) $spanum[0] ;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1 $spanum[0];
select -r ($sel+".cv["+$i+"]");
cluster -wn $spanum[0] $spanum[0];

}
}

 

 python

import maya.cmds as cmd
sels=cmd.ls(sl=True)
for sel in sels:
    cvnum = cmd.getAttr(sel+'.controlPoints', size=1)
    for i in range(0,cvnum):
        cmd.select(sel+('.cv['+str(i)+']'),r=1)
        clustername =cmd.cluster(envelope=1)
        pointr =cmd.xform(sel+('.cv['+str(i)+']'),q=1,ws=1,t=1)
        spanum =cmd.spaceLocator(p=(0,0,0))
        cmd.xform(spanum[0],r=1,t=(pointr[0],pointr[1],pointr[2]))
        cmd.pointConstraint(spanum[0],clustername[1])
        cmd.setAttr(clustername[1]+".visibility",0)

  

转载于:https://www.cnblogs.com/ladaojeifang/archive/2013/04/25/3042519.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值