views:

232

answers:

1

hello...

i have created a dragger context in maya using the following code, pos holds my 2D coordinates of mouse cursor, i want to convert it into 3D coordinate to be the source of the ray i want to launch,, i want it either through python scripting or through the python api,,

import maya.cmds as mc

mc.draggerContext( 'testContext', pressCommand='getCursorPos()',
                    dragCommand='getCursorPos()', cursor='default')

def getCursorPos():

    #--get the 2D position of cursor (on the view port)----

    pos = mc.draggerContext( 'testContext', query=1, dragPoint=1) 

    #----convert to 3D coordinates in the scene--------
    ????????

thanks in advance

A: 

Have you reviewed the projection (-pr) options for the draggerContext?

Mouse co-ordinates is data across 2 dimensions, and the projection options are methods to resolve how the 3rd dimension is mapped. For rays, maybe one of the following options is relevant to your question:

xAxis project to closest point on X axis yAxis project to closest point on Y axis zAxis project to closest point on Z axis

Here's hoping that helps and best of luck.

Mike Ton