3D Math Question

Blitz3D Forums/Blitz3D Programming/3D Math Question

jfk EO-11110(Posted 2004) [#1]
A question to the 3D Gurus out there:

When I give you the camera rotation and position, a pixels 2D screen-coordinate and the distance from the camera to the picked surface that lies under that pixel, is it possible to calculate the 3D Coordinate of that position where the surface was picked? (of course without to use Linepicks)


semar(Posted 2004) [#2]
Well, the point that lies on the picked surface, should be located on that surface, right ?

What's about using Camerapick ? Then PickedX, PickedY and PickedZ should provide you the values you need..

Or am I missing your question completely ?


jfk EO-11110(Posted 2004) [#3]
Yes :) I don't want to use a linepick (and a CameraPick is technically the same as a linepick) since it's all about speed optimation. I already know the distance, all I need to know now is where it exactly is. A simplified version of this calculation may be

x2= x1+(sin(angle)*distance)
z2= z1+(cos(angle)*distance)

where x1,z1 is the position of the camera and "angle" is calculated from the camera angle plus (the screen position multiplied with the distance) or something.

And it has to be in 3D :)


jfk EO-11110(Posted 2004) [#4]
Thanks for your help. Darn, feels like I am in the middle of a vacuum...

Semar, remind me to offer you a beer if I ever gonna meet you IRL.


Clarks(Posted 2004) [#5]
yes its possible.

of course its all about using transformation and invtransformation.

to be more precise, if you can plot a position in 3d space on a 2d screen, you just have to do the inverse.

when you do the inverse youll be transforming the pixel to camera space, and next youll have to transform it to world space.

it sounds complicated but its easy, im too lazy to code something like that right now.


jfk EO-11110(Posted 2004) [#6]
thanks anyway!