Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BahYou

Converting 3D space to 2D space

This topic is 5131 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

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!