Converting 3D space to 2D space

Started by
3 comments, last by BahYou 19 years, 11 months ago
What I have so far is an ortho matrix conversion in order to display my 2D UI. Problem is, is that I want to take a coordinate in 3d space and convert it to my 2d space. For example, I have a sphere located at world position (-5,5,3) and I want to draw a menu next to the sphere in my ortho view. If my ortho view is between [-1,1] (for x y position that is) how can I figure out where the point is between -1 and 1 that is (-5,5,3) in world 3D space? Thanks.
Advertisement
Vector3.Project (in C#) in C/C++ it would be something like D3DXVector3Project ?

I have used them before and I belive that''s what you want, I''m fairly new to 3D so don''t take my word as stone.
Thanks for your reply but I searched around but couldn''t find a D3DXVector3Project or some thing similar (C++). Does any one else know what it is in C++?


On the other hand, does any one know the math being performed when the orhto projection is created? I''m not familar with matrices all that much.
What are you using? OpenGL?

I imagine that you have a 3D position (xyz), to find out where in the 2D window surface it will end up, you do:

V' = V * ModelViewProjection;

So, you have to multiply the current position, by the MVP matrix, which you can get under OpenGL as:

float matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
glGetFloatv(GL_PROJECTION_MATRIX, matrix);

Hope it helped

Salsa cooked it, your eyes eat it![Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"our stupidity allways comes back to bite us in the ass... in a white-shark sort of way..." - Prozak

[edited by - Prozak on May 7, 2004 7:18:25 AM]
quote:Original post by BahYou
Thanks for your reply but I searched around but couldn''t find a D3DXVector3Project or some thing similar (C++). Does any one else know what it is in C++?

The name given was close enough so that you should have been able to find the function without much trouble. In any case, the function name is D3DXVec3Project.

neneboricua

This topic is closed to new replies.

Advertisement