Convert Screen Coordinates do World Coordinates - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Convert Screen Coordinates do World Coordinates

I have a point defined on screen, that i captured using Win32 API "GetCursorPos" and transformed it with the "ScreenToClient" in order to know where the click was made on screen.
After that i created a PointF variable to keep the values of .X and .Y.

I need to use that point (actually its a lot of points created that way) in a variable of type Direct3D.CustomVertex.PositionColored, in order to position the point in my 3d world.
Of course that if i do something like:

tmp_point = (PointF)m_pontos_coordenadas[key]; // tmp_point is a PointF variable
v = new Vector3(tmp_point.X, -tmp_point.Y, 1.0f);
vertexColored[internal_counter].SetPosition(v); //vertexColored[internal_counter]is a variable of type Direct3D.CustomVertex.PositionColored

this wont work because one is in screen coordinates and the other is in world coordinates.
How can i convert the screen coordinates to the world coordinates?
my World is defined as:

graphics.Transform.View = Matrix.OrthoOffCenterLH(0, screenwidth - 150, screenheight, 0, 1, 10);

where screenwidth =800 and screenheight=600

Can you help?
my thanks in advanced
Sign In or Register to comment.