#### Archived

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

# Converting 3D space to 2D space

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

## 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 on other sites
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 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 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

[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
"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 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

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 9
• 15
• ### Forum Statistics

• Total Topics
633392
• Total Posts
3011639
• ### Who's Online (See full list)

There are no registered users currently online

×