Jump to content
  • Advertisement

Archived

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

HyperMan

3D to 2D problem

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

im doing a map editor where i have to convert a point from 3d to 2d screen-coordinates. i have 4 different views: x-view (2d-view along the x-axis), y-view (along the y-axis), z-view (along the z-axis) and a 3d-view, everything like in worldcraft. the default translation is -1000.0f on the z-axis(for zooming away or closer to the grid). i have 2 functions: Point2DTo3D (this already works, im using gluUnProject) and Point3DTo2D (this doesn''t work, im using gluProject). i checked the first function by converting the current mouse position (window-coords) to 3d coords and set a vertex at this location. every time i translated on the x,y or z-axis the 3d point was set on the correct position. to test the second function (point3dto2d) i just converted the 3d point back to 2d. if i translate on the x-axis the x and y window coords are correct, but if i translate on the y-axis the y window coord is totally wrong, why? do i do it correct: double wx,wy,wz; gluProject(x,y,0,modelview,projection,viewport,&wx,&wy,&wz); dont wonder about the zero, since im looking along the z-axis i dont care about this value. i think i have to do something with the y value before i call this function.

Share this post


Link to post
Share on other sites
Advertisement
Subtract your y-coordinate from the height of the screen. The problem is that OpenGL and WinAPI have different understanding of where the point (0,0) lies

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!