# 3D to 2D coords....

• 10-17-2006
ellis
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 ?
• 10-17-2006
Shakti
Might find some ideas there.
• 10-17-2006
ellis
thats not it... thats somthing diferent.
• 10-17-2006
CornedBee
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.
• 10-18-2006
ellis
humm... i se what you meen, but dont really have the maths for it =P
gonna try and look it up.
• 10-18-2006
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.
• 10-18-2006
VirtualAce
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.
• 10-18-2006
psychopath
The OpenGL equiv to D3DXProject would be gluProject, if you're using OpenGL.
• 10-18-2006
ellis
Quote:

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.