欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

maya视图物体对齐放大平移插件 - 建模人员必备

程序员文章站 2022-03-05 10:24:53
...

maya视图物体对齐放大平移插件 - 建模人员必备

建模人员经常要导入参考图平面作为参考,但是在调整模型局部位置时看不清,精度不够,那么摄像机如何能不改变视角、位置和参数,而实现单纯视图的放大呢?这个工具解决这个问题。
maya视图平移发大镜工具-建模人员必备

使用方法:
直接将代码拷贝到maya脚本编辑中,按ctrl+回车,即可弹出界面,点击 pan view按钮,鼠标按住左键点击视图并拖动即可平移视图,点击插件zoom view按钮,之后左键点击视图并拖动即可放大视图,,之后,使用移动、旋转、缩放工具进行局部物体与参考图对齐和微调。点击插件reset view按钮,可以恢复视图默认状态。南无阿弥陀佛

global proc tjh_CameraPanAndZoom()
	{
	if ( ` windowPref -exists tjh_CameraPanAndZoom_window `)
		    windowPref -remove  tjh_CameraPanAndZoom_window;     
		  
			if (`window -exists tjh_CameraPanAndZoom_window`)
				deleteUI tjh_CameraPanAndZoom_window;


	window -w 180-h 200 tjh_CameraPanAndZoom_window;
	columnLayout;						
			separator -h 10 -w 180;
			text  -fn boldLabelFont   -al "center" -l " Zoom and pan Camera V1.0";
			//text  -fn boldLabelFont   -al "center" -l " programmer:tiancg  ";
			separator -h 10 -w 180;
			text -w 180 -wordWrap 1  -al "center" -l "  插件说明:本工具可以移动放大摄像机视图方便参考图片与模型对齐。";
			separator -h 10 -w 180;
			text  -w 180 -wordWrap 1   -al "center" -l " 切换到有参考图平面的摄像机,点击相应的按钮,按住鼠标左键在视图中拖动即可操作视图。";
			separator -h 10 -w 180;
			button  -w 180 -backgroundColor 0.6 0.6 1.0 -label "Pan View"  -command  "PanZoomTool;tjh_CameraPanAndZoom_openToggle;panZoomCtx -e -panMode PanZoomContext;";
			separator -h 10 -w 180;
			button  -w 180 -backgroundColor 0.6 0.6 1.0 -label "Zoom View"  -command  "PanZoomTool;tjh_CameraPanAndZoom_openToggle;panZoomCtx -e -zoomMode PanZoomContext;";
			separator -h 10 -w 180;
			button  -w 180 -backgroundColor 0.6 1.6 0.6 -label "Reset View"  -command  "tjh_CameraPanAndZoom_reset;;";
			
			setParent ..;
	showWindow;

}
global proc tjh_CameraPanAndZoom_openToggle()
{	
	

	string $camera = ` lookThru -q `;
	string $cameraShape[] = ` ls -dag  -shapes  $camera `;
	print $cameraShape[0];


	if (`objExists $cameraShape[0]`) 
	{
		
		if (`attributeExists "panZoomEnabled" $cameraShape[0]`)	setAttr ($cameraShape[0] + ".panZoomEnabled") 1;
	}	
}



global proc tjh_CameraPanAndZoom_reset()
{	
	
	string $camera = ` lookThru -q `;
	string $cameraShape[] = ` ls -dag  -shapes  $camera `;
	print $cameraShape[0];

	if (`objExists $cameraShape[0]`) 
	{
		//reset attributes
		if (`attributeExists "overscan" $cameraShape[0]`)	setAttr ($cameraShape[0] + ".overscan") 1;
		if (`attributeExists "horizontalFilmOffset" $cameraShape[0]`)	setAttr ($cameraShape[0] + ".horizontalFilmOffset") 0;
		if (`attributeExists "verticalFilmOffset" $cameraShape[0]`)	setAttr ($cameraShape[0] + ".verticalFilmOffset")  0;
		if (`attributeExists "panZoomEnabled" $cameraShape[0]`)	setAttr ($cameraShape[0] + ".panZoomEnabled") 0;
		
	}

	
	
	//restore undo
	undoInfo -swf 1;
	global string $gSelect;
	setToolTo $gSelect;
}
tjh_CameraPanAndZoom;