Jump to content
  • Advertisement
Sign in to follow this  
paic

Computing the depth value of a point

This topic is 3253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi ! I've got a little question : I have a 3 dimensional point (in the world space) and I'd like to compute its depth (between 0 and 1 if I'm not mistaken) And I also would like to have a confirmation : when using D3DXVec3UnProject, the 2 first values (x and y) of the input vector are the x and y coordinate in screenspace, and the z value is the desired depth ? To be a little more precise, what I want to do is : I have a "screen space" 2D point, and a "world space" 3D point. Imagine a plane containing the 3D point and parallel to the camera. I want to project the 2D point onto that plane and get the coordinates :) So I thought : get the depth of the 3D point, create a vector with the 2D point and the previously computed depth, and unproject. But it doesn't seem to work ... Any idea ? PS: If you don't understand what I asked, don't hesitate to say it, english is not my mother language, so I know I might be confusing sometimes :)

Share this post


Link to post
Share on other sites
Advertisement
transform the world vector by camera view matrix and then by projection matrix. The z value of transformed vector will be the vectors depth in screen space normalized between 0-1 allready.

Share this post


Link to post
Share on other sites
Quote:
Original post by JohnnyCode
transform the world vector by camera view matrix and then by projection matrix. The z value of transformed vector will be the vectors depth in screen space normalized between 0-1 allready.


try using this
D3DXVECTOR3 * D3DXVec3Project(
D3DXVECTOR3 *pOut,
CONST D3DXVECTOR3 *pV,
CONST D3D10_VIEWPORT *pViewport,
CONST D3DXMATRIX *pProjection,
CONST D3DXMATRIX *pView,
CONST D3DXMATRIX *pWorld
);

[Edited by - e3d_ALiVE on October 24, 2009 3:27:46 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!