永发信息网

用maya mel如何实现如下功能:得到鼠标选择的顶点的坐标? 谢谢!

答案:4  悬赏:60  手机版
解决时间 2021-03-31 02:06
  • 提问者网友:兔牙战士
  • 2021-03-30 15:37
用maya mel如何实现如下功能:得到鼠标选择的顶点的坐标? 谢谢!
最佳答案
  • 五星知识达人网友:孤老序
  • 2021-03-30 15:55
global proc sampleContextPress()
{
float $pressPosition[] = `draggerContext -query -anchorPoint sampleContext`;
print ("Press: " + $pressPosition[0] + " " + $pressPosition[1] + " "
+ $pressPosition[2] + "\n");
}
// Procedure called on drag
global proc sampleContextDrag()
{
float $dragPosition[] = `draggerContext -query -dragPoint sampleContext`;
int $button = `draggerContext -query -button sampleContext`;
string $modifier = `draggerContext -query -modifier sampleContext`;
print ("Drag: " + $dragPosition[0] + " " + $dragPosition[1] + " "
+ $dragPosition[2]
+ " Button is " + $button + " Modifier is " + $modifier + "\n");
string $message = ($dragPosition[0] + ", " + $dragPosition[1]);
draggerContext -edit -drawString $message sampleContext;
}
// Create the dragger context
draggerContext
-pressCommand "sampleContextPress"
-dragCommand "sampleContextDrag"
-cursor "hand"
sampleContext;
// Set current tool to use the sample context created.
// Results can be seen by dragging mouse in main window
setToolTo sampleContext;追问你写得相当好,你能不能实现得到被选择的点的绝对坐标?
谢谢!
全部回答
  • 1楼网友:零点过十分
  • 2021-03-30 19:15
是不是用鼠标右键选择快捷方式
  • 2楼网友:梦中风几里
  • 2021-03-30 18:07
用 ls -sl 获取所选取点的名称放入一个sting数组中。然后用Xform -q获取坐标。手机无力。就这么思路。
  • 3楼网友:污到你湿
  • 2021-03-30 17:05
string $selectObj[] = `filterExpand -ex true -sm 31`;
int $numSelectObj = size($selectObj);
int $i = 0;
for($ele in $selectObj)
{
    print("v" + $i + " ");
    $pos = `pointPosition -w $ele`; //get world position
    string $posStr;
    for($co in $pos)
    {
        $posStr += " " + $co;
    }
    print($posStr);       
    print(" ");
    
    $i++;
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯