# Thread: 3D to 2D coords....

1. ## 3D to 2D coords....

I'm working on a simple demo app. What i need to do is convert a point in 3D space to a point in 2D space (in this case my screen).

I was thinking of creating a vector from the point where the 4 viewport edges meets behind the camera, to the point in 3D, and detect the intersection point in the nearclipping plane. But from there, im lost. I also know that the nearclipping plane can be both infront of the camera and behind.

Any one got any good ideas ?

Might find some ideas there.

3. thats not it... thats somthing diferent.

4. Can't you just use the projection matrix for that? That's what the graphics card does, after all, to map 3d points to the final 2d image.

5. humm... i se what you meen, but dont really have the maths for it =P
gonna try and look it up.

6. It's multiplying the vector with a single matrix. If you don't have the maths for that then, I'm sorry to say, you have no business in 3d graphics.

7. D3DX has a function called D3DXProject() which projects a 3D vector from 3D space to 2D screen space. To do a type of targeting system for a HUD you would project the corners of your bounding volume into 2D space and then when you finally have the 2D values, you can determine which ones are most appropriate for display.

8. The OpenGL equiv to D3DXProject would be gluProject, if you're using OpenGL.

9. Originally Posted by CornedBee
It's multiplying the vector with a single matrix. If you don't have the maths for that then, I'm sorry to say, you have no business in 3d graphics.