something like this should do the trick.
pseudo code:

camPos = `xform -q -t "yourShotCam" `
vertPos = "your vertext point position"
distToVert = mag(vertPos - camPos)


HTH, -d

On Thu, Jul 7, 2011 at 8:09 AM, Sebastian Schoellhammer <
[email protected]> wrote:

> Hello .. again! :)
>
> I have a new problem!
> I'm trying to get the depth of a vertex from the camera and I am ..
> confused.
>
> My attempt is getting the world position and multiplying it by the
> inclusiveMatrixInverse() of the camera.
> (Btw this gives the same result as multiplying with modelViewMatrix() from
> the current view, which makes sense I suppose.)
>
> What I don't understand now is that the z value of the transformed position
> does not change at all when I move the camera towards or away from the
> object.
> It does change however when I tumble around the object.
>
> What I am trying to achieve is a selection tool that ignores elements that
> are not actually visible. (or I'll go slowly crazy constantly picking the
> wrong things!!)
>
> So my plan is to read the depthbuffer of the viewport to check the depth of
> my verts against it - and ignore .those with a higher depth.
> (reading the depthbuffer is easier as worldToView conveniently does the
> job, properly,  but sadly doesn't give me a z value :( )
>
> MPoint pos = iterVtx.position(MSpace::kWorld);
> pos = camera.inclusiveMatrixInverse()*pos;
>
> this at least is correct I hope?
>
> Thanks for any hints!!
> Seb
>
>
>
>  --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to