> > items = mc.ls(sl=1) > viewport = ui.qGetViewport() > dp = api.MDagPath() > view = apiui.M3dView.active3dView() > view.getCamera(dp) > camFn = api.MFnCamera( dp ) >
> itemsPos = mc.xform( items, q=1, ws=1, t=1 ) > camPos = mc.xform( obj.currentCamera(), q=1, ws=1, t=1 ) > camDir = camFn.viewDirection( api.MSpace.kWorld ) > camUp = camFn.upDirection( api.MSpace.kWorld ) > camRight = camFn.upDirection( api.MSpace.kWorld ) > camObjVector=api.MVector(camPos[0]-itemsPos[0], camPos[1]-itemsPos[1], > camPos[2]-itemsPos[2]) > angle = camObjVector.angle(camDir) > depth = abs( camObjVector.length() * math.cos(angle) ) > depth -= camFn.nearClippingPlane() > > wp = api.MPoint() > wv = api.MVector() > view.viewToWorld( 0, 0, wp, wv ) > > v = camDir * depth > > x = wp[0] + v[0] > y = wp[1] + v[1] > z = wp[2] + v[2] > > mc.xform( items, t=(x,y,z), ws=True > I have this code to move object under mouse. *autoPlace(um=True)* is good but i need more than viewport edges. So i want manualy move object in camera projection without influences. Code work well for orthographic views. But not for perspective. I need rotate camDir about somуthing according to camera angle of view. -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
