2
$\begingroup$

Given a pixel on the rendered image, is there any easy way to get the 3D location that the pixel corresponds to in the scene using python? i would really like to know before I go through trying to do the math to get it myself.

In case it makes a difference, I'm using an orthographic camera.

$\endgroup$
  • $\begingroup$ It is possible in the game engine, using the 'kx_camera.getScreenVect()' call. Not sure about the viewport. $\endgroup$ – Mike Pan Feb 17 '14 at 20:27
  • $\begingroup$ It's possible in the viewport too, but rendered image? Not sure... What is the application? $\endgroup$ – CodeManX Feb 17 '14 at 23:50
2
$\begingroup$

There are utility functions to convert 2d region coordinates to 3d:

bpy_extras.view3d_utils

There's also a method to cast a ray in the scene:

Scene.ray_cast

... but it might not work with orthographic view.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.